@rotki/ui-library 0.3.0 → 0.5.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.
@@ -1,37 +1,77 @@
1
1
  import { type TablePaginationData } from './TablePagination.vue';
2
- export interface TableColumn {
3
- key: string;
4
- sortable?: boolean;
2
+ /**
3
+ * Represents a sortable column name for a given type.
4
+ * The column name must be a key of the passed data object type.
5
+ * @template T - The type of the data in the column.
6
+ */
7
+ export type SortableColumnName<T> = keyof T;
8
+ /**
9
+ * Represents the name of a column in a dataset.
10
+ *
11
+ * The `ColumnName` type can either be a `SortableColumnName` or a string.
12
+ *
13
+ * @typeparam T - The type of the dataset containing the column name.
14
+ */
15
+ export type ColumnName<T> = SortableColumnName<T> | string;
16
+ export interface BaseTableColumn {
5
17
  direction?: 'asc' | 'desc';
6
- align?: 'left' | 'right';
18
+ align?: 'start' | 'center' | 'end';
7
19
  class?: string;
20
+ cellClass?: string;
8
21
  [key: string]: any;
9
22
  }
10
- export interface SortColumn {
11
- column?: string;
23
+ /**
24
+ * Represents a sortable table column.
25
+ * This is used to ensure that when using sortable with a true value,
26
+ * the key matches to an actual property of the object passed.
27
+ *
28
+ * @template T - The type of data in the table column.
29
+ */
30
+ export interface SortableTableColumn<T> extends BaseTableColumn {
31
+ key: SortableColumnName<T>;
32
+ sortable: true;
33
+ }
34
+ /**
35
+ * An interface representing a column in a table that cannot be sorted.
36
+ * This can be mapped to an actual property of the object or to a virtual column.
37
+ *
38
+ * @typeparam T - The type of data in the table.
39
+ */
40
+ export interface NoneSortableTableColumn<T> extends BaseTableColumn {
41
+ key: string | SortableColumnName<T>;
42
+ sortable?: false;
43
+ }
44
+ export type TableColumn<T> = SortableTableColumn<T> | NoneSortableTableColumn<T>;
45
+ export interface SortColumn<T> {
46
+ column?: SortableColumnName<T>;
12
47
  direction: 'asc' | 'desc';
13
48
  }
14
- export interface TableOptions {
49
+ export interface TableOptions<T> {
15
50
  pagination?: TablePaginationData;
16
- sort?: SortColumn | SortColumn[];
51
+ sort?: SortColumn<T> | SortColumn<T>[];
17
52
  }
18
- export interface Props {
53
+ export interface Props<T, K extends keyof T> {
19
54
  /**
20
55
  * list of items for each row
21
56
  */
22
- rows: Array<Record<string, any>>;
57
+ rows: T[];
23
58
  /**
24
59
  * the attribute used to identify each row uniquely for selection, usually `id`
25
60
  */
26
- rowAttr: string;
61
+ rowAttr: K;
27
62
  /**
28
63
  * model for selected rows, add a v-model to support row selection
29
64
  */
30
- modelValue?: string[];
65
+ modelValue?: T[K][];
31
66
  /**
32
- * model for insternal searching
67
+ * model for internal searching
33
68
  */
34
69
  search?: string;
70
+ /**
71
+ * model for items per page
72
+ * will be used if the `pagination` model isn't specified
73
+ */
74
+ itemsPerPage?: number;
35
75
  /**
36
76
  * model for paginating data
37
77
  * @example v-model:pagination="{ total: 10, limit: 5, page: 1 }"
@@ -52,7 +92,7 @@ export interface Props {
52
92
  * multi columns sort
53
93
  * @example v-model:sort="[{ column: 'name', direction: 'asc' }]"
54
94
  */
55
- sort?: SortColumn | SortColumn[];
95
+ sort?: SortColumn<T> | SortColumn<T>[];
56
96
  /**
57
97
  * modifiers for specifying externally sorted tables
58
98
  * use this when api controls sorting
@@ -67,7 +107,7 @@ export interface Props {
67
107
  /**
68
108
  * list of column definitions
69
109
  */
70
- cols?: Array<TableColumn>;
110
+ cols?: TableColumn<T>[];
71
111
  /**
72
112
  * attribute to use from column definitions to display column titles
73
113
  */
@@ -94,187 +134,78 @@ export interface Props {
94
134
  label?: string;
95
135
  description?: string;
96
136
  };
137
+ /**
138
+ * should hide the footer
139
+ */
140
+ hideDefaultFooter?: boolean;
141
+ rounded?: 'sm' | 'md' | 'lg';
97
142
  }
98
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
99
- sort: {
100
- type: globalThis.PropType<SortColumn | SortColumn[]>;
101
- default: undefined;
102
- };
103
- search: {
104
- type: globalThis.PropType<string>;
105
- default: string;
106
- };
107
- outlined: {
108
- type: globalThis.PropType<boolean>;
109
- };
110
- loading: {
111
- type: globalThis.PropType<boolean>;
112
- default: boolean;
113
- };
114
- modelValue: {
115
- type: globalThis.PropType<string[]>;
116
- default: undefined;
117
- };
118
- dense: {
119
- type: globalThis.PropType<boolean>;
120
- };
121
- empty: {
122
- type: globalThis.PropType<{
123
- label?: string | undefined;
124
- description?: string | undefined;
125
- }>;
126
- default: () => {
127
- label: string;
143
+ declare const _default: <T extends object, IdType extends keyof T = keyof T>(__VLS_props: Props<T, IdType> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, __VLS_ctx?: Pick<{
144
+ props: Props<T, IdType>;
145
+ expose(exposed: {}): void;
146
+ attrs: any;
147
+ slots: Partial<Record<string, (_: {
148
+ column: TableColumn<T>;
149
+ }) => any>> & Partial<Record<string, (_: {
150
+ column: TableColumn<T>;
151
+ row: T;
152
+ index: number;
153
+ }) => any>> & {
154
+ "no-data"?(_: {}): any;
155
+ "empty-description"?(_: {}): any;
156
+ tfoot?(_: {}): any;
157
+ };
158
+ emit: {
159
+ (e: 'update:model-value', value?: T[IdType][] | undefined): void;
160
+ (e: 'update:pagination', value: TablePaginationData): void;
161
+ (e: 'update:sort', value?: SortColumn<T> | SortColumn<T>[] | undefined): void;
162
+ (e: 'update:options', value: TableOptions<T>): void;
163
+ };
164
+ }, "attrs" | "slots" | "emit"> | undefined, __VLS_expose?: ((exposed: {}) => void) | undefined, __VLS_setup?: Promise<{
165
+ props: Props<T, IdType>;
166
+ expose(exposed: {}): void;
167
+ attrs: any;
168
+ slots: Partial<Record<string, (_: {
169
+ column: TableColumn<T>;
170
+ }) => any>> & Partial<Record<string, (_: {
171
+ column: TableColumn<T>;
172
+ row: T;
173
+ index: number;
174
+ }) => any>> & {
175
+ "no-data"?(_: {}): any;
176
+ "empty-description"?(_: {}): any;
177
+ tfoot?(_: {}): any;
178
+ };
179
+ emit: {
180
+ (e: 'update:model-value', value?: T[IdType][] | undefined): void;
181
+ (e: 'update:pagination', value: TablePaginationData): void;
182
+ (e: 'update:sort', value?: SortColumn<T> | SortColumn<T>[] | undefined): void;
183
+ (e: 'update:options', value: TableOptions<T>): void;
184
+ };
185
+ }>) => globalThis.VNode<import("vue").RendererNode, import("vue").RendererElement, {
186
+ [key: string]: any;
187
+ }> & {
188
+ __ctx?: {
189
+ props: Props<T, IdType>;
190
+ expose(exposed: {}): void;
191
+ attrs: any;
192
+ slots: Partial<Record<string, (_: {
193
+ column: TableColumn<T>;
194
+ }) => any>> & Partial<Record<string, (_: {
195
+ column: TableColumn<T>;
196
+ row: T;
197
+ index: number;
198
+ }) => any>> & {
199
+ "no-data"?(_: {}): any;
200
+ "empty-description"?(_: {}): any;
201
+ tfoot?(_: {}): any;
128
202
  };
129
- };
130
- rows: {
131
- type: globalThis.PropType<Record<string, any>[]>;
132
- required: true;
133
- };
134
- rowAttr: {
135
- type: globalThis.PropType<string>;
136
- required: true;
137
- };
138
- pagination: {
139
- type: globalThis.PropType<TablePaginationData>;
140
- default: undefined;
141
- };
142
- paginationModifiers: {
143
- type: globalThis.PropType<{
144
- external: boolean;
145
- }>;
146
- default: undefined;
147
- };
148
- sortModifiers: {
149
- type: globalThis.PropType<{
150
- external: boolean;
151
- }>;
152
- default: undefined;
153
- };
154
- cols: {
155
- type: globalThis.PropType<TableColumn[]>;
156
- default: undefined;
157
- };
158
- columnAttr: {
159
- type: globalThis.PropType<string>;
160
- default: string;
161
- };
162
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
163
- "update:model-value": (value?: string[] | undefined) => void;
164
- "update:pagination": (value?: TablePaginationData | undefined) => void;
165
- "update:sort": (value?: SortColumn | SortColumn[] | undefined) => void;
166
- "update:options": (value?: TableOptions | undefined) => void;
167
- }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
168
- sort: {
169
- type: globalThis.PropType<SortColumn | SortColumn[]>;
170
- default: undefined;
171
- };
172
- search: {
173
- type: globalThis.PropType<string>;
174
- default: string;
175
- };
176
- outlined: {
177
- type: globalThis.PropType<boolean>;
178
- };
179
- loading: {
180
- type: globalThis.PropType<boolean>;
181
- default: boolean;
182
- };
183
- modelValue: {
184
- type: globalThis.PropType<string[]>;
185
- default: undefined;
186
- };
187
- dense: {
188
- type: globalThis.PropType<boolean>;
189
- };
190
- empty: {
191
- type: globalThis.PropType<{
192
- label?: string | undefined;
193
- description?: string | undefined;
194
- }>;
195
- default: () => {
196
- label: string;
203
+ emit: {
204
+ (e: 'update:model-value', value?: T[IdType][] | undefined): void;
205
+ (e: 'update:pagination', value: TablePaginationData): void;
206
+ (e: 'update:sort', value?: SortColumn<T> | SortColumn<T>[] | undefined): void;
207
+ (e: 'update:options', value: TableOptions<T>): void;
197
208
  };
198
- };
199
- rows: {
200
- type: globalThis.PropType<Record<string, any>[]>;
201
- required: true;
202
- };
203
- rowAttr: {
204
- type: globalThis.PropType<string>;
205
- required: true;
206
- };
207
- pagination: {
208
- type: globalThis.PropType<TablePaginationData>;
209
- default: undefined;
210
- };
211
- paginationModifiers: {
212
- type: globalThis.PropType<{
213
- external: boolean;
214
- }>;
215
- default: undefined;
216
- };
217
- sortModifiers: {
218
- type: globalThis.PropType<{
219
- external: boolean;
220
- }>;
221
- default: undefined;
222
- };
223
- cols: {
224
- type: globalThis.PropType<TableColumn[]>;
225
- default: undefined;
226
- };
227
- columnAttr: {
228
- type: globalThis.PropType<string>;
229
- default: string;
230
- };
231
- }>> & {
232
- "onUpdate:model-value"?: ((value?: string[] | undefined) => any) | undefined;
233
- "onUpdate:pagination"?: ((value?: TablePaginationData | undefined) => any) | undefined;
234
- "onUpdate:sort"?: ((value?: SortColumn | SortColumn[] | undefined) => any) | undefined;
235
- "onUpdate:options"?: ((value?: TableOptions | undefined) => any) | undefined;
236
- }, {
237
- sort: SortColumn | SortColumn[];
238
- search: string;
239
- loading: boolean;
240
- modelValue: string[];
241
- empty: {
242
- label?: string | undefined;
243
- description?: string | undefined;
244
- };
245
- pagination: TablePaginationData;
246
- paginationModifiers: {
247
- external: boolean;
248
- };
249
- sortModifiers: {
250
- external: boolean;
251
- };
252
- cols: TableColumn[];
253
- columnAttr: string;
254
- }, {}>, Partial<Record<string, (_: {
255
- column: TableColumn | {
256
- [x: string]: string | boolean;
257
- key: string;
258
- sortable: boolean;
259
- class: string;
260
- };
261
- }) => any>> & Partial<Record<string, (_: {
262
- column: TableColumn | {
263
- [x: string]: string | boolean;
264
- key: string;
265
- sortable: boolean;
266
- class: string;
267
- };
268
- row: Record<string, any>;
269
- index: number;
270
- }) => any>> & {
271
- "no-data"?(_: {}): any;
272
- "empty-description"?(_: {}): any;
273
- tfoot?(_: {}): any;
274
- }>;
275
- export default _default;
276
- type __VLS_WithTemplateSlots<T, S> = T & {
277
- new (): {
278
- $slots: S;
279
- };
209
+ } | undefined;
280
210
  };
211
+ export default _default;
@@ -0,0 +1,137 @@
1
+ import { type ContextColorsType } from '../../../consts/colors';
2
+ export interface Props {
3
+ color?: ContextColorsType;
4
+ disabled?: boolean;
5
+ grow?: boolean;
6
+ tabValue?: number | string;
7
+ active?: boolean;
8
+ link?: boolean;
9
+ target?: string;
10
+ to?: string;
11
+ exact?: boolean;
12
+ exactPath?: boolean;
13
+ vertical?: boolean;
14
+ align?: 'start' | 'center' | 'end';
15
+ }
16
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
17
+ color: {
18
+ type: globalThis.PropType<"primary" | "secondary" | "error" | "warning" | "info" | "success">;
19
+ default: undefined;
20
+ };
21
+ link: {
22
+ type: globalThis.PropType<boolean>;
23
+ default: boolean;
24
+ };
25
+ target: {
26
+ type: globalThis.PropType<string>;
27
+ default: string;
28
+ };
29
+ to: {
30
+ type: globalThis.PropType<string>;
31
+ default: string;
32
+ };
33
+ disabled: {
34
+ type: globalThis.PropType<boolean>;
35
+ default: boolean;
36
+ };
37
+ active: {
38
+ type: globalThis.PropType<boolean>;
39
+ default: boolean;
40
+ };
41
+ vertical: {
42
+ type: globalThis.PropType<boolean>;
43
+ default: boolean;
44
+ };
45
+ align: {
46
+ type: globalThis.PropType<"end" | "center" | "start">;
47
+ default: string;
48
+ };
49
+ grow: {
50
+ type: globalThis.PropType<boolean>;
51
+ default: boolean;
52
+ };
53
+ tabValue: {
54
+ type: globalThis.PropType<string | number>;
55
+ default: string;
56
+ };
57
+ exact: {
58
+ type: globalThis.PropType<boolean>;
59
+ default: boolean;
60
+ };
61
+ exactPath: {
62
+ type: globalThis.PropType<boolean>;
63
+ default: boolean;
64
+ };
65
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
66
+ click: (tabValue: string | number) => void;
67
+ }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
68
+ color: {
69
+ type: globalThis.PropType<"primary" | "secondary" | "error" | "warning" | "info" | "success">;
70
+ default: undefined;
71
+ };
72
+ link: {
73
+ type: globalThis.PropType<boolean>;
74
+ default: boolean;
75
+ };
76
+ target: {
77
+ type: globalThis.PropType<string>;
78
+ default: string;
79
+ };
80
+ to: {
81
+ type: globalThis.PropType<string>;
82
+ default: string;
83
+ };
84
+ disabled: {
85
+ type: globalThis.PropType<boolean>;
86
+ default: boolean;
87
+ };
88
+ active: {
89
+ type: globalThis.PropType<boolean>;
90
+ default: boolean;
91
+ };
92
+ vertical: {
93
+ type: globalThis.PropType<boolean>;
94
+ default: boolean;
95
+ };
96
+ align: {
97
+ type: globalThis.PropType<"end" | "center" | "start">;
98
+ default: string;
99
+ };
100
+ grow: {
101
+ type: globalThis.PropType<boolean>;
102
+ default: boolean;
103
+ };
104
+ tabValue: {
105
+ type: globalThis.PropType<string | number>;
106
+ default: string;
107
+ };
108
+ exact: {
109
+ type: globalThis.PropType<boolean>;
110
+ default: boolean;
111
+ };
112
+ exactPath: {
113
+ type: globalThis.PropType<boolean>;
114
+ default: boolean;
115
+ };
116
+ }>> & {
117
+ onClick?: ((tabValue: string | number) => any) | undefined;
118
+ }, {
119
+ color: "primary" | "secondary" | "error" | "warning" | "info" | "success";
120
+ link: boolean;
121
+ target: string;
122
+ to: string;
123
+ disabled: boolean;
124
+ active: boolean;
125
+ vertical: boolean;
126
+ align: "end" | "center" | "start";
127
+ grow: boolean;
128
+ tabValue: string | number;
129
+ exact: boolean;
130
+ exactPath: boolean;
131
+ }, {}>, Partial<Record<NonNullable<string | number>, (_: any) => any>> & Partial<Record<NonNullable<string | number>, (_: any) => any>> & Partial<Record<NonNullable<string | number>, (_: any) => any>>>;
132
+ export default _default;
133
+ type __VLS_WithTemplateSlots<T, S> = T & {
134
+ new (): {
135
+ $slots: S;
136
+ };
137
+ };
@@ -0,0 +1,54 @@
1
+ export interface Props {
2
+ active?: boolean;
3
+ value?: number | string;
4
+ eager?: boolean;
5
+ reverse?: boolean;
6
+ }
7
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
8
+ reverse: {
9
+ type: globalThis.PropType<boolean>;
10
+ default: boolean;
11
+ };
12
+ value: {
13
+ type: globalThis.PropType<string | number>;
14
+ default: undefined;
15
+ };
16
+ active: {
17
+ type: globalThis.PropType<boolean>;
18
+ default: boolean;
19
+ };
20
+ eager: {
21
+ type: globalThis.PropType<boolean>;
22
+ default: boolean;
23
+ };
24
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
25
+ reverse: {
26
+ type: globalThis.PropType<boolean>;
27
+ default: boolean;
28
+ };
29
+ value: {
30
+ type: globalThis.PropType<string | number>;
31
+ default: undefined;
32
+ };
33
+ active: {
34
+ type: globalThis.PropType<boolean>;
35
+ default: boolean;
36
+ };
37
+ eager: {
38
+ type: globalThis.PropType<boolean>;
39
+ default: boolean;
40
+ };
41
+ }>>, {
42
+ reverse: boolean;
43
+ value: string | number;
44
+ active: boolean;
45
+ eager: boolean;
46
+ }, {}>, {
47
+ default?(_: {}): any;
48
+ }>;
49
+ export default _default;
50
+ type __VLS_WithTemplateSlots<T, S> = T & {
51
+ new (): {
52
+ $slots: S;
53
+ };
54
+ };
@@ -0,0 +1,17 @@
1
+ export interface Props {
2
+ modelValue?: number | string;
3
+ }
4
+ declare const _default: import("vue").DefineComponent<{
5
+ modelValue: {
6
+ type: globalThis.PropType<string | number>;
7
+ default: undefined;
8
+ };
9
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
10
+ modelValue: {
11
+ type: globalThis.PropType<string | number>;
12
+ default: undefined;
13
+ };
14
+ }>>, {
15
+ modelValue: string | number;
16
+ }, {}>;
17
+ export default _default;
@@ -0,0 +1,72 @@
1
+ import { type ContextColorsType } from '../../../consts/colors';
2
+ export interface Props {
3
+ color?: ContextColorsType;
4
+ vertical?: boolean;
5
+ disabled?: boolean;
6
+ grow?: boolean;
7
+ modelValue?: number | string;
8
+ align?: 'start' | 'center' | 'end';
9
+ }
10
+ declare const _default: import("vue").DefineComponent<{
11
+ color: {
12
+ type: globalThis.PropType<"primary" | "secondary" | "error" | "warning" | "info" | "success">;
13
+ default: undefined;
14
+ };
15
+ disabled: {
16
+ type: globalThis.PropType<boolean>;
17
+ default: boolean;
18
+ };
19
+ vertical: {
20
+ type: globalThis.PropType<boolean>;
21
+ default: boolean;
22
+ };
23
+ modelValue: {
24
+ type: globalThis.PropType<string | number>;
25
+ default: undefined;
26
+ };
27
+ align: {
28
+ type: globalThis.PropType<"end" | "center" | "start">;
29
+ default: string;
30
+ };
31
+ grow: {
32
+ type: globalThis.PropType<boolean>;
33
+ default: boolean;
34
+ };
35
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
36
+ "update:modelValue": (modelValue: string | number) => void;
37
+ }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
38
+ color: {
39
+ type: globalThis.PropType<"primary" | "secondary" | "error" | "warning" | "info" | "success">;
40
+ default: undefined;
41
+ };
42
+ disabled: {
43
+ type: globalThis.PropType<boolean>;
44
+ default: boolean;
45
+ };
46
+ vertical: {
47
+ type: globalThis.PropType<boolean>;
48
+ default: boolean;
49
+ };
50
+ modelValue: {
51
+ type: globalThis.PropType<string | number>;
52
+ default: undefined;
53
+ };
54
+ align: {
55
+ type: globalThis.PropType<"end" | "center" | "start">;
56
+ default: string;
57
+ };
58
+ grow: {
59
+ type: globalThis.PropType<boolean>;
60
+ default: boolean;
61
+ };
62
+ }>> & {
63
+ "onUpdate:modelValue"?: ((modelValue: string | number) => any) | undefined;
64
+ }, {
65
+ color: "primary" | "secondary" | "error" | "warning" | "info" | "success";
66
+ disabled: boolean;
67
+ vertical: boolean;
68
+ modelValue: string | number;
69
+ align: "end" | "center" | "start";
70
+ grow: boolean;
71
+ }, {}>;
72
+ export default _default;
@@ -1,4 +1,4 @@
1
- import { u as s, a } from "../index-2304aade.js";
1
+ import { u as s, a } from "../index-393a0e94.js";
2
2
  import "../all-icons.es.js";
3
3
  import "@vueuse/core";
4
4
  import "vue";