bank20baht-ui 0.1.4 → 0.1.6
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.
- package/dist/components/primitives/baht-pagination.d.ts +12 -2
- package/dist/components/primitives/baht-table.d.ts +20 -0
- package/dist/custom-elements.json +128 -6
- package/dist/index.js +573 -535
- package/dist/react.d.ts +7 -1
- package/dist/vscode.html-custom-data.json +23 -6
- package/dist/web-types.json +57 -11
- package/package.json +1 -1
|
@@ -6,15 +6,25 @@ import { BahtElement } from '../base.js';
|
|
|
6
6
|
*
|
|
7
7
|
* <baht-pagination page="4" total-pages="20"></baht-pagination>
|
|
8
8
|
* <baht-pagination variant="compact" page="1" total-pages="3"></baht-pagination>
|
|
9
|
+
*
|
|
10
|
+
* `variant="cursor"` drops page numbers entirely — the host doesn't know a
|
|
11
|
+
* total, only whether another page exists in either direction:
|
|
12
|
+
*
|
|
13
|
+
* <baht-pagination variant="cursor" has-next has-prev></baht-pagination>
|
|
14
|
+
* el.addEventListener('baht-cursor-change', (e) => fetchPage(e.detail.direction));
|
|
9
15
|
*/
|
|
10
16
|
export declare class BahtPagination extends BahtElement {
|
|
11
17
|
page: number;
|
|
12
18
|
totalPages: number;
|
|
13
|
-
/** 'numbered' = 1 … 4 5 6 … 20 · 'compact' = « Page 4 of 20 » */
|
|
14
|
-
variant: 'numbered' | 'compact';
|
|
19
|
+
/** 'numbered' = 1 … 4 5 6 … 20 · 'compact' = « Page 4 of 20 · 'cursor' = « Prev / Next » */
|
|
20
|
+
variant: 'numbered' | 'compact' | 'cursor';
|
|
15
21
|
/** Numbered pages shown on each side of the current page. */
|
|
16
22
|
siblings: number;
|
|
23
|
+
/** cursor variant only — whether a next/previous page is available. */
|
|
24
|
+
hasNext: boolean;
|
|
25
|
+
hasPrev: boolean;
|
|
17
26
|
private go;
|
|
27
|
+
private goCursor;
|
|
18
28
|
/** Visible page numbers with `null` marking an ellipsis gap. */
|
|
19
29
|
private get pageItems();
|
|
20
30
|
protected render(): TemplateResult;
|
|
@@ -13,6 +13,20 @@ export type CellRenderer = (value: unknown, row: Record<string, unknown>) => unk
|
|
|
13
13
|
* t.loading = false; t.page = 1; t.totalPages = 12;
|
|
14
14
|
* t.addEventListener('baht-page-change', (e) => fetchPage(e.detail.page));
|
|
15
15
|
* t.addEventListener('baht-row-click', (e) => open(e.detail.id));
|
|
16
|
+
*
|
|
17
|
+
* Set `cursor-mode` for cursor-based APIs (no total count) — the footer
|
|
18
|
+
* becomes a Prev/Next pair gated by `has-next`/`has-prev`, and the host
|
|
19
|
+
* listens for `baht-cursor-change` instead of `baht-page-change`:
|
|
20
|
+
*
|
|
21
|
+
* t.cursorMode = true; t.hasNext = true; t.hasPrev = false;
|
|
22
|
+
* t.addEventListener('baht-cursor-change', (e) => fetchPage(e.detail.direction));
|
|
23
|
+
*
|
|
24
|
+
* `visibleColumns` picks + orders a subset of `columns` client-side (no
|
|
25
|
+
* refetch) — pair it with <baht-multiselect> as the chooser UI:
|
|
26
|
+
*
|
|
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);
|
|
16
30
|
*/
|
|
17
31
|
export declare class BahtTable extends BahtElement {
|
|
18
32
|
/** Rows of the CURRENT page. */
|
|
@@ -33,8 +47,14 @@ export declare class BahtTable extends BahtElement {
|
|
|
33
47
|
clickable: boolean;
|
|
34
48
|
/** Custom cell renderers by column key (functions — a property, never JSON). */
|
|
35
49
|
renderers: Record<string, CellRenderer>;
|
|
50
|
+
/** Subset + order of `columns` to render; empty/omitted = show all. */
|
|
51
|
+
visibleColumns: string[];
|
|
36
52
|
page: number;
|
|
37
53
|
totalPages: number;
|
|
54
|
+
/** Switch the footer to Prev/Next (cursor-based API, no total count). */
|
|
55
|
+
cursorMode: boolean;
|
|
56
|
+
hasNext: boolean;
|
|
57
|
+
hasPrev: boolean;
|
|
38
58
|
private get columnKeys();
|
|
39
59
|
private labelFor;
|
|
40
60
|
private emitRow;
|
|
@@ -5731,7 +5731,7 @@
|
|
|
5731
5731
|
"declarations": [
|
|
5732
5732
|
{
|
|
5733
5733
|
"kind": "class",
|
|
5734
|
-
"description": "Server-side pagination control: it never slices data — it only reports the\npage the user asked for via `baht-page-change`; the host fetches that page.\n\n <baht-pagination page=\"4\" total-pages=\"20\"></baht-pagination>\n <baht-pagination variant=\"compact\" page=\"1\" total-pages=\"3\"></baht-pagination
|
|
5734
|
+
"description": "Server-side pagination control: it never slices data — it only reports the\npage the user asked for via `baht-page-change`; the host fetches that page.\n\n <baht-pagination page=\"4\" total-pages=\"20\"></baht-pagination>\n <baht-pagination variant=\"compact\" page=\"1\" total-pages=\"3\"></baht-pagination>\n\n`variant=\"cursor\"` drops page numbers entirely — the host doesn't know a\ntotal, only whether another page exists in either direction:\n\n <baht-pagination variant=\"cursor\" has-next has-prev></baht-pagination>\n el.addEventListener('baht-cursor-change', (e) => fetchPage(e.detail.direction));",
|
|
5735
5735
|
"name": "BahtPagination",
|
|
5736
5736
|
"members": [
|
|
5737
5737
|
{
|
|
@@ -5756,10 +5756,10 @@
|
|
|
5756
5756
|
"kind": "field",
|
|
5757
5757
|
"name": "variant",
|
|
5758
5758
|
"type": {
|
|
5759
|
-
"text": "'numbered' | 'compact'"
|
|
5759
|
+
"text": "'numbered' | 'compact' | 'cursor'"
|
|
5760
5760
|
},
|
|
5761
5761
|
"default": "'numbered'",
|
|
5762
|
-
"description": "'numbered' = 1 … 4 5 6 … 20 · 'compact' = « Page 4 of 20 »",
|
|
5762
|
+
"description": "'numbered' = 1 … 4 5 6 … 20 · 'compact' = « Page 4 of 20 · 'cursor' = « Prev / Next »",
|
|
5763
5763
|
"attribute": "variant"
|
|
5764
5764
|
},
|
|
5765
5765
|
{
|
|
@@ -5772,6 +5772,25 @@
|
|
|
5772
5772
|
"description": "Numbered pages shown on each side of the current page.",
|
|
5773
5773
|
"attribute": "siblings"
|
|
5774
5774
|
},
|
|
5775
|
+
{
|
|
5776
|
+
"kind": "field",
|
|
5777
|
+
"name": "hasNext",
|
|
5778
|
+
"type": {
|
|
5779
|
+
"text": "boolean"
|
|
5780
|
+
},
|
|
5781
|
+
"default": "false",
|
|
5782
|
+
"description": "cursor variant only — whether a next/previous page is available.",
|
|
5783
|
+
"attribute": "has-next"
|
|
5784
|
+
},
|
|
5785
|
+
{
|
|
5786
|
+
"kind": "field",
|
|
5787
|
+
"name": "hasPrev",
|
|
5788
|
+
"type": {
|
|
5789
|
+
"text": "boolean"
|
|
5790
|
+
},
|
|
5791
|
+
"default": "false",
|
|
5792
|
+
"attribute": "has-prev"
|
|
5793
|
+
},
|
|
5775
5794
|
{
|
|
5776
5795
|
"kind": "method",
|
|
5777
5796
|
"name": "go",
|
|
@@ -5790,6 +5809,24 @@
|
|
|
5790
5809
|
}
|
|
5791
5810
|
]
|
|
5792
5811
|
},
|
|
5812
|
+
{
|
|
5813
|
+
"kind": "method",
|
|
5814
|
+
"name": "goCursor",
|
|
5815
|
+
"privacy": "private",
|
|
5816
|
+
"return": {
|
|
5817
|
+
"type": {
|
|
5818
|
+
"text": "void"
|
|
5819
|
+
}
|
|
5820
|
+
},
|
|
5821
|
+
"parameters": [
|
|
5822
|
+
{
|
|
5823
|
+
"name": "direction",
|
|
5824
|
+
"type": {
|
|
5825
|
+
"text": "'next' | 'prev'"
|
|
5826
|
+
}
|
|
5827
|
+
}
|
|
5828
|
+
]
|
|
5829
|
+
},
|
|
5793
5830
|
{
|
|
5794
5831
|
"kind": "field",
|
|
5795
5832
|
"name": "pageItems",
|
|
@@ -5807,6 +5844,12 @@
|
|
|
5807
5844
|
"type": {
|
|
5808
5845
|
"text": "CustomEvent"
|
|
5809
5846
|
}
|
|
5847
|
+
},
|
|
5848
|
+
{
|
|
5849
|
+
"name": "baht-cursor-change",
|
|
5850
|
+
"type": {
|
|
5851
|
+
"text": "CustomEvent"
|
|
5852
|
+
}
|
|
5810
5853
|
}
|
|
5811
5854
|
],
|
|
5812
5855
|
"attributes": [
|
|
@@ -5829,10 +5872,10 @@
|
|
|
5829
5872
|
{
|
|
5830
5873
|
"name": "variant",
|
|
5831
5874
|
"type": {
|
|
5832
|
-
"text": "'numbered' | 'compact'"
|
|
5875
|
+
"text": "'numbered' | 'compact' | 'cursor'"
|
|
5833
5876
|
},
|
|
5834
5877
|
"default": "'numbered'",
|
|
5835
|
-
"description": "'numbered' = 1 … 4 5 6 … 20 · 'compact' = « Page 4 of 20 »",
|
|
5878
|
+
"description": "'numbered' = 1 … 4 5 6 … 20 · 'compact' = « Page 4 of 20 · 'cursor' = « Prev / Next »",
|
|
5836
5879
|
"fieldName": "variant"
|
|
5837
5880
|
},
|
|
5838
5881
|
{
|
|
@@ -5843,6 +5886,23 @@
|
|
|
5843
5886
|
"default": "1",
|
|
5844
5887
|
"description": "Numbered pages shown on each side of the current page.",
|
|
5845
5888
|
"fieldName": "siblings"
|
|
5889
|
+
},
|
|
5890
|
+
{
|
|
5891
|
+
"name": "has-next",
|
|
5892
|
+
"type": {
|
|
5893
|
+
"text": "boolean"
|
|
5894
|
+
},
|
|
5895
|
+
"default": "false",
|
|
5896
|
+
"description": "cursor variant only — whether a next/previous page is available.",
|
|
5897
|
+
"fieldName": "hasNext"
|
|
5898
|
+
},
|
|
5899
|
+
{
|
|
5900
|
+
"name": "has-prev",
|
|
5901
|
+
"type": {
|
|
5902
|
+
"text": "boolean"
|
|
5903
|
+
},
|
|
5904
|
+
"default": "false",
|
|
5905
|
+
"fieldName": "hasPrev"
|
|
5846
5906
|
}
|
|
5847
5907
|
],
|
|
5848
5908
|
"superclass": {
|
|
@@ -8288,7 +8348,7 @@
|
|
|
8288
8348
|
"declarations": [
|
|
8289
8349
|
{
|
|
8290
8350
|
"kind": "class",
|
|
8291
|
-
"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));",
|
|
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);",
|
|
8292
8352
|
"name": "BahtTable",
|
|
8293
8353
|
"members": [
|
|
8294
8354
|
{
|
|
@@ -8402,6 +8462,15 @@
|
|
|
8402
8462
|
"default": "{}",
|
|
8403
8463
|
"description": "Custom cell renderers by column key (functions — a property, never JSON)."
|
|
8404
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
|
+
},
|
|
8405
8474
|
{
|
|
8406
8475
|
"kind": "field",
|
|
8407
8476
|
"name": "page",
|
|
@@ -8420,6 +8489,34 @@
|
|
|
8420
8489
|
"default": "1",
|
|
8421
8490
|
"attribute": "total-pages"
|
|
8422
8491
|
},
|
|
8492
|
+
{
|
|
8493
|
+
"kind": "field",
|
|
8494
|
+
"name": "cursorMode",
|
|
8495
|
+
"type": {
|
|
8496
|
+
"text": "boolean"
|
|
8497
|
+
},
|
|
8498
|
+
"default": "false",
|
|
8499
|
+
"description": "Switch the footer to Prev/Next (cursor-based API, no total count).",
|
|
8500
|
+
"attribute": "cursor-mode"
|
|
8501
|
+
},
|
|
8502
|
+
{
|
|
8503
|
+
"kind": "field",
|
|
8504
|
+
"name": "hasNext",
|
|
8505
|
+
"type": {
|
|
8506
|
+
"text": "boolean"
|
|
8507
|
+
},
|
|
8508
|
+
"default": "false",
|
|
8509
|
+
"attribute": "has-next"
|
|
8510
|
+
},
|
|
8511
|
+
{
|
|
8512
|
+
"kind": "field",
|
|
8513
|
+
"name": "hasPrev",
|
|
8514
|
+
"type": {
|
|
8515
|
+
"text": "boolean"
|
|
8516
|
+
},
|
|
8517
|
+
"default": "false",
|
|
8518
|
+
"attribute": "has-prev"
|
|
8519
|
+
},
|
|
8423
8520
|
{
|
|
8424
8521
|
"kind": "field",
|
|
8425
8522
|
"name": "columnKeys",
|
|
@@ -8613,6 +8710,31 @@
|
|
|
8613
8710
|
},
|
|
8614
8711
|
"default": "1",
|
|
8615
8712
|
"fieldName": "totalPages"
|
|
8713
|
+
},
|
|
8714
|
+
{
|
|
8715
|
+
"name": "cursor-mode",
|
|
8716
|
+
"type": {
|
|
8717
|
+
"text": "boolean"
|
|
8718
|
+
},
|
|
8719
|
+
"default": "false",
|
|
8720
|
+
"description": "Switch the footer to Prev/Next (cursor-based API, no total count).",
|
|
8721
|
+
"fieldName": "cursorMode"
|
|
8722
|
+
},
|
|
8723
|
+
{
|
|
8724
|
+
"name": "has-next",
|
|
8725
|
+
"type": {
|
|
8726
|
+
"text": "boolean"
|
|
8727
|
+
},
|
|
8728
|
+
"default": "false",
|
|
8729
|
+
"fieldName": "hasNext"
|
|
8730
|
+
},
|
|
8731
|
+
{
|
|
8732
|
+
"name": "has-prev",
|
|
8733
|
+
"type": {
|
|
8734
|
+
"text": "boolean"
|
|
8735
|
+
},
|
|
8736
|
+
"default": "false",
|
|
8737
|
+
"fieldName": "hasPrev"
|
|
8616
8738
|
}
|
|
8617
8739
|
],
|
|
8618
8740
|
"superclass": {
|