bank20baht-ui 0.0.1 → 0.0.2

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.
@@ -1,8 +1,8 @@
1
- import { LitElement as E, nothing as h, html as d, svg as p } from "lit";
1
+ import { LitElement as E, nothing as h, html as d, svg as u } from "lit";
2
2
  import { property as a, query as C, customElement as $, state as _ } from "lit/decorators.js";
3
- var B = Object.defineProperty, f = (t, e, i, o) => {
4
- for (var s = void 0, r = t.length - 1, n; r >= 0; r--)
5
- (n = t[r]) && (s = n(e, i, s) || s);
3
+ var B = Object.defineProperty, f = (t, e, i, r) => {
4
+ for (var s = void 0, o = t.length - 1, n; o >= 0; o--)
5
+ (n = t[o]) && (s = n(e, i, s) || s);
6
6
  return s && B(e, i, s), s;
7
7
  };
8
8
  class v extends E {
@@ -13,10 +13,10 @@ class v extends E {
13
13
  function w(t, e) {
14
14
  let i = e;
15
15
  for (; i.parentNode && i.parentNode !== t; ) i = i.parentNode;
16
- const o = Array.from(t.childNodes).filter(
16
+ const r = Array.from(t.childNodes).filter(
17
17
  (s) => s !== i && s.nodeType !== Node.COMMENT_NODE
18
18
  );
19
- o.length > 0 && e.append(...o);
19
+ r.length > 0 && e.append(...r);
20
20
  }
21
21
  class m extends v {
22
22
  constructor() {
@@ -88,14 +88,15 @@ f([
88
88
  a({ attribute: !1 })
89
89
  ], m.prototype, "error");
90
90
  const O = {
91
- copy: p`<rect x="6" y="6" width="8" height="8" rx="1.5"/><path d="M10 6V4.5A1.5 1.5 0 0 0 8.5 3H4.5A1.5 1.5 0 0 0 3 4.5v4A1.5 1.5 0 0 0 4.5 10H6"/>`,
92
- check: p`<path d="M3.5 8.5 6.5 11.5 12.5 4.5"/>`,
93
- download: p`<path d="M8 3v7m0 0 3-3m-3 3L5 7"/><path d="M3 12h10"/>`,
94
- upload: p`<path d="M8 12V5m0 0 3 3M8 5 5 8"/><path d="M3 4h10"/>`,
95
- plus: p`<path d="M8 3.5v9M3.5 8h9"/>`,
96
- external: p`<path d="M6 3H3.5v9.5h9.5V10"/><path d="M9 3h4v4"/><path d="M13 3 7.5 8.5"/>`,
97
- close: p`<path d="M4 4l8 8M12 4l-8 8"/>`,
98
- play: p`<path d="M5 3.5v9l7-4.5z"/>`
91
+ copy: u`<rect x="6" y="6" width="8" height="8" rx="1.5"/><path d="M10 6V4.5A1.5 1.5 0 0 0 8.5 3H4.5A1.5 1.5 0 0 0 3 4.5v4A1.5 1.5 0 0 0 4.5 10H6"/>`,
92
+ check: u`<path d="M3.5 8.5 6.5 11.5 12.5 4.5"/>`,
93
+ download: u`<path d="M8 3v7m0 0 3-3m-3 3L5 7"/><path d="M3 12h10"/>`,
94
+ upload: u`<path d="M8 12V5m0 0 3 3M8 5 5 8"/><path d="M3 4h10"/>`,
95
+ plus: u`<path d="M8 3.5v9M3.5 8h9"/>`,
96
+ external: u`<path d="M6 3H3.5v9.5h9.5V10"/><path d="M9 3h4v4"/><path d="M13 3 7.5 8.5"/>`,
97
+ close: u`<path d="M4 4l8 8M12 4l-8 8"/>`,
98
+ play: u`<path d="M5 3.5v9l7-4.5z"/>`,
99
+ search: u`<circle cx="7" cy="7" r="4"/><path d="m13 13-3.2-3.2"/>`
99
100
  };
100
101
  function M(t) {
101
102
  return d`<svg
@@ -114,10 +115,10 @@ function M(t) {
114
115
  function I(t) {
115
116
  return t in O;
116
117
  }
117
- var P = Object.defineProperty, S = Object.getOwnPropertyDescriptor, u = (t, e, i, o) => {
118
- for (var s = o > 1 ? void 0 : o ? S(e, i) : e, r = t.length - 1, n; r >= 0; r--)
119
- (n = t[r]) && (s = (o ? n(e, i, s) : n(s)) || s);
120
- return o && s && P(e, i, s), s;
118
+ var x = Object.defineProperty, P = Object.getOwnPropertyDescriptor, p = (t, e, i, r) => {
119
+ for (var s = r > 1 ? void 0 : r ? P(e, i) : e, o = t.length - 1, n; o >= 0; o--)
120
+ (n = t[o]) && (s = (r ? n(e, i, s) : n(s)) || s);
121
+ return r && s && x(e, i, s), s;
121
122
  };
122
123
  let c = class extends v {
123
124
  constructor() {
@@ -127,46 +128,46 @@ let c = class extends v {
127
128
  this.iconOnly || w(this, this.buttonEl);
128
129
  }
129
130
  render() {
130
- const t = this.variant === "primary" ? "" : ` baht-button--${this.variant}`, e = this.size === "md" ? "" : ` baht-button--${this.size}`, i = this.iconOnly ? " baht-button--icon" : "", o = this.icon && I(this.icon) ? M(this.icon) : h;
131
+ const t = this.variant === "primary" ? "" : ` baht-button--${this.variant}`, e = this.size === "md" ? "" : ` baht-button--${this.size}`, i = this.iconOnly ? " baht-button--icon" : "", r = this.icon && I(this.icon) ? M(this.icon) : h;
131
132
  return d`<button
132
133
  class="baht-button${t}${e}${i}"
133
134
  type=${this.type}
134
135
  aria-label=${this.iconOnly && this.label ? this.label : h}
135
136
  ?disabled=${this.disabled}
136
- >${o}${this.iconOnly ? h : this.label}</button>`;
137
+ >${r}${this.iconOnly ? h : this.label}</button>`;
137
138
  }
138
139
  };
139
- u([
140
+ p([
140
141
  a()
141
142
  ], c.prototype, "variant", 2);
142
- u([
143
+ p([
143
144
  a()
144
145
  ], c.prototype, "size", 2);
145
- u([
146
+ p([
146
147
  a({ type: Boolean })
147
148
  ], c.prototype, "disabled", 2);
148
- u([
149
+ p([
149
150
  a()
150
151
  ], c.prototype, "type", 2);
151
- u([
152
+ p([
152
153
  a()
153
154
  ], c.prototype, "label", 2);
154
- u([
155
+ p([
155
156
  a()
156
157
  ], c.prototype, "icon", 2);
157
- u([
158
+ p([
158
159
  a({ type: Boolean, attribute: "icon-only" })
159
160
  ], c.prototype, "iconOnly", 2);
160
- u([
161
+ p([
161
162
  C("button")
162
163
  ], c.prototype, "buttonEl", 2);
163
- c = u([
164
+ c = p([
164
165
  $("baht-button")
165
166
  ], c);
166
- var k = Object.defineProperty, x = Object.getOwnPropertyDescriptor, y = (t, e, i, o) => {
167
- for (var s = o > 1 ? void 0 : o ? x(e, i) : e, r = t.length - 1, n; r >= 0; r--)
168
- (n = t[r]) && (s = (o ? n(e, i, s) : n(s)) || s);
169
- return o && s && k(e, i, s), s;
167
+ var S = Object.defineProperty, k = Object.getOwnPropertyDescriptor, y = (t, e, i, r) => {
168
+ for (var s = r > 1 ? void 0 : r ? k(e, i) : e, o = t.length - 1, n; o >= 0; o--)
169
+ (n = t[o]) && (s = (r ? n(e, i, s) : n(s)) || s);
170
+ return r && s && S(e, i, s), s;
170
171
  };
171
172
  let l = class extends v {
172
173
  constructor() {
@@ -189,12 +190,12 @@ let l = class extends v {
189
190
  i == null || i.focus(), t.preventDefault();
190
191
  return;
191
192
  }
192
- const o = e[0], s = e[e.length - 1], r = document.activeElement;
193
- if (!this.contains(r)) {
194
- o.focus(), t.preventDefault();
193
+ const r = e[0], s = e[e.length - 1], o = document.activeElement;
194
+ if (!this.contains(o)) {
195
+ r.focus(), t.preventDefault();
195
196
  return;
196
197
  }
197
- t.shiftKey && (r === o || r === i) ? (s.focus(), t.preventDefault()) : !t.shiftKey && r === s && (o.focus(), t.preventDefault());
198
+ t.shiftKey && (o === r || o === i) ? (s.focus(), t.preventDefault()) : !t.shiftKey && o === s && (r.focus(), t.preventDefault());
198
199
  }
199
200
  connectedCallback() {
200
201
  super.connectedCallback(), document.addEventListener("keydown", this.onKeydown);
@@ -207,9 +208,9 @@ let l = class extends v {
207
208
  }
208
209
  updated(t) {
209
210
  var e, i;
210
- if (t.has("open") && (l.openStack = l.openStack.filter((o) => o !== this), this.open && l.openStack.push(this)), t.has("open") && this.open && (this.previousFocus = document.activeElement, (e = this.querySelector(".baht-modal")) == null || e.focus()), t.has("open") && !this.open && t.get("open") === !0) {
211
- const o = this.previousFocus;
212
- this.previousFocus = null, o != null && o.isConnected && (!document.activeElement || document.activeElement === document.body || this.contains(document.activeElement)) && ((i = o.focus) == null || i.call(o));
211
+ if (t.has("open") && (l.openStack = l.openStack.filter((r) => r !== this), this.open && l.openStack.push(this)), t.has("open") && this.open && (this.previousFocus = document.activeElement, (e = this.querySelector(".baht-modal")) == null || e.focus()), t.has("open") && !this.open && t.get("open") === !0) {
212
+ const r = this.previousFocus;
213
+ this.previousFocus = null, r != null && r.isConnected && (!document.activeElement || document.activeElement === document.body || this.contains(document.activeElement)) && ((i = r.focus) == null || i.call(r));
213
214
  }
214
215
  }
215
216
  /** Ask the host to close (the host owns `open`). */
@@ -253,10 +254,10 @@ y([
253
254
  l = y([
254
255
  $("baht-modal")
255
256
  ], l);
256
- var q = Object.defineProperty, D = Object.getOwnPropertyDescriptor, g = (t, e, i, o) => {
257
- for (var s = o > 1 ? void 0 : o ? D(e, i) : e, r = t.length - 1, n; r >= 0; r--)
258
- (n = t[r]) && (s = (o ? n(e, i, s) : n(s)) || s);
259
- return o && s && q(e, i, s), s;
257
+ var q = Object.defineProperty, D = Object.getOwnPropertyDescriptor, g = (t, e, i, r) => {
258
+ for (var s = r > 1 ? void 0 : r ? D(e, i) : e, o = t.length - 1, n; o >= 0; o--)
259
+ (n = t[o]) && (s = (r ? n(e, i, s) : n(s)) || s);
260
+ return r && s && q(e, i, s), s;
260
261
  };
261
262
  let b = class extends v {
262
263
  constructor() {
@@ -0,0 +1,16 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ import { ChartGroup } from './charts.js';
4
+ /**
5
+ * Horizontal bars with counts (report type "bar").
6
+ *
7
+ * const el = document.createElement('baht-bar-chart');
8
+ * el.groups = [{ label: 'P1', count: 2 }, { label: 'P2', count: 7 }];
9
+ */
10
+ export declare class BahtBarChart extends BahtElement {
11
+ groups: ChartGroup[];
12
+ /** Single color for every bar; per-series palette otherwise. */
13
+ color: string;
14
+ emptyMessage: string;
15
+ protected render(): TemplateResult;
16
+ }
@@ -0,0 +1,22 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ import { ChartGroup } from './charts.js';
4
+ /**
5
+ * Pure-SVG donut with legend (report type "pie").
6
+ *
7
+ * const el = document.createElement('baht-donut-chart');
8
+ * el.groups = [{ label: 'Open', count: 4 }, { label: 'Closed', count: 9 }];
9
+ *
10
+ * `total` defaults to the group sum; set it when the center number differs
11
+ * (e.g. records vs. groups).
12
+ */
13
+ export declare class BahtDonutChart extends BahtElement {
14
+ groups: ChartGroup[];
15
+ total: number | null;
16
+ /** Single-series color override (first segment). */
17
+ color: string;
18
+ centerLabel: string;
19
+ emptyMessage: string;
20
+ private static readonly R;
21
+ protected render(): TemplateResult;
22
+ }
@@ -0,0 +1,14 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /**
4
+ * Centered "nothing here" placeholder for lists, tables, and searches.
5
+ *
6
+ * <baht-empty-state message="No records to display" hint="Try clearing the filter"></baht-empty-state>
7
+ */
8
+ export declare class BahtEmptyState extends BahtElement {
9
+ /** Decorative glyph shown above the message (emoji or short text). */
10
+ icon: string;
11
+ message: string;
12
+ hint: string;
13
+ protected render(): TemplateResult;
14
+ }
@@ -0,0 +1,20 @@
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
+ */
11
+ export declare class BahtErrorState extends BahtElement {
12
+ /** Decorative glyph shown above the heading (emoji or short text). */
13
+ icon: string;
14
+ heading: string;
15
+ message: string;
16
+ /** Renders a retry button with this label; omit for no action. */
17
+ retryLabel: string;
18
+ private onRetry;
19
+ protected render(): TemplateResult;
20
+ }
@@ -0,0 +1,27 @@
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
+ */
12
+ export declare class BahtKeyvalueEditor extends BahtElement {
13
+ value: Record<string, unknown>;
14
+ keyPlaceholder: string;
15
+ valuePlaceholder: string;
16
+ addLabel: string;
17
+ disabled: boolean;
18
+ private rows;
19
+ /** Last value synced/emitted, serialized — hosts re-feed fresh-but-equal objects. */
20
+ private syncedJson;
21
+ protected willUpdate(changed: Map<PropertyKey, unknown>): void;
22
+ private toRows;
23
+ private commit;
24
+ private edit;
25
+ private addRow;
26
+ protected render(): TemplateResult;
27
+ }
@@ -0,0 +1,62 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ export interface ReferenceOption {
4
+ key: string;
5
+ label: string;
6
+ /** Secondary text shown right-aligned (e.g. the record's class/table). */
7
+ sub?: string;
8
+ }
9
+ /**
10
+ * Reference lookup: read-only input + magnifier opening a typeahead dropdown.
11
+ * The host supplies the data via `fetcher(term)`; the component owns the
12
+ * debounce, the dropdown, and the keyboard interaction.
13
+ *
14
+ * const el = document.createElement('baht-reference-picker');
15
+ * el.fetcher = (term) => api.search('sys_user', term); // Promise<ReferenceOption[]>
16
+ * el.value = '6816f79cc0a8016401c5a33be04be441';
17
+ * el.display = 'Abel Tuter';
18
+ * el.addEventListener('baht-change', (e) => onPick(e.detail)); // { value, label }
19
+ *
20
+ * Clearing emits `baht-change` with `{ value: '', label: '' }`. Set `href` to
21
+ * render an open-record link next to the lookup button.
22
+ */
23
+ export declare class BahtReferencePicker extends BahtElement {
24
+ /** Accessible name for the combobox + its option list. */
25
+ label: string;
26
+ /** Selected id (the reference's key). */
27
+ value: string;
28
+ /** Human-readable label for `value`; falls back to showing the raw id. */
29
+ display: string;
30
+ placeholder: string;
31
+ disabled: boolean;
32
+ /** Marks the control invalid (styles + aria-invalid). */
33
+ invalid: boolean;
34
+ /** Optional link to the selected record, rendered as an external-link button. */
35
+ href: string;
36
+ /** Accessible name for the lookup button. */
37
+ lookupLabel: string;
38
+ /** Debounce for `fetcher` calls, ms. */
39
+ debounce: number;
40
+ /** Async search: term in, options out. Required for the dropdown to work. */
41
+ fetcher: ((term: string) => Promise<ReferenceOption[]>) | null;
42
+ private open;
43
+ private term;
44
+ private options;
45
+ private loading;
46
+ private activeIndex;
47
+ private inputEl;
48
+ private readonly listboxId;
49
+ private timer;
50
+ private fetchSeq;
51
+ private readonly onDocMousedown;
52
+ disconnectedCallback(): void;
53
+ private openLookup;
54
+ private close;
55
+ private search;
56
+ private pick;
57
+ private clear;
58
+ private emitChange;
59
+ private onInput;
60
+ private onKeydown;
61
+ protected render(): TemplateResult;
62
+ }
@@ -0,0 +1,14 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /**
4
+ * Big single-number stat (report type "count").
5
+ *
6
+ * <baht-stat-chart total="1284" label="Open incidents"></baht-stat-chart>
7
+ */
8
+ export declare class BahtStatChart extends BahtElement {
9
+ total: number;
10
+ label: string;
11
+ /** Overrides the number color (defaults to the primary token). */
12
+ color: string;
13
+ protected render(): TemplateResult;
14
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Shared chart vocabulary for the baht-*-chart primitives.
3
+ *
4
+ * Series colors come from the `--baht-chart-1 … --baht-chart-10` tokens so a
5
+ * consumer can retheme every chart from CSS; `color` on a chart overrides the
6
+ * first (or only) series.
7
+ */
8
+ export interface ChartGroup {
9
+ label: string;
10
+ count: number;
11
+ }
12
+ /** CSS color for series `i` — `override` wins for the first series only. */
13
+ export declare function chartColor(i: number, override?: string): string;
@@ -7,7 +7,7 @@ import { TemplateResult } from 'lit';
7
7
  * Add an icon only when a component genuinely needs it; this is not a general
8
8
  * icon library.
9
9
  */
10
- export type IconName = 'copy' | 'check' | 'download' | 'upload' | 'plus' | 'external' | 'close' | 'play';
10
+ export type IconName = 'copy' | 'check' | 'download' | 'upload' | 'plus' | 'external' | 'close' | 'play' | 'search';
11
11
  /** Render a named icon, or `nothing`-equivalent empty when the name is unknown. */
12
12
  export declare function renderIcon(name: IconName): TemplateResult;
13
13
  export declare function isIconName(v: string): v is IconName;
@@ -34,5 +34,13 @@ export { BahtToggle } from './baht-toggle.js';
34
34
  export { BahtDatepicker } from './baht-datepicker.js';
35
35
  export { BahtFile } from './baht-file.js';
36
36
  export { BahtText } from './baht-text.js';
37
+ export { BahtStatChart } from './baht-stat-chart.js';
38
+ export { BahtDonutChart } from './baht-donut-chart.js';
39
+ export { BahtBarChart } from './baht-bar-chart.js';
40
+ export { chartColor, type ChartGroup } from './charts.js';
41
+ export { BahtEmptyState } from './baht-empty-state.js';
42
+ export { BahtErrorState } from './baht-error-state.js';
43
+ export { BahtKeyvalueEditor } from './baht-keyvalue-editor.js';
44
+ export { BahtReferencePicker, type ReferenceOption } from './baht-reference-picker.js';
37
45
  /** field descriptor `type` -> primitive tag (used by <baht-form> and the builder). */
38
46
  export declare const TAG_FOR_TYPE: Record<FieldType, string>;