@gzmjs/table 0.1.0

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.
@@ -0,0 +1,20 @@
1
+ import { TableColHeadTailBase } from './47-head-tail';
2
+ import * as M from '@gzmjs/mvvm';
3
+ import * as TB from './00-base';
4
+ import * as THT from './46-tht-options';
5
+ export interface TableColTailOptions extends M.ViewListModel<THT.ThtOptions, TableColHeadTailBase<THT.ThtOptions>, TableColTail> {
6
+ tagName?: typeof TB.tableColTailTagName;
7
+ }
8
+ export declare class TableColTail extends M.ViewListElement<THT.ThtOptions, TableColHeadTailBase<THT.ThtOptions>, TableColTailOptions> implements THT.TableHeadTailBridge {
9
+ [M.handleModelEvent](source: unknown, evt: M.ModelEvent): boolean;
10
+ protected _getViewItemTagName(options: THT.ThtOptions): string;
11
+ get $list(): Element & THT.TableHeadTailNoticeReceiver | null;
12
+ notifyHide($child: THT.TableColHeadOrTail): void;
13
+ notifyConnected($child: THT.TableColHeadOrTail): void;
14
+ notifyDisconnected($child: THT.TableColHeadOrTail): void;
15
+ }
16
+ declare global {
17
+ interface HTMLElementTagNameMap {
18
+ [TB.tableColTailTagName]: TableColTail;
19
+ }
20
+ }
@@ -0,0 +1,89 @@
1
+ import { TableRow } from './16-row';
2
+ import * as B from '@gzmjs/ui-basic';
3
+ import * as M from '@gzmjs/mvvm';
4
+ import * as TB from './00-base';
5
+ import * as THT from './47-head-tail';
6
+ export interface TableColCheckOptions extends M.ViewModel<TableColCheckbox> {
7
+ readonly tagName: typeof TB.tableColCheckTagName;
8
+ rowsCheckChanged?: (checked: boolean) => void;
9
+ rowCheckChanged?: ($row: TableRow, checked: boolean) => void;
10
+ }
11
+ declare const mutableAttributes: readonly ["hidden"];
12
+ export declare class TableColCheckbox extends THT.TableColHeadTailBase<TableColCheckOptions> implements B.AttributeHandlers<typeof mutableAttributes[number]> {
13
+ #private;
14
+ $chk?: HTMLInputElement;
15
+ _createUI(): void;
16
+ protected _clear(): void;
17
+ get rowTagName(): string;
18
+ get T(): {
19
+ readonly agg: string;
20
+ readonly noAgg: string;
21
+ readonly sort: string;
22
+ readonly noSort: string;
23
+ readonly autoWidth: string;
24
+ readonly minWidth: string;
25
+ readonly maxWidth: string;
26
+ readonly pxWidth: string;
27
+ readonly textWrap: string;
28
+ readonly autoWrap: string;
29
+ readonly noWrap: string;
30
+ readonly mustWrap: string;
31
+ readonly textAlign: string;
32
+ readonly startAlign: string;
33
+ readonly endAlign: string;
34
+ readonly centerAlign: string;
35
+ readonly justifyAlign: string;
36
+ readonly COUNT: string;
37
+ readonly MAX: string;
38
+ readonly MIN: string;
39
+ readonly AVG: string;
40
+ readonly SUM: string;
41
+ readonly STDDEV_POP: string;
42
+ readonly STDDEV_SAMP: string;
43
+ readonly VAR_POP: string;
44
+ readonly VAR_SAMP: string;
45
+ readonly toggleCheck: string;
46
+ } & {
47
+ readonly close: string;
48
+ readonly true: string;
49
+ readonly false: string;
50
+ readonly undefined: string;
51
+ readonly default: string;
52
+ readonly valueMissing: string;
53
+ readonly count: string;
54
+ readonly min: string;
55
+ readonly max: string;
56
+ readonly sum: string;
57
+ readonly avg: string;
58
+ readonly hide: string;
59
+ readonly del: string;
60
+ readonly asc: string;
61
+ readonly desc: string;
62
+ readonly ok: string;
63
+ readonly cancel: string;
64
+ readonly waiting: string;
65
+ readonly confirming: (...args: unknown[]) => string;
66
+ readonly completed: string;
67
+ readonly error: string;
68
+ readonly attention: string;
69
+ readonly noMenuSet: string;
70
+ readonly readonly: string;
71
+ } & {
72
+ bindHtmlElement: <P>(this: P, $ele: HTMLElement) => P;
73
+ };
74
+ }
75
+ /**
76
+ * 由 grid-col-check 为每一行生成
77
+ */
78
+ export declare class TableRowCheckbox extends HTMLElement {
79
+ constructor();
80
+ readonly $chk: HTMLInputElement;
81
+ connectedCallback(): void;
82
+ }
83
+ declare global {
84
+ interface HTMLElementTagNameMap {
85
+ [TB.tableColCheckTagName]: TableColCheckbox;
86
+ [TB.tableRowCheckTagName]: TableRowCheckbox;
87
+ }
88
+ }
89
+ export {};
@@ -0,0 +1,20 @@
1
+ import * as B from '@gzmjs/ui-basic';
2
+ import * as M from '@gzmjs/mvvm';
3
+ import * as TB from './00-base';
4
+ import * as THT from './47-head-tail';
5
+ export interface TableColSerialNoOptions extends M.ViewModel<TableColSerialNo> {
6
+ readonly tagName: typeof TB.tableColSerialTagName;
7
+ }
8
+ declare const mutableAttributes: readonly ["hidden"];
9
+ /**
10
+ * 列头显示行号,意义不大,因为宽度必须固定,当行数太大的时候会显示不下!
11
+ */
12
+ declare class TableColSerialNo extends THT.TableColHeadTailBase<TableColSerialNoOptions> implements B.AttributeHandlers<typeof mutableAttributes[number]> {
13
+ get rowTagName(): string;
14
+ _createUI(): void;
15
+ get width(): string;
16
+ }
17
+ export {};
18
+ /**
19
+ * 没有任何功能,就不用定义一个类了
20
+ */
@@ -0,0 +1,53 @@
1
+ import { TableList } from './60-list';
2
+ import { TableRow } from './16-row';
3
+ import * as B from '@gzmjs/ui-basic';
4
+ import * as M from '@gzmjs/mvvm';
5
+ import * as TB from './00-base';
6
+ import * as THT from './47-head-tail';
7
+ export interface TableColActionOptions extends M.ViewModel<TableColAction> {
8
+ readonly tagName: typeof TB.tableColActionTagName;
9
+ label?: string;
10
+ actions: Record<string, (ctx: {
11
+ $row: TableRow;
12
+ $rowAction: TableRowAction;
13
+ $btn: HTMLButtonElement;
14
+ }) => void>;
15
+ rowActionConfig?: ($row: TableRow, $rowAction: TableRowAction, btns: Record<string, HTMLButtonElement>) => void;
16
+ }
17
+ declare const mutableAttributes: readonly ["hidden"];
18
+ /**
19
+ * 按钮操作列
20
+ */
21
+ declare class TableColAction extends THT.TableColHeadTailBase<TableColActionOptions> implements B.AttributeHandlers<typeof mutableAttributes[number]> {
22
+ get rowTagName(): string;
23
+ createInRow(): HTMLElement;
24
+ refresh($row: TableRow, $headOrTail?: HTMLElement | null): void;
25
+ get width(): string;
26
+ get dataAware(): boolean;
27
+ actions?: Record<string, (ctx: {
28
+ $row: TableRow;
29
+ $rowAction: TableRowAction;
30
+ $btn: HTMLButtonElement;
31
+ }) => void>;
32
+ get label(): string;
33
+ set label(v: string);
34
+ }
35
+ declare global {
36
+ interface HTMLElementTagNameMap {
37
+ [TB.tableColActionTagName]: TableColAction;
38
+ }
39
+ }
40
+ /**
41
+ * 由 grid-col-action 为每一行生成
42
+ */
43
+ declare class TableRowAction extends HTMLElement {
44
+ /**
45
+ * 为了在 GridColAction.refresh() 中触发事件用,从功能上来说没有必要定义这个属性,可以临时生成 btns 对象。
46
+ * 但是在触发事件时读取 button.innerText,导致在 _createRowsFromDataSource() 中调用时回流。
47
+ * 因为按钮刚刚生成还未绘制,读取 innerText 就会回流,所以要避免读取 innerText。
48
+ * 于是就在这里定义了这个属性。
49
+ */
50
+ readonly btns: Record<string, HTMLButtonElement>;
51
+ handleClick(e: MouseEvent, $list: TableList): void;
52
+ }
53
+ export {};
@@ -0,0 +1,27 @@
1
+ import { TableList } from './60-list';
2
+ import { TableRow } from './16-row';
3
+ import * as B from '@gzmjs/ui-basic';
4
+ import * as M from '@gzmjs/mvvm';
5
+ import * as TB from './00-base';
6
+ import * as THT from './47-head-tail';
7
+ export interface TableColMenuOptions extends M.ViewModel<TableColMenu> {
8
+ readonly tagName: typeof TB.tableColMenuTagName;
9
+ rowMenuClick?: ($row: TableRow, $ht: TableRowMenu, $btn: HTMLElement) => void;
10
+ }
11
+ declare const mutableAttributes: readonly ["hidden"];
12
+ /**
13
+ * 在每一行显示一个菜单按钮,点击后弹出菜单
14
+ */
15
+ declare class TableColMenu extends THT.TableColHeadTailBase<TableColMenuOptions> implements B.AttributeHandlers<typeof mutableAttributes[number]> {
16
+ get rowTagName(): string;
17
+ createInRow(): HTMLElement;
18
+ }
19
+ declare global {
20
+ interface HTMLElementTagNameMap {
21
+ [TB.tableColMenuTagName]: TableColMenu;
22
+ }
23
+ }
24
+ declare class TableRowMenu extends HTMLElement {
25
+ handleClick(e: MouseEvent, $list: TableList): void;
26
+ }
27
+ export {};
@@ -0,0 +1,41 @@
1
+ import { TableCol, NoticeOfCol } from './20-col';
2
+ import { TableCell } from './10-cell';
3
+ import { Snapshot } from './35-snapshot';
4
+ import { TableRow } from './16-row';
5
+ import { TableView } from './62-table';
6
+ import { NoticeOfColGroup } from './22-colgroup';
7
+ import { NoticeOfHead, NoticeOfTail } from './46-tht-options';
8
+ import * as TB from './00-base';
9
+ export declare class TableList extends HTMLElement {
10
+ #private;
11
+ readonly $colStart: HTMLElement;
12
+ readonly $colMiddle: HTMLElement;
13
+ readonly $colEnd: HTMLElement;
14
+ readonly $colHead: import('./48-col-head').TableColHead;
15
+ readonly $colTail: import('./48-col-tail').TableColTail;
16
+ readonly $colStartCols: import('./25-cols').TableCols;
17
+ readonly $colMiddleCols: import('./25-cols').TableCols;
18
+ readonly $colEndCols: import('./25-cols').TableCols;
19
+ readonly $rows: import('./17-rows').TableRows;
20
+ readonly $aggs: import('./18-aggs').TableAggs;
21
+ initLayout(): void;
22
+ createSnapshot(): Snapshot;
23
+ getCellsByColKey(colKey: string): TableCell[];
24
+ get $table(): TableView;
25
+ sortRows(ss?: Snapshot): void;
26
+ _calcAgg($col: TableCol): void;
27
+ showAggs(b: boolean): void;
28
+ refreshAggs(ss?: Snapshot): void;
29
+ notify(n: NoticeOfCol | NoticeOfColGroup | NoticeOfHead | NoticeOfTail): void;
30
+ refreshAll(): void;
31
+ get colLayoutPaused(): boolean;
32
+ set colLayoutPaused(b: boolean);
33
+ _setColumnsTemplate(ss?: Snapshot): void;
34
+ _layoutColumnGroup(ss?: Snapshot): void;
35
+ getRowRefreshFunc(ss?: Snapshot): ($row: TableRow, refreshCellData?: boolean) => void;
36
+ }
37
+ declare global {
38
+ interface HTMLElementTagNameMap {
39
+ [TB.tableListTagName]: TableList;
40
+ }
41
+ }
@@ -0,0 +1,175 @@
1
+ import { TableList } from './60-list';
2
+ import { ThtOptions } from './46-tht-options';
3
+ import { TableCol, TableColOptions } from './20-col';
4
+ import { TableRow } from './16-row';
5
+ import * as B from '@gzmjs/ui-basic';
6
+ import * as M from '@gzmjs/mvvm';
7
+ import * as TB from './00-base';
8
+ export interface TableViewOptions extends M.ViewModel<TableView> {
9
+ /**
10
+ * 多行 active
11
+ */
12
+ multiple?: boolean;
13
+ /**
14
+ * 允许多个字段排序
15
+ */
16
+ multiSort?: boolean;
17
+ /**
18
+ * 自动根据表格中的内容排序
19
+ */
20
+ autoSort?: boolean;
21
+ /**
22
+ * !autoSort,此函数才会被调用
23
+ * @param $columnsWantSort 需要排序的字段
24
+ * @returns
25
+ */
26
+ columnSort?: ($columnsWantSort: TableCol[]) => void;
27
+ /**
28
+ * 自动根据表格中的内容聚合
29
+ */
30
+ autoAgg?: boolean;
31
+ /**
32
+ * !autoAgg,此函数才会被调用
33
+ * @param $col 要聚合的列
34
+ * @returns
35
+ */
36
+ columnAgg?: ($col: TableCol) => void;
37
+ heads?: ThtOptions[];
38
+ tails?: ThtOptions[];
39
+ colsStart?: TableColOptions[];
40
+ colsMiddle?: TableColOptions[];
41
+ colsEnd?: TableColOptions[];
42
+ /**
43
+ * 这个属性放在最后,确保所有的列都先生成。
44
+ */
45
+ dataSource?: object[];
46
+ }
47
+ declare const mutableAttributes: readonly ["multiple", "auto-sort", "auto-agg"];
48
+ export declare class TableView extends M.ViewElement<TableViewOptions> implements B.AttributeHandlers<typeof mutableAttributes[number]> {
49
+ #private;
50
+ constructor();
51
+ readonly shadowRoot: ShadowRoot;
52
+ readonly $list: TableList;
53
+ /**
54
+ * 设置 model 会导致此函数被调用来设置各个属性,所以需要控制 colLayoutPaused;
55
+ */
56
+ [M.handleModelEvent](source: unknown, evt: M.ModelEvent): boolean;
57
+ get heads(): ThtOptions[];
58
+ set heads(v: ThtOptions[]);
59
+ get tails(): ThtOptions[];
60
+ set tails(v: ThtOptions[]);
61
+ get colsStart(): TableColOptions[];
62
+ set colsStart(v: TableColOptions[]);
63
+ get colsMiddle(): TableColOptions[];
64
+ set colsMiddle(v: TableColOptions[]);
65
+ get colsEnd(): TableColOptions[];
66
+ set colsEnd(v: TableColOptions[]);
67
+ get dataSource(): object[] | undefined;
68
+ set dataSource(ds: object[] | undefined);
69
+ /**
70
+ * @returns 选中的行的数据
71
+ */
72
+ getActiveModels(): (import('./16-row').TableRowOptions | undefined)[];
73
+ getActiveRows(): TableRow[];
74
+ getCheckedRows(): TableRow[];
75
+ getCheckedModels(): (import('./16-row').TableRowOptions | undefined)[];
76
+ accessor multiple: boolean;
77
+ _multiple_set(): void;
78
+ accessor multiSort: boolean;
79
+ accessor autoSort: boolean;
80
+ _auto_sort_set(): void;
81
+ accessor autoAgg: boolean;
82
+ _auto_agg_set(): void;
83
+ count(...args: unknown[]): number;
84
+ sum(...args: number[]): number | undefined;
85
+ avg(...args: number[]): number | undefined;
86
+ min(...args: unknown[]): unknown;
87
+ max(...args: unknown[]): unknown;
88
+ readonly T: ({
89
+ readonly agg: string;
90
+ readonly noAgg: string;
91
+ readonly sort: string;
92
+ readonly noSort: string;
93
+ readonly autoWidth: string;
94
+ readonly minWidth: string;
95
+ readonly maxWidth: string;
96
+ readonly pxWidth: string;
97
+ readonly textWrap: string;
98
+ readonly autoWrap: string;
99
+ readonly noWrap: string;
100
+ readonly mustWrap: string;
101
+ readonly textAlign: string;
102
+ readonly startAlign: string;
103
+ readonly endAlign: string;
104
+ readonly centerAlign: string;
105
+ readonly justifyAlign: string;
106
+ readonly COUNT: string;
107
+ readonly MAX: string;
108
+ readonly MIN: string;
109
+ readonly AVG: string;
110
+ readonly SUM: string;
111
+ readonly STDDEV_POP: string;
112
+ readonly STDDEV_SAMP: string;
113
+ readonly VAR_POP: string;
114
+ readonly VAR_SAMP: string;
115
+ readonly toggleCheck: string;
116
+ } & ({
117
+ readonly close: string;
118
+ readonly true: string;
119
+ readonly false: string;
120
+ readonly undefined: string;
121
+ readonly default: string;
122
+ readonly valueMissing: string;
123
+ readonly count: string;
124
+ readonly min: string;
125
+ readonly max: string;
126
+ readonly sum: string;
127
+ readonly avg: string;
128
+ readonly hide: string;
129
+ readonly del: string;
130
+ readonly asc: string;
131
+ readonly desc: string;
132
+ readonly ok: string;
133
+ readonly cancel: string;
134
+ readonly waiting: string;
135
+ readonly confirming: (...args: unknown[]) => string;
136
+ readonly completed: string;
137
+ readonly error: string;
138
+ readonly attention: string;
139
+ readonly noMenuSet: string;
140
+ readonly readonly: string;
141
+ } | {
142
+ readonly close: string;
143
+ readonly true: string;
144
+ readonly false: string;
145
+ readonly undefined: string;
146
+ readonly default: string;
147
+ readonly valueMissing: string;
148
+ readonly count: string;
149
+ readonly min: string;
150
+ readonly max: string;
151
+ readonly sum: string;
152
+ readonly avg: string;
153
+ readonly hide: string;
154
+ readonly del: string;
155
+ readonly asc: string;
156
+ readonly desc: string;
157
+ readonly ok: string;
158
+ readonly cancel: string;
159
+ readonly waiting: string;
160
+ readonly confirming: (...args: unknown[]) => string;
161
+ readonly completed: string;
162
+ readonly error: string;
163
+ readonly attention: string;
164
+ readonly noMenuSet: string;
165
+ readonly readonly: string;
166
+ })) & {
167
+ bindHtmlElement: <P>(this: P, $ele: HTMLElement) => P;
168
+ };
169
+ }
170
+ declare global {
171
+ interface HTMLElementTagNameMap {
172
+ [TB.tableViewTagName]: TableView;
173
+ }
174
+ }
175
+ export {};
@@ -0,0 +1,10 @@
1
+ export { tableViewTagName, tableColCheckTagName, tableColSerialTagName, tableColActionTagName, tableColMenuTagName } from './055-table/00-base';
2
+ export { type TableRowOptions, TableRow } from './055-table/16-row';
3
+ export { type TableColOptions, TableCol, sortAsc, sortDesc, type TableColSort, type TableColAlign, type TableColAggs } from './055-table/20-col';
4
+ export { Snapshot } from './055-table/35-snapshot';
5
+ export { type ThtOptions } from './055-table/46-tht-options';
6
+ export { type TableColCheckOptions } from './055-table/51-check';
7
+ export { type TableColSerialNoOptions } from './055-table/52-serial';
8
+ export { type TableColActionOptions } from './055-table/53-action';
9
+ export { type TableColMenuOptions } from './055-table/54-menu';
10
+ export { type TableViewOptions, TableView } from './055-table/62-table';