@rotki/ui-library 1.7.1 → 1.8.1

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.
@@ -4,7 +4,7 @@ export interface IconsOptions {
4
4
  registeredIcons: GeneratedIcon[];
5
5
  }
6
6
  export interface UseIconsReturn {
7
- registeredIcons: Readonly<Record<string, string>>;
7
+ registeredIcons: Readonly<Record<string, [string, Record<string, string>][]>>;
8
8
  }
9
9
  export declare const IconsSymbol: InjectionKey<UseIconsReturn>;
10
10
  export declare function createIconDefaults(options?: Partial<IconsOptions>): UseIconsReturn;
@@ -0,0 +1,478 @@
1
+ import { LuChevronsUpDown as se, LuArrowUp as re, LuArrowDown as ie, LuArrowLeft as ce, LuArrowRight as ae, LuChevronUp as le, LuChevronDown as ue, LuChevronLeft as fe, LuChevronRight as de, LuChevronsLeft as pe, LuChevronsRight as me, LuCircleAlert as he, LuCheck as ge, LuCircleX as ye, LuCircleCheck as we, LuCheckboxBlank as be, LuCheckboxFill as Le, LuCheckboxIndeterminateFill as ve, LuCheckboxBlankCircle as Ce, LuCheckboxBlankCircleFill as xe, LuRadioButtonFill as Te } from "../icons/icons_7.es.js";
2
+ import { LuEllipsis as Se, LuInfo as ke, LuEye as Ee, LuEyeOff as Pe } from "../icons/icons_8.es.js";
3
+ import { LuTriangleAlert as Ie } from "../icons/icons_9.es.js";
4
+ import { LuX as Oe } from "../icons/icons_10.es.js";
5
+ import { inject as ee, ref as h, computed as M, watch as W, onMounted as te, watchEffect as $e, nextTick as Y } from "vue";
6
+ import { e as Be } from "../utils/index-Cps3W0wA.js";
7
+ import { createSharedComposable as De, useColorMode as Ae, useWindowSize as Me, breakpointsTailwind as Re, useBreakpoints as ze, unrefElement as Z, useResizeObserver as ne, useVirtualList as He, useArrayMap as _e, watchOnce as qe, useEventListener as K, useMutationObserver as je } from "@vueuse/core";
8
+ import { d as oe, T as O } from "../types/index-DSBIGM2a.js";
9
+ import { get as e, set as l } from "@vueuse/shared";
10
+ import { c as G, p as Ue, d as Ve, a as We, o as Fe, f as Ne, b as Xe, e as Ke, g as Ge } from "../vendor-BRFX1hnB.js";
11
+ const Je = [
12
+ se,
13
+ Se,
14
+ Ie,
15
+ Oe,
16
+ ke,
17
+ re,
18
+ ie,
19
+ ce,
20
+ ae,
21
+ le,
22
+ ue,
23
+ fe,
24
+ de,
25
+ pe,
26
+ me,
27
+ he,
28
+ Ee,
29
+ Pe,
30
+ ge,
31
+ ye,
32
+ we,
33
+ be,
34
+ Le,
35
+ ve,
36
+ Ce,
37
+ xe,
38
+ Te
39
+ ], Qe = Symbol.for("rui:icons");
40
+ function dt(r) {
41
+ const f = (r == null ? void 0 : r.registeredIcons) || [];
42
+ return {
43
+ registeredIcons: {
44
+ ...Object.fromEntries(
45
+ [
46
+ ...Je,
47
+ ...f
48
+ ].map(({ components: p, name: y }) => [y, p])
49
+ )
50
+ }
51
+ };
52
+ }
53
+ function pt() {
54
+ const r = ee(Qe);
55
+ return Be(r, "Could not find icons injection"), r;
56
+ }
57
+ const V = h({ ...oe }), mt = De(() => {
58
+ const { state: r, store: f } = Ae(), p = M(() => e(f) === O.auto), y = M(() => e(r) === O.light), c = M(() => e(r) === O.dark), g = M(() => e(y) ? e(V).light : e(V).dark), i = (n) => {
59
+ l(f, n || O.auto);
60
+ }, v = () => {
61
+ e(p) ? i(O.light) : e(y) ? i(O.dark) : e(c) && i(O.auto);
62
+ }, w = (n) => {
63
+ l(V, n);
64
+ };
65
+ return {
66
+ config: V,
67
+ init: (n) => {
68
+ i(n.mode ?? O.auto), w(n.config ?? { ...oe }), typeof window < "u" && W([y, g], ([a, x]) => {
69
+ const o = /* @__PURE__ */ new Map();
70
+ Object.entries(x).forEach(([C, T]) => {
71
+ o.set(`--rui-${C}-darker`, T.darker), o.set(`--rui-${C}-lighter`, T.lighter), o.set(`--rui-${C}-main`, T.DEFAULT);
72
+ });
73
+ const u = a ? O.light : O.dark;
74
+ o.set("--rui-text-disabled", `var(--rui-${u}-text-disabled)`), o.set("--rui-text-primary", `var(--rui-${u}-text-primary)`), o.set("--rui-text-secondary", `var(--rui-${u}-text-secondary)`);
75
+ const P = document.documentElement.style;
76
+ o.forEach((C, T) => {
77
+ P.setProperty(T, C);
78
+ });
79
+ }, { immediate: !0 });
80
+ },
81
+ isAutoControlled: p,
82
+ isDark: c,
83
+ isLight: y,
84
+ setThemeConfig: w,
85
+ state: r,
86
+ store: f,
87
+ switchThemeScheme: i,
88
+ theme: g,
89
+ toggleThemeMode: v
90
+ };
91
+ });
92
+ function ht() {
93
+ const { width: r } = Me(), f = {
94
+ xs: 0,
95
+ ...Re
96
+ }, p = ze(f), y = Object.keys, c = y(f), g = c.map(
97
+ (n, a) => [
98
+ n,
99
+ a < c.length - 1 ? p.between(n, c[a + 1]) : p[n]
100
+ ]
101
+ ), i = g.map(([n, a]) => [
102
+ G(`is_${n}`),
103
+ a
104
+ ]), v = c.map((n) => [
105
+ G(`is_${n}_and_up`),
106
+ p.greaterOrEqual(n)
107
+ ]), w = c.map((n) => [
108
+ G(`is_${n}_and_down`),
109
+ p.smaller(n)
110
+ ]), d = M(() => {
111
+ var n;
112
+ return ((n = g.find((a) => e(a[1]))) == null ? void 0 : n[0]) || "";
113
+ });
114
+ return {
115
+ ...Object.fromEntries(i),
116
+ ...Object.fromEntries(v),
117
+ ...Object.fromEntries(w),
118
+ name: d,
119
+ width: r
120
+ };
121
+ }
122
+ const $ = {
123
+ adaptive: !0,
124
+ gpuAcceleration: !0,
125
+ locked: !1,
126
+ offsetDistance: 8,
127
+ offsetSkid: 0,
128
+ overflowPadding: 8,
129
+ placement: "bottom",
130
+ resize: !0,
131
+ scroll: !0,
132
+ strategy: "absolute"
133
+ }, Ye = Ue({
134
+ defaultModifiers: [
135
+ ...Ve,
136
+ We,
137
+ Fe,
138
+ Ne,
139
+ Xe,
140
+ Ke,
141
+ Ge
142
+ ]
143
+ });
144
+ function gt(r, f = h(!1), p = h(0), y = h(0), c) {
145
+ const g = h(null), i = h(null), v = h(null), w = h(!1), d = h(), n = h(), a = h(!1), x = h(!1), o = () => {
146
+ l(a, !1);
147
+ }, u = () => {
148
+ var m;
149
+ (m = e(v)) == null || m.update();
150
+ }, P = (m = !1) => {
151
+ if (!e(f) && (e(n) && (clearTimeout(e(n)), l(n, void 0)), l(x, !1), !e(d))) {
152
+ l(a, !0);
153
+ const L = setTimeout(() => {
154
+ l(w, !0), l(d, void 0);
155
+ }, m ? 0 : e(p));
156
+ l(d, L);
157
+ }
158
+ }, C = (m = !1) => {
159
+ if (!e(f) && (e(d) && (clearTimeout(e(d)), l(d, void 0)), !e(n))) {
160
+ const L = setTimeout(() => {
161
+ e(w) || o(), l(w, !1), l(n, void 0);
162
+ }, m ? 0 : e(y));
163
+ l(n, L);
164
+ }
165
+ }, T = () => {
166
+ l(x, !0);
167
+ };
168
+ return te(() => {
169
+ $e((m) => {
170
+ if (!e(i) || !e(g) && !e(c))
171
+ return;
172
+ const L = Z(i), B = e(c) || Z(g);
173
+ if (!(L instanceof HTMLElement) || !B)
174
+ return;
175
+ const {
176
+ adaptive: R = $.adaptive,
177
+ gpuAcceleration: E = $.gpuAcceleration,
178
+ locked: z = $.locked,
179
+ offsetDistance: b = $.offsetDistance,
180
+ offsetSkid: F = $.offsetSkid,
181
+ overflowPadding: j = $.overflowPadding,
182
+ placement: U = $.placement,
183
+ resize: H = $.resize,
184
+ scroll: _ = $.scroll,
185
+ strategy: N = $.strategy
186
+ } = e(r), X = Ye(B, L, {
187
+ modifiers: [
188
+ {
189
+ enabled: !z,
190
+ name: "flip"
191
+ },
192
+ {
193
+ name: "preventOverflow",
194
+ options: {
195
+ padding: j
196
+ }
197
+ },
198
+ {
199
+ name: "offset",
200
+ options: {
201
+ offset: [F, b]
202
+ }
203
+ },
204
+ {
205
+ name: "computeStyles",
206
+ options: {
207
+ adaptive: R,
208
+ gpuAcceleration: E
209
+ }
210
+ },
211
+ {
212
+ name: "eventListeners",
213
+ options: {
214
+ resize: H,
215
+ scroll: _
216
+ }
217
+ },
218
+ {
219
+ name: "arrow",
220
+ options: {
221
+ padding: 4
222
+ }
223
+ }
224
+ ],
225
+ placement: U,
226
+ strategy: N
227
+ });
228
+ l(v, X), m(X.destroy);
229
+ });
230
+ }), ne([g, i], async () => {
231
+ const m = e(v);
232
+ e(w) && m && await m.update();
233
+ }), {
234
+ instance: v,
235
+ leavePending: x,
236
+ onClose: C,
237
+ onLeavePending: T,
238
+ onOpen: P,
239
+ onPopperLeave: o,
240
+ open: w,
241
+ popper: i,
242
+ popperEnter: a,
243
+ reference: g,
244
+ updatePopper: u
245
+ };
246
+ }
247
+ function Ze({
248
+ keyAttr: r,
249
+ textAttr: f
250
+ }) {
251
+ function p(c) {
252
+ var g;
253
+ return f ? typeof f == "function" ? f(c) : (g = c[f]) == null ? void 0 : g.toString() : c == null ? void 0 : c.toString();
254
+ }
255
+ function y(c) {
256
+ return r ? c[r] : c;
257
+ }
258
+ return {
259
+ getIdentifier: y,
260
+ getText: p
261
+ };
262
+ }
263
+ function yt({
264
+ appendWidth: r,
265
+ autoFocus: f,
266
+ autoSelectFirst: p,
267
+ dense: y,
268
+ hideSelected: c,
269
+ itemHeight: g = 48,
270
+ keyAttr: i,
271
+ menuRef: v,
272
+ options: w,
273
+ overscan: d = 5,
274
+ prependWidth: n,
275
+ setValue: a,
276
+ textAttr: x,
277
+ value: o
278
+ }) {
279
+ const u = M(() => {
280
+ const t = e(w);
281
+ return c ? t.filter((s) => !H(s)) : t;
282
+ }), { getIdentifier: P, getText: C } = Ze({
283
+ keyAttr: i,
284
+ textAttr: x
285
+ }), { containerProps: T, list: m, scrollTo: L, wrapperProps: B } = He(
286
+ u,
287
+ {
288
+ itemHeight: g,
289
+ overscan: d
290
+ }
291
+ ), R = _e(m, ({ data: t, index: s }) => ({ _index: s, item: t })), E = h(!1), z = M(() => {
292
+ const t = e(o);
293
+ return !i || !t ? t : Array.isArray(t) ? t.map((s) => s[i]) : t[i];
294
+ }), b = h(e(p) ? 0 : -1), F = M(() => {
295
+ const t = { max: 0, min: 0 }, s = 30, I = 1.5, S = e(y) ? 12 : 13;
296
+ e(u).forEach((D) => {
297
+ var J, Q;
298
+ const A = ((Q = (J = C(D)) == null ? void 0 : J.toString()) == null ? void 0 : Q.length) ?? 0;
299
+ t.min === 0 && t.max === 0 ? (t.min = A, t.max = A) : A < t.min ? t.min = A : A > t.max && (t.max = A);
300
+ });
301
+ const q = t.max - t.min;
302
+ function k(D) {
303
+ const A = (n ? n + 0.5 : 0) + (r ? r + 0.5 : 0);
304
+ return `${Math.min(D * S / 16 + I + A, s)}rem`;
305
+ }
306
+ return q <= 5 ? k(t.max) : k(t.min + q / 2);
307
+ });
308
+ function j(t = !1) {
309
+ l(E, t);
310
+ }
311
+ function U(t) {
312
+ const s = e(o), I = Array.isArray(s) ? s : s ? [s] : [];
313
+ return I.length === 0 ? -1 : I.findIndex((S) => i ? S[i] === t[i] : S === t);
314
+ }
315
+ function H(t) {
316
+ return U(t) !== -1;
317
+ }
318
+ async function _(t = !1) {
319
+ const s = e(b);
320
+ s > -1 && await Y(() => {
321
+ var S, q;
322
+ if ((S = e(v)) == null ? void 0 : S.parentElement) {
323
+ const k = e(v).getElementsByClassName("highlighted")[0];
324
+ if (k)
325
+ (q = k.scrollIntoView) == null || q.call(k, { behavior: t ? "smooth" : "auto", block: "nearest" }), e(f) && "focus" in k && typeof k.focus == "function" && (k == null || k.focus());
326
+ else if (L(s), e(f)) {
327
+ const D = e(v).getElementsByClassName("highlighted")[0];
328
+ D && "focus" in D && typeof D.focus == "function" && D.focus();
329
+ }
330
+ }
331
+ });
332
+ }
333
+ async function N(t) {
334
+ await Y(() => {
335
+ if (t) {
336
+ const s = e(o);
337
+ if (Array.isArray(s) && s.length > 0 || s) {
338
+ const I = e(u).findIndex(H);
339
+ I > -1 && l(b, I);
340
+ }
341
+ qe(m, async () => {
342
+ await _();
343
+ });
344
+ }
345
+ });
346
+ }
347
+ return W(E, N), W(b, async (t, s) => {
348
+ t !== s && await _(!0);
349
+ }), W(u, async () => {
350
+ e(b) !== -1 ? e(p) ? (l(b, 0), await _()) : (l(b, -1), L(0)) : L(0);
351
+ }), {
352
+ applyHighlighted: () => {
353
+ if (!a || !e(E))
354
+ return;
355
+ const t = e(b);
356
+ if (t === -1)
357
+ return;
358
+ const s = e(u).find((I, S) => t === S);
359
+ s && a(s);
360
+ },
361
+ containerProps: T,
362
+ getIdentifier: P,
363
+ getText: C,
364
+ highlightedIndex: b,
365
+ isActiveItem: H,
366
+ isOpen: E,
367
+ itemIndexInValue: U,
368
+ menuWidth: F,
369
+ moveHighlight: (t) => {
370
+ if (!e(E)) {
371
+ j(!0);
372
+ return;
373
+ }
374
+ let s = e(b);
375
+ s += t ? -1 : 1;
376
+ const S = e(u).length;
377
+ s >= S ? l(b, 0) : s < 0 ? l(b, S - 1) : l(b, s);
378
+ },
379
+ optionsWithSelectedHidden: u,
380
+ renderedData: R,
381
+ toggle: j,
382
+ valueKey: z,
383
+ wrapperProps: B
384
+ };
385
+ }
386
+ const et = Symbol.for("rui:table");
387
+ function wt(r) {
388
+ return {
389
+ globalItemsPerPage: !1,
390
+ itemsPerPage: h(10),
391
+ limits: [10, 25, 50, 100],
392
+ stickyOffset: h(0),
393
+ ...r
394
+ };
395
+ }
396
+ function bt() {
397
+ const r = ee(et);
398
+ if (!r)
399
+ throw new Error("Could not find rui table options injection");
400
+ return r;
401
+ }
402
+ function Lt(r = h(!1), f) {
403
+ const p = h(null), y = h(null), c = h(!1), g = -0.5, i = {
404
+ head: ":scope > thead[data-id=head-main]",
405
+ headClone: ":scope > thead[data-id=head-clone]",
406
+ row: ":scope > tbody > tr:not([hidden])",
407
+ th: ":scope > th"
408
+ }, v = () => {
409
+ const d = e(p);
410
+ if (!e(r) || !d)
411
+ return;
412
+ const n = d.querySelector(
413
+ `${i.headClone} > tr`
414
+ ), a = d.querySelector(`${i.head} > tr`) ?? null, x = () => {
415
+ const o = a == null ? void 0 : a.querySelectorAll(
416
+ i.th
417
+ ), u = n == null ? void 0 : n.querySelectorAll(i.th);
418
+ u == null || u.forEach((P, C) => {
419
+ ne(P, (T) => {
420
+ const m = T[0].target.getBoundingClientRect(), L = o == null ? void 0 : o.item(C);
421
+ L && (L.style.width = `${m.width}px`);
422
+ });
423
+ });
424
+ };
425
+ je(n, (o) => {
426
+ for (const u of o)
427
+ (u.type === "childList" || u.type === "attributes") && x();
428
+ }, {
429
+ attributes: !0,
430
+ childList: !0,
431
+ subtree: !0
432
+ }), x();
433
+ }, w = () => {
434
+ var z;
435
+ const d = e(p);
436
+ if (!e(r) || !d)
437
+ return;
438
+ const n = d.getBoundingClientRect(), a = d.querySelector(
439
+ i.headClone
440
+ ), x = a == null ? void 0 : a.getBoundingClientRect(), o = d.querySelector(i.head) ?? null, u = o == null ? void 0 : o.getBoundingClientRect();
441
+ if (!n || !x || !o || !a || !u)
442
+ return;
443
+ const {
444
+ height: P,
445
+ left: C,
446
+ width: T
447
+ } = x, { bottom: m, top: L } = n, B = e(f) ?? 0;
448
+ o.style.width = `${T}px`;
449
+ const R = d.querySelectorAll(i.row), E = (z = R.item(R.length - 1)) == null ? void 0 : z.getBoundingClientRect();
450
+ if (L <= B && m > B && R.length > 1) {
451
+ l(c, !0), o.style.left = `${C + g}px`;
452
+ const b = (E == null ? void 0 : E.height) ?? 0;
453
+ m <= b + P + B ? o.style.top = `${m - b - P}px` : o.style.top = `${B}px`;
454
+ } else
455
+ l(c, !1), o.style.left = `${g}px`, o.style.top = "0";
456
+ };
457
+ return te(() => {
458
+ w(), K(y, "scroll", w), K(document.body, "scroll", w), K(window, "resize", w), v();
459
+ }), {
460
+ stick: c,
461
+ table: p,
462
+ tableScroller: y
463
+ };
464
+ }
465
+ export {
466
+ Qe as I,
467
+ et as T,
468
+ gt as a,
469
+ Ze as b,
470
+ yt as c,
471
+ bt as d,
472
+ Lt as e,
473
+ dt as f,
474
+ wt as g,
475
+ mt as h,
476
+ ht as i,
477
+ pt as u
478
+ };
@@ -1,4 +1,4 @@
1
- import { i as o, u as a, h as u } from "./index-Q1RSg-Av.js";
1
+ import { i as o, u as a, h as u } from "./index-D0JjQG2m.js";
2
2
  export {
3
3
  o as useBreakpoint,
4
4
  a as useIcons,