bank20baht-ui 0.1.6 → 0.1.7

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.
@@ -21,12 +21,16 @@ export type CellRenderer = (value: unknown, row: Record<string, unknown>) => unk
21
21
  * t.cursorMode = true; t.hasNext = true; t.hasPrev = false;
22
22
  * t.addEventListener('baht-cursor-change', (e) => fetchPage(e.detail.direction));
23
23
  *
24
- * `visibleColumns` picks + orders a subset of `columns` client-side (no
25
- * refetch) — pair it with <baht-multiselect> as the chooser UI:
24
+ * Set `column-picker` for a built-in "Columns" toggle — it walks `columns`
25
+ * (or the first row's keys, same as the header does) and lets the user
26
+ * show/hide them client-side, no host wiring required:
26
27
  *
27
- * picker.field = { key: 'cols', options: Object.entries(t.columns).map(([key, label]) => ({ key, label })) };
28
- * picker.value = t.visibleColumns; // omit/empty = show all columns
29
- * picker.addEventListener('baht-input', (e) => t.visibleColumns = e.detail.value);
28
+ * t.columnPicker = true;
29
+ * t.addEventListener('baht-columns-change', (e) => console.log(e.detail.visibleColumns));
30
+ *
31
+ * `visibleColumns` still works standalone for a host-controlled subset (no
32
+ * refetch) — pass it explicitly and the built-in picker (if also enabled)
33
+ * starts from that selection and keeps emitting updates for it.
30
34
  */
31
35
  export declare class BahtTable extends BahtElement {
32
36
  /** Rows of the CURRENT page. */
@@ -49,16 +53,27 @@ export declare class BahtTable extends BahtElement {
49
53
  renderers: Record<string, CellRenderer>;
50
54
  /** Subset + order of `columns` to render; empty/omitted = show all. */
51
55
  visibleColumns: string[];
56
+ /** Built-in "Columns" toggle — derives its options from `columns`/rows. */
57
+ columnPicker: boolean;
52
58
  page: number;
53
59
  totalPages: number;
54
60
  /** Switch the footer to Prev/Next (cursor-based API, no total count). */
55
61
  cursorMode: boolean;
56
62
  hasNext: boolean;
57
63
  hasPrev: boolean;
64
+ private pickerOpen;
65
+ /** User's picks once they've touched the picker; null = follow `visibleColumns`/all. */
66
+ private pickedColumns;
67
+ private readonly onDocMousedown;
68
+ disconnectedCallback(): void;
69
+ private get allColumnKeys();
58
70
  private get columnKeys();
71
+ private togglePicker;
72
+ private toggleColumn;
59
73
  private labelFor;
60
74
  private emitRow;
61
75
  private cell;
62
76
  private renderBody;
77
+ private renderColumnPicker;
63
78
  protected render(): TemplateResult;
64
79
  }
@@ -8348,7 +8348,7 @@
8348
8348
  "declarations": [
8349
8349
  {
8350
8350
  "kind": "class",
8351
- "description": "Server-side data table. `items` is ONE page of rows — the component never\nslices or fetches; on `baht-page-change` the host fetches the next page and\nre-feeds `items`/`page`. While that fetch runs, set `loading` to show\nskeleton rows.\n\n const t = document.querySelector('baht-table');\n t.columns = { name: 'Name', created_at: 'Created' };\n t.items = pageRows; // current page only\n t.loading = false; t.page = 1; t.totalPages = 12;\n t.addEventListener('baht-page-change', (e) => fetchPage(e.detail.page));\n t.addEventListener('baht-row-click', (e) => open(e.detail.id));\n\nSet `cursor-mode` for cursor-based APIs (no total count) — the footer\nbecomes a Prev/Next pair gated by `has-next`/`has-prev`, and the host\nlistens for `baht-cursor-change` instead of `baht-page-change`:\n\n t.cursorMode = true; t.hasNext = true; t.hasPrev = false;\n t.addEventListener('baht-cursor-change', (e) => fetchPage(e.detail.direction));\n\n`visibleColumns` picks + orders a subset of `columns` client-side (no\nrefetch) — pair it with <baht-multiselect> as the chooser UI:\n\n picker.field = { key: 'cols', options: Object.entries(t.columns).map(([key, label]) => ({ key, label })) };\n picker.value = t.visibleColumns; // omit/empty = show all columns\n picker.addEventListener('baht-input', (e) => t.visibleColumns = e.detail.value);",
8351
+ "description": "Server-side data table. `items` is ONE page of rows — the component never\nslices or fetches; on `baht-page-change` the host fetches the next page and\nre-feeds `items`/`page`. While that fetch runs, set `loading` to show\nskeleton rows.\n\n const t = document.querySelector('baht-table');\n t.columns = { name: 'Name', created_at: 'Created' };\n t.items = pageRows; // current page only\n t.loading = false; t.page = 1; t.totalPages = 12;\n t.addEventListener('baht-page-change', (e) => fetchPage(e.detail.page));\n t.addEventListener('baht-row-click', (e) => open(e.detail.id));\n\nSet `cursor-mode` for cursor-based APIs (no total count) — the footer\nbecomes a Prev/Next pair gated by `has-next`/`has-prev`, and the host\nlistens for `baht-cursor-change` instead of `baht-page-change`:\n\n t.cursorMode = true; t.hasNext = true; t.hasPrev = false;\n t.addEventListener('baht-cursor-change', (e) => fetchPage(e.detail.direction));\n\nSet `column-picker` for a built-in \"Columns\" toggle — it walks `columns`\n(or the first row's keys, same as the header does) and lets the user\nshow/hide them client-side, no host wiring required:\n\n t.columnPicker = true;\n t.addEventListener('baht-columns-change', (e) => console.log(e.detail.visibleColumns));\n\n`visibleColumns` still works standalone for a host-controlled subset (no\nrefetch) — pass it explicitly and the built-in picker (if also enabled)\nstarts from that selection and keeps emitting updates for it.",
8352
8352
  "name": "BahtTable",
8353
8353
  "members": [
8354
8354
  {
@@ -8471,6 +8471,16 @@
8471
8471
  "default": "[]",
8472
8472
  "description": "Subset + order of `columns` to render; empty/omitted = show all."
8473
8473
  },
8474
+ {
8475
+ "kind": "field",
8476
+ "name": "columnPicker",
8477
+ "type": {
8478
+ "text": "boolean"
8479
+ },
8480
+ "default": "false",
8481
+ "description": "Built-in \"Columns\" toggle — derives its options from `columns`/rows.",
8482
+ "attribute": "column-picker"
8483
+ },
8474
8484
  {
8475
8485
  "kind": "field",
8476
8486
  "name": "page",
@@ -8517,6 +8527,40 @@
8517
8527
  "default": "false",
8518
8528
  "attribute": "has-prev"
8519
8529
  },
8530
+ {
8531
+ "kind": "field",
8532
+ "name": "pickerOpen",
8533
+ "type": {
8534
+ "text": "boolean"
8535
+ },
8536
+ "privacy": "private",
8537
+ "default": "false"
8538
+ },
8539
+ {
8540
+ "kind": "field",
8541
+ "name": "pickedColumns",
8542
+ "type": {
8543
+ "text": "string[] | null"
8544
+ },
8545
+ "privacy": "private",
8546
+ "default": "null",
8547
+ "description": "User's picks once they've touched the picker; null = follow `visibleColumns`/all."
8548
+ },
8549
+ {
8550
+ "kind": "field",
8551
+ "name": "onDocMousedown",
8552
+ "privacy": "private",
8553
+ "readonly": true
8554
+ },
8555
+ {
8556
+ "kind": "field",
8557
+ "name": "allColumnKeys",
8558
+ "type": {
8559
+ "text": "string[]"
8560
+ },
8561
+ "privacy": "private",
8562
+ "readonly": true
8563
+ },
8520
8564
  {
8521
8565
  "kind": "field",
8522
8566
  "name": "columnKeys",
@@ -8526,6 +8570,34 @@
8526
8570
  "privacy": "private",
8527
8571
  "readonly": true
8528
8572
  },
8573
+ {
8574
+ "kind": "method",
8575
+ "name": "togglePicker",
8576
+ "privacy": "private",
8577
+ "return": {
8578
+ "type": {
8579
+ "text": "void"
8580
+ }
8581
+ }
8582
+ },
8583
+ {
8584
+ "kind": "method",
8585
+ "name": "toggleColumn",
8586
+ "privacy": "private",
8587
+ "return": {
8588
+ "type": {
8589
+ "text": "void"
8590
+ }
8591
+ },
8592
+ "parameters": [
8593
+ {
8594
+ "name": "key",
8595
+ "type": {
8596
+ "text": "string"
8597
+ }
8598
+ }
8599
+ ]
8600
+ },
8529
8601
  {
8530
8602
  "kind": "method",
8531
8603
  "name": "labelFor",
@@ -8609,9 +8681,25 @@
8609
8681
  }
8610
8682
  }
8611
8683
  ]
8684
+ },
8685
+ {
8686
+ "kind": "method",
8687
+ "name": "renderColumnPicker",
8688
+ "privacy": "private",
8689
+ "return": {
8690
+ "type": {
8691
+ "text": "TemplateResult"
8692
+ }
8693
+ }
8612
8694
  }
8613
8695
  ],
8614
8696
  "events": [
8697
+ {
8698
+ "name": "baht-columns-change",
8699
+ "type": {
8700
+ "text": "CustomEvent"
8701
+ }
8702
+ },
8615
8703
  {
8616
8704
  "name": "baht-row-click",
8617
8705
  "type": {
@@ -8695,6 +8783,15 @@
8695
8783
  "description": "Rows emit baht-row-click + get hover/keyboard affordances.",
8696
8784
  "fieldName": "clickable"
8697
8785
  },
8786
+ {
8787
+ "name": "column-picker",
8788
+ "type": {
8789
+ "text": "boolean"
8790
+ },
8791
+ "default": "false",
8792
+ "description": "Built-in \"Columns\" toggle — derives its options from `columns`/rows.",
8793
+ "fieldName": "columnPicker"
8794
+ },
8698
8795
  {
8699
8796
  "name": "page",
8700
8797
  "type": {