@rotki/ui-library 1.0.0-beta.2 → 1.0.0-beta.4

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,9 +1,9 @@
1
+ import { type KeyOfType } from '../../../composables/dropdown-menu';
1
2
  import { type MenuProps } from '../../../components/overlays/menu/RuiMenu.vue';
2
- export interface Props<T, K extends keyof T = keyof T> {
3
- options: T[];
4
- keyAttr?: K;
5
- textAttr?: keyof T;
6
- modelValue?: T extends string ? T : T[K];
3
+ export interface Props<TValue, TItem> {
4
+ options: TItem[];
5
+ keyAttr?: KeyOfType<TItem, TValue>;
6
+ textAttr?: keyof TItem;
7
7
  disabled?: boolean;
8
8
  loading?: boolean;
9
9
  readOnly?: boolean;
@@ -26,12 +26,12 @@ export interface Props<T, K extends keyof T = keyof T> {
26
26
  hideNoData?: boolean;
27
27
  noDataText?: string;
28
28
  }
29
- declare const _default: <T extends string | object, K extends keyof T = keyof T>(__VLS_props: {
30
- "onUpdate:model-value"?: ((value?: T | T[K] | undefined) => any) | undefined;
31
- options: T[];
32
- keyAttr?: K | undefined;
33
- textAttr?: keyof T | undefined;
34
- modelValue?: (T extends string ? T : T[K]) | undefined;
29
+ declare const _default: <TValue, TItem>(__VLS_props: {
30
+ "onUpdate:modelValue"?: ((modelValue: TValue | undefined) => any) | undefined;
31
+ modelValue: TValue | undefined;
32
+ options: TItem[];
33
+ keyAttr?: keyof { [P in keyof TItem as TItem[P] extends TValue ? P : never]: any; } | undefined;
34
+ textAttr?: keyof TItem | undefined;
35
35
  disabled?: boolean | undefined;
36
36
  loading?: boolean | undefined;
37
37
  readOnly?: boolean | undefined;
@@ -55,11 +55,11 @@ declare const _default: <T extends string | object, K extends keyof T = keyof T>
55
55
  noDataText?: string | undefined;
56
56
  } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, __VLS_ctx?: {
57
57
  attrs: any;
58
- emit: (e: 'update:model-value', value?: T | T[K]) => void;
58
+ emit: (evt: "update:modelValue", modelValue: TValue | undefined) => void;
59
59
  slots: {
60
60
  activator?(_: {
61
61
  disabled: boolean;
62
- value: T | undefined;
62
+ value: TItem | undefined;
63
63
  variant: "default" | "outlined" | "filled";
64
64
  readOnly: boolean;
65
65
  attrs: {
@@ -76,38 +76,38 @@ declare const _default: <T extends string | object, K extends keyof T = keyof T>
76
76
  hasSuccess: boolean;
77
77
  }): any;
78
78
  "activator.label"?(_: {
79
- value: T | undefined;
79
+ value: TItem | undefined;
80
80
  }): any;
81
81
  "selection.prepend"?(_: {
82
- item: T;
82
+ item: NonNullable<TItem>;
83
83
  }): any;
84
84
  selection?(_: {
85
- item: T;
85
+ item: NonNullable<TItem>;
86
86
  }): any;
87
87
  "item.prepend"?(_: {
88
88
  disabled: boolean;
89
- item: T;
89
+ item: TItem;
90
90
  active: boolean;
91
91
  }): any;
92
92
  item?(_: {
93
93
  disabled: boolean;
94
- item: T;
94
+ item: TItem;
95
95
  active: boolean;
96
96
  }): any;
97
97
  "item.append"?(_: {
98
98
  disabled: boolean;
99
- item: T;
99
+ item: TItem;
100
100
  active: boolean;
101
101
  }): any;
102
102
  "no-data"?(_: {}): any;
103
103
  };
104
104
  } | undefined, __VLS_expose?: ((exposed: import('vue').ShallowUnwrapRef<{}>) => void) | undefined, __VLS_setup?: Promise<{
105
105
  props: {
106
- "onUpdate:model-value"?: ((value?: T | T[K] | undefined) => any) | undefined;
107
- options: T[];
108
- keyAttr?: K | undefined;
109
- textAttr?: keyof T | undefined;
110
- modelValue?: (T extends string ? T : T[K]) | undefined;
106
+ "onUpdate:modelValue"?: ((modelValue: TValue | undefined) => any) | undefined;
107
+ modelValue: TValue | undefined;
108
+ options: TItem[];
109
+ keyAttr?: keyof { [P in keyof TItem as TItem[P] extends TValue ? P : never]: any; } | undefined;
110
+ textAttr?: keyof TItem | undefined;
111
111
  disabled?: boolean | undefined;
112
112
  loading?: boolean | undefined;
113
113
  readOnly?: boolean | undefined;
@@ -135,7 +135,7 @@ declare const _default: <T extends string | object, K extends keyof T = keyof T>
135
135
  slots: {
136
136
  activator?(_: {
137
137
  disabled: boolean;
138
- value: T | undefined;
138
+ value: TItem | undefined;
139
139
  variant: "default" | "outlined" | "filled";
140
140
  readOnly: boolean;
141
141
  attrs: {
@@ -152,42 +152,42 @@ declare const _default: <T extends string | object, K extends keyof T = keyof T>
152
152
  hasSuccess: boolean;
153
153
  }): any;
154
154
  "activator.label"?(_: {
155
- value: T | undefined;
155
+ value: TItem | undefined;
156
156
  }): any;
157
157
  "selection.prepend"?(_: {
158
- item: T;
158
+ item: NonNullable<TItem>;
159
159
  }): any;
160
160
  selection?(_: {
161
- item: T;
161
+ item: NonNullable<TItem>;
162
162
  }): any;
163
163
  "item.prepend"?(_: {
164
164
  disabled: boolean;
165
- item: T;
165
+ item: TItem;
166
166
  active: boolean;
167
167
  }): any;
168
168
  item?(_: {
169
169
  disabled: boolean;
170
- item: T;
170
+ item: TItem;
171
171
  active: boolean;
172
172
  }): any;
173
173
  "item.append"?(_: {
174
174
  disabled: boolean;
175
- item: T;
175
+ item: TItem;
176
176
  active: boolean;
177
177
  }): any;
178
178
  "no-data"?(_: {}): any;
179
179
  };
180
- emit: (e: 'update:model-value', value?: T | T[K]) => void;
180
+ emit: (evt: "update:modelValue", modelValue: TValue | undefined) => void;
181
181
  }>) => globalThis.VNode<import("vue").RendererNode, import("vue").RendererElement, {
182
182
  [key: string]: any;
183
183
  }> & {
184
184
  __ctx?: {
185
185
  props: {
186
- "onUpdate:model-value"?: ((value?: T | T[K] | undefined) => any) | undefined;
187
- options: T[];
188
- keyAttr?: K | undefined;
189
- textAttr?: keyof T | undefined;
190
- modelValue?: (T extends string ? T : T[K]) | undefined;
186
+ "onUpdate:modelValue"?: ((modelValue: TValue | undefined) => any) | undefined;
187
+ modelValue: TValue | undefined;
188
+ options: TItem[];
189
+ keyAttr?: keyof { [P in keyof TItem as TItem[P] extends TValue ? P : never]: any; } | undefined;
190
+ textAttr?: keyof TItem | undefined;
191
191
  disabled?: boolean | undefined;
192
192
  loading?: boolean | undefined;
193
193
  readOnly?: boolean | undefined;
@@ -215,7 +215,7 @@ declare const _default: <T extends string | object, K extends keyof T = keyof T>
215
215
  slots: {
216
216
  activator?(_: {
217
217
  disabled: boolean;
218
- value: T | undefined;
218
+ value: TItem | undefined;
219
219
  variant: "default" | "outlined" | "filled";
220
220
  readOnly: boolean;
221
221
  attrs: {
@@ -232,32 +232,32 @@ declare const _default: <T extends string | object, K extends keyof T = keyof T>
232
232
  hasSuccess: boolean;
233
233
  }): any;
234
234
  "activator.label"?(_: {
235
- value: T | undefined;
235
+ value: TItem | undefined;
236
236
  }): any;
237
237
  "selection.prepend"?(_: {
238
- item: T;
238
+ item: NonNullable<TItem>;
239
239
  }): any;
240
240
  selection?(_: {
241
- item: T;
241
+ item: NonNullable<TItem>;
242
242
  }): any;
243
243
  "item.prepend"?(_: {
244
244
  disabled: boolean;
245
- item: T;
245
+ item: TItem;
246
246
  active: boolean;
247
247
  }): any;
248
248
  item?(_: {
249
249
  disabled: boolean;
250
- item: T;
250
+ item: TItem;
251
251
  active: boolean;
252
252
  }): any;
253
253
  "item.append"?(_: {
254
254
  disabled: boolean;
255
- item: T;
255
+ item: TItem;
256
256
  active: boolean;
257
257
  }): any;
258
258
  "no-data"?(_: {}): any;
259
259
  };
260
- emit: (e: 'update:model-value', value?: T | T[K]) => void;
260
+ emit: (evt: "update:modelValue", modelValue: TValue | undefined) => void;
261
261
  } | undefined;
262
262
  };
263
263
  export default _default;
@@ -1,4 +1,4 @@
1
- import { I as u, H as s, R as e, a as R, b as o, J as t, c as r, d as l, u as d, v as n, e as p, f as c, K as T, r as b, t as S, D as g, g as m, h as x, _ as C, q as A, F as h, L as B, M as D, i as k, j as v, k as w, l as F, s as I, B as f, G, m as L, n as M, x as P, z as E, y as H, A as N, E as j, w as q, C as y, o as z, p as J } from "../RuiNavigationDrawer-DgxZEmkN.js";
1
+ import { I as u, H as s, R as e, a as R, b as o, J as t, c as r, d as l, u as d, v as n, e as p, f as c, K as T, r as b, t as S, D as g, g as m, h as x, _ as C, q as A, F as h, L as B, M as D, i as k, j as v, k as w, l as F, s as I, B as f, G, m as L, n as M, x as P, z as E, y as H, A as N, E as j, w as q, C as y, o as z, p as J } from "../RuiNavigationDrawer-DdMiKI77.js";
2
2
  export {
3
3
  u as RuiAccordion,
4
4
  s as RuiAccordions,
@@ -1,28 +1,37 @@
1
- export interface Props {
2
- modelValue?: number | string;
1
+ export interface Props<T> {
2
+ modelValue?: T;
3
3
  }
4
- declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
5
- modelValue: undefined;
6
- }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<globalThis.ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
7
- modelValue: undefined;
8
- }>>>, {
9
- modelValue: string | number;
10
- }, {}>;
11
- export default _default;
12
- type __VLS_WithDefaults<P, D> = {
13
- [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
14
- default: D[K];
15
- }> : P[K];
4
+ declare const _default: <T extends string | number>(__VLS_props: {
5
+ "onUpdate:modelValue"?: ((modelValue: T | undefined) => any) | undefined;
6
+ modelValue?: Props<T>['modelValue'];
7
+ } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, __VLS_ctx?: {
8
+ attrs: any;
9
+ emit: (evt: "update:modelValue", modelValue: T | undefined) => void;
10
+ slots: {};
11
+ } | undefined, __VLS_expose?: ((exposed: import('vue').ShallowUnwrapRef<{}>) => void) | undefined, __VLS_setup?: Promise<{
12
+ props: {
13
+ "onUpdate:modelValue"?: ((modelValue: T | undefined) => any) | undefined;
14
+ modelValue?: Props<T>['modelValue'];
15
+ } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps;
16
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
17
+ attrs: any;
18
+ slots: {};
19
+ emit: (evt: "update:modelValue", modelValue: T | undefined) => void;
20
+ }>) => globalThis.VNode<import("vue").RendererNode, import("vue").RendererElement, {
21
+ [key: string]: any;
22
+ }> & {
23
+ __ctx?: {
24
+ props: {
25
+ "onUpdate:modelValue"?: ((modelValue: T | undefined) => any) | undefined;
26
+ modelValue?: Props<T>['modelValue'];
27
+ } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps;
28
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
29
+ attrs: any;
30
+ slots: {};
31
+ emit: (evt: "update:modelValue", modelValue: T | undefined) => void;
32
+ } | undefined;
16
33
  };
34
+ export default _default;
17
35
  type __VLS_Prettify<T> = {
18
36
  [K in keyof T]: T[K];
19
37
  } & {};
20
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
21
- type __VLS_TypePropsToOption<T> = {
22
- [K in keyof T]-?: {} extends Pick<T, K> ? {
23
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
24
- } : {
25
- type: import('vue').PropType<T[K]>;
26
- required: true;
27
- };
28
- };
@@ -1,42 +1,45 @@
1
1
  import type { Ref } from 'vue';
2
- export interface DropdownOptions<T, K extends keyof T = keyof T> {
3
- options: Ref<T[]>;
2
+ export type KeyOfType<T, V> = keyof {
3
+ [P in keyof T as T[P] extends V ? P : never]: any;
4
+ };
5
+ export interface DropdownOptions<TValue, TItem> {
6
+ options: Ref<TItem[]>;
4
7
  dense?: Ref<boolean>;
5
- value: Ref<T | T[] | undefined>;
8
+ value: Ref<TItem | TItem[] | undefined>;
6
9
  menuRef: Ref<HTMLElement>;
7
- keyAttr?: K;
8
- textAttr?: keyof T | ((item: T) => string);
10
+ keyAttr?: KeyOfType<TItem, TValue extends Array<infer U> ? U : TValue>;
11
+ textAttr?: keyof TItem | ((item: TItem) => string);
9
12
  appendWidth?: number;
10
13
  prependWidth?: number;
11
14
  itemHeight?: number;
12
15
  overscan?: number;
13
16
  autoSelectFirst?: boolean;
14
17
  autoFocus?: boolean;
15
- setValue?: (val: T) => void;
18
+ setValue?: (val: TItem) => void;
16
19
  hideSelected?: boolean;
17
20
  }
18
- export declare function useDropdownMenu<T extends object | string, K extends keyof T>({ appendWidth, autoFocus, autoSelectFirst, dense, hideSelected, itemHeight, keyAttr, menuRef, options: allOptions, overscan, prependWidth, setValue, textAttr, value, }: DropdownOptions<T, K>): {
21
+ export declare function useDropdownMenu<TValue, TItem>({ appendWidth, autoFocus, autoSelectFirst, dense, hideSelected, itemHeight, keyAttr, menuRef, options: allOptions, overscan, prependWidth, setValue, textAttr, value, }: DropdownOptions<TValue, TItem>): {
19
22
  applyHighlighted: () => void;
20
23
  containerProps: {
21
24
  ref: Ref<HTMLElement | null>;
22
25
  onScroll: () => void;
23
26
  style: import("vue").StyleValue;
24
27
  };
25
- getIdentifier: (item: T) => T[K] | T;
26
- getText: (item: T) => string | undefined;
28
+ getIdentifier: (item: TItem) => TItem | TItem[KeyOfType<TItem, TValue>];
29
+ getText: (item: TItem) => string | undefined;
27
30
  highlightedIndex: Ref<number>;
28
- isActiveItem: (item: T) => boolean;
31
+ isActiveItem: (item: TItem) => boolean;
29
32
  isOpen: Ref<boolean>;
30
- itemIndexInValue: (item: T) => number;
33
+ itemIndexInValue: (item: TItem) => number;
31
34
  menuWidth: globalThis.ComputedRef<string>;
32
35
  moveHighlight: (up: boolean) => void;
33
- optionsWithSelectedHidden: globalThis.ComputedRef<T[]>;
36
+ optionsWithSelectedHidden: globalThis.ComputedRef<TItem[]>;
34
37
  renderedData: globalThis.ComputedRef<{
35
38
  index: number;
36
- item: T;
39
+ item: TItem;
37
40
  }[]>;
38
41
  toggle: (state?: boolean) => void;
39
- valueKey: globalThis.ComputedRef<any[] | T | T[K] | undefined>;
42
+ valueKey: globalThis.ComputedRef<TItem | TItem[] | TItem[keyof { [P in keyof TItem as TItem[P] extends (TValue extends (infer U)[] ? U : TValue) ? P : never]: any; }][] | NonNullable<TItem>[keyof { [P in keyof TItem as TItem[P] extends (TValue extends (infer U)[] ? U : TValue) ? P : never]: any; }] | undefined>;
40
43
  wrapperProps: globalThis.ComputedRef<{
41
44
  style: {
42
45
  width: string;
package/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { u as a, a as r } from "./index-NNlkUY_M.js";
2
2
  import { T as C } from "./index-NNlkUY_M.js";
3
- import { N as F, T as L } from "./RuiNavigationDrawer-DgxZEmkN.js";
4
- import { I as S, H as g, R as m, a as k, b as B, J as w, c as f, d as P, u as y, v as D, e as M, f as b, K as A, r as T, t as x, D as H, g as U, h as E, _ as v, q as G, F as I, L as W, M as V, i as O, j as N, k as z, l as K, s as q, B as Q, G as j, m as Z, n as X, x as J, z as Y, y as _, A as $, E as ii, w as li, C as ei, o as Ri, p as ni, S as oi } from "./RuiNavigationDrawer-DgxZEmkN.js";
3
+ import { N as F, T as L } from "./RuiNavigationDrawer-DdMiKI77.js";
4
+ import { I as S, H as g, R as m, a as k, b as B, J as w, c as f, d as P, u as y, v as D, e as M, f as b, K as A, r as T, t as x, D as H, g as U, h as E, _ as v, q as G, F as I, L as W, M as V, i as O, j as N, k as z, l as K, s as q, B as Q, G as j, m as Z, n as X, x as J, z as Y, y as _, A as $, E as ii, w as li, C as ei, o as Ri, p as ni, S as oi } from "./RuiNavigationDrawer-DdMiKI77.js";
5
5
  import { u as ri } from "./breakpoint-OTAceaTK.js";
6
6
  import { RuiIcons as Li, isRuiIcon as ti } from "./icons/index.es.js";
7
7
  import { c as di } from "./colors-D563Ic3q.js";