bank20baht-ui 0.1.5 → 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.
@@ -20,6 +20,17 @@ export type CellRenderer = (value: unknown, row: Record<string, unknown>) => unk
20
20
  *
21
21
  * t.cursorMode = true; t.hasNext = true; t.hasPrev = false;
22
22
  * t.addEventListener('baht-cursor-change', (e) => fetchPage(e.detail.direction));
23
+ *
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:
27
+ *
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.
23
34
  */
24
35
  export declare class BahtTable extends BahtElement {
25
36
  /** Rows of the CURRENT page. */
@@ -40,16 +51,29 @@ export declare class BahtTable extends BahtElement {
40
51
  clickable: boolean;
41
52
  /** Custom cell renderers by column key (functions — a property, never JSON). */
42
53
  renderers: Record<string, CellRenderer>;
54
+ /** Subset + order of `columns` to render; empty/omitted = show all. */
55
+ visibleColumns: string[];
56
+ /** Built-in "Columns" toggle — derives its options from `columns`/rows. */
57
+ columnPicker: boolean;
43
58
  page: number;
44
59
  totalPages: number;
45
60
  /** Switch the footer to Prev/Next (cursor-based API, no total count). */
46
61
  cursorMode: boolean;
47
62
  hasNext: boolean;
48
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();
49
70
  private get columnKeys();
71
+ private togglePicker;
72
+ private toggleColumn;
50
73
  private labelFor;
51
74
  private emitRow;
52
75
  private cell;
53
76
  private renderBody;
77
+ private renderColumnPicker;
54
78
  protected render(): TemplateResult;
55
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));",
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
  {
@@ -8462,6 +8462,25 @@
8462
8462
  "default": "{}",
8463
8463
  "description": "Custom cell renderers by column key (functions — a property, never JSON)."
8464
8464
  },
8465
+ {
8466
+ "kind": "field",
8467
+ "name": "visibleColumns",
8468
+ "type": {
8469
+ "text": "string[]"
8470
+ },
8471
+ "default": "[]",
8472
+ "description": "Subset + order of `columns` to render; empty/omitted = show all."
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
+ },
8465
8484
  {
8466
8485
  "kind": "field",
8467
8486
  "name": "page",
@@ -8508,6 +8527,40 @@
8508
8527
  "default": "false",
8509
8528
  "attribute": "has-prev"
8510
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
+ },
8511
8564
  {
8512
8565
  "kind": "field",
8513
8566
  "name": "columnKeys",
@@ -8517,6 +8570,34 @@
8517
8570
  "privacy": "private",
8518
8571
  "readonly": true
8519
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
+ },
8520
8601
  {
8521
8602
  "kind": "method",
8522
8603
  "name": "labelFor",
@@ -8600,9 +8681,25 @@
8600
8681
  }
8601
8682
  }
8602
8683
  ]
8684
+ },
8685
+ {
8686
+ "kind": "method",
8687
+ "name": "renderColumnPicker",
8688
+ "privacy": "private",
8689
+ "return": {
8690
+ "type": {
8691
+ "text": "TemplateResult"
8692
+ }
8693
+ }
8603
8694
  }
8604
8695
  ],
8605
8696
  "events": [
8697
+ {
8698
+ "name": "baht-columns-change",
8699
+ "type": {
8700
+ "text": "CustomEvent"
8701
+ }
8702
+ },
8606
8703
  {
8607
8704
  "name": "baht-row-click",
8608
8705
  "type": {
@@ -8686,6 +8783,15 @@
8686
8783
  "description": "Rows emit baht-row-click + get hover/keyboard affordances.",
8687
8784
  "fieldName": "clickable"
8688
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
+ },
8689
8795
  {
8690
8796
  "name": "page",
8691
8797
  "type": {