@uoguelph/react-components 1.10.0-rc.2 → 1.10.0-rc.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.
- package/dist/components/toaster/toaster.d.ts +19 -5
- package/dist/index.browser-E4KzWirf.js +9 -0
- package/dist/pagination.js +65 -70
- package/dist/toaster.js +77 -62
- package/package.json +1 -1
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export type Toast = {
|
|
2
|
+
message: string;
|
|
3
|
+
type: 'error' | 'success' | 'info' | 'warning';
|
|
4
|
+
id: string;
|
|
5
|
+
timeout: number;
|
|
6
|
+
};
|
|
7
|
+
declare function removeToast(id: string): void;
|
|
8
|
+
declare function addToast(message: Toast['message'], type?: Toast['type'], timeout?: Toast['timeout']): void;
|
|
9
|
+
export declare function useToaster(): Toast[];
|
|
10
|
+
export declare const toast: {
|
|
11
|
+
add: typeof addToast;
|
|
12
|
+
remove: typeof removeToast;
|
|
13
|
+
info: (message: Toast["message"], timeout?: Toast["timeout"]) => void;
|
|
14
|
+
success: (message: Toast["message"], timeout?: Toast["timeout"]) => void;
|
|
15
|
+
warning: (message: Toast["message"], timeout?: Toast["timeout"]) => void;
|
|
16
|
+
error: (message: Toast["message"], timeout?: Toast["timeout"]) => void;
|
|
17
|
+
};
|
|
18
|
+
export declare function Toaster(): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export {};
|
package/dist/pagination.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { h as
|
|
2
|
+
import { jsxs as n, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { h as v } from "./solid-CpJcQLq3.js";
|
|
4
4
|
import { FontAwesomeIcon as f } from "@fortawesome/react-fontawesome";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
5
|
+
import { n as q } from "./index.browser-E4KzWirf.js";
|
|
6
|
+
import { useState as x, useEffect as B } from "react";
|
|
7
|
+
import { twMerge as F } from "tailwind-merge";
|
|
8
|
+
import { tv as G } from "tailwind-variants";
|
|
9
|
+
import { c as N } from "./math-utils-CnAd98v6.js";
|
|
10
|
+
import { Button as V } from "./button.js";
|
|
11
|
+
import { NumberInput as _ } from "./number-input.js";
|
|
12
|
+
var D = {
|
|
12
13
|
prefix: "fad",
|
|
13
14
|
iconName: "chevrons-right",
|
|
14
15
|
icon: [
|
|
@@ -18,7 +19,7 @@ var U = {
|
|
|
18
19
|
"f324",
|
|
19
20
|
["M32 448c0 8.2 3.1 16.4 9.4 22.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3l-192-192C80.4 35.1 72.2 32 64 32s-16.4 3.1-22.6 9.4c-12.5 12.5-12.5 32.8 0 45.3L210.7 256 41.4 425.4C35.1 431.6 32 439.8 32 448z", "M470.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L402.7 256 233.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"]
|
|
20
21
|
]
|
|
21
|
-
},
|
|
22
|
+
}, H = {
|
|
22
23
|
prefix: "fad",
|
|
23
24
|
iconName: "chevrons-left",
|
|
24
25
|
icon: [
|
|
@@ -29,53 +30,47 @@ var U = {
|
|
|
29
30
|
["M224 256c0 8.2 3.1 16.4 9.4 22.6l192 192c6.2 6.2 14.4 9.4 22.6 9.4s16.4-3.1 22.6-9.4c12.5-12.5 12.5-32.8 0-45.3L301.3 256 470.6 86.6c12.5-12.5 12.5-32.8 0-45.3C464.4 35.1 456.2 32 448 32s-16.4 3.1-22.6 9.4l-192 192c-6.2 6.2-9.4 14.4-9.4 22.6z", "M41.4 278.6c-12.5-12.5-12.5-32.8 0-45.3l192-192c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3L109.3 256 278.6 425.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0l-192-192z"]
|
|
30
31
|
]
|
|
31
32
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
for (; i--; )
|
|
35
|
-
e += D[m[i] & 63];
|
|
36
|
-
return e;
|
|
37
|
-
};
|
|
38
|
-
function re({
|
|
39
|
-
page: i,
|
|
33
|
+
function se({
|
|
34
|
+
page: d,
|
|
40
35
|
count: e,
|
|
41
|
-
visible:
|
|
42
|
-
defaultPage:
|
|
36
|
+
visible: w,
|
|
37
|
+
defaultPage: h,
|
|
43
38
|
onChange: P,
|
|
44
|
-
color:
|
|
39
|
+
color: m = "yellow",
|
|
45
40
|
hideInput: C = !1,
|
|
46
41
|
hideList: k = !1,
|
|
47
42
|
className: $
|
|
48
43
|
}) {
|
|
49
|
-
const [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}, [
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
P?.(
|
|
56
|
-
},
|
|
57
|
-
const
|
|
58
|
-
return /* @__PURE__ */
|
|
44
|
+
const [s, I] = x(h ?? 0), [L, M] = x(h ?? 0), j = [...Array(e).keys()], o = Math.max(Math.ceil(w), 3), b = q();
|
|
45
|
+
B(() => {
|
|
46
|
+
l(d ?? 0);
|
|
47
|
+
}, [d]);
|
|
48
|
+
const l = (r) => {
|
|
49
|
+
const g = N(r, 0, e - 1);
|
|
50
|
+
P?.(g), I(g);
|
|
51
|
+
}, u = (r) => {
|
|
52
|
+
const g = s === r;
|
|
53
|
+
return /* @__PURE__ */ n(
|
|
59
54
|
"button",
|
|
60
55
|
{
|
|
61
|
-
className: `uofg-pagination-item ${W({ active:
|
|
56
|
+
className: `uofg-pagination-item ${W({ active: g })}`,
|
|
62
57
|
onClick: () => {
|
|
63
|
-
|
|
58
|
+
l(r);
|
|
64
59
|
},
|
|
65
60
|
children: [
|
|
66
61
|
/* @__PURE__ */ t("span", { className: "sr-only", children: "Page" }),
|
|
67
62
|
" ",
|
|
68
|
-
|
|
63
|
+
r + 1,
|
|
69
64
|
" ",
|
|
70
|
-
|
|
65
|
+
g ? /* @__PURE__ */ t("span", { className: "sr-only", children: "(Current Page)" }) : ""
|
|
71
66
|
]
|
|
72
67
|
},
|
|
73
|
-
|
|
68
|
+
r
|
|
74
69
|
);
|
|
75
70
|
};
|
|
76
|
-
let a,
|
|
77
|
-
e <= o || e < 5 ? (
|
|
78
|
-
const { base:
|
|
71
|
+
let i, a, c, p;
|
|
72
|
+
e <= o || e < 5 ? (i = 1, a = e - 1, c = !1, p = !1) : s < o - 1 ? (i = 1, a = o, p = !0, c = !1) : s > e - o ? (i = e - o, a = e - 1, c = !0, p = !1) : (i = s - Math.floor(o / 2), a = i + o, c = i > 1, p = a < e);
|
|
73
|
+
const { base: z, list: E, seperator: A, control: y, item: W, inputWrapper: R, goTo: S, input: T } = G({
|
|
79
74
|
slots: {
|
|
80
75
|
base: "flex w-full flex-col items-center justify-center gap-4 md:flex-row",
|
|
81
76
|
list: "flex items-center justify-center gap-4",
|
|
@@ -148,67 +143,67 @@ function re({
|
|
|
148
143
|
}
|
|
149
144
|
]
|
|
150
145
|
})({
|
|
151
|
-
color:
|
|
146
|
+
color: m ?? "yellow",
|
|
152
147
|
hideList: k ?? !1,
|
|
153
148
|
hideInput: C ?? !1
|
|
154
149
|
});
|
|
155
|
-
return /* @__PURE__ */
|
|
156
|
-
/* @__PURE__ */ t("a", { href: `#uofg-pagination-skip-${
|
|
157
|
-
/* @__PURE__ */
|
|
158
|
-
/* @__PURE__ */
|
|
150
|
+
return /* @__PURE__ */ n("div", { className: `uofg-pagination ${F(z(), $)}`, children: [
|
|
151
|
+
/* @__PURE__ */ t("a", { href: `#uofg-pagination-skip-${b}`, className: "sr-only! focus-visible:not-sr-only!", children: "Skip Pagination" }),
|
|
152
|
+
/* @__PURE__ */ n("div", { className: `uofg-pagination-list ${E()}`, children: [
|
|
153
|
+
/* @__PURE__ */ n(
|
|
159
154
|
"button",
|
|
160
155
|
{
|
|
161
|
-
disabled:
|
|
162
|
-
className: `uofg-pagination-previous ${
|
|
163
|
-
onClick: () =>
|
|
156
|
+
disabled: s <= 0,
|
|
157
|
+
className: `uofg-pagination-previous ${y()}`,
|
|
158
|
+
onClick: () => l(s - 1),
|
|
164
159
|
children: [
|
|
165
|
-
/* @__PURE__ */ t(f, { icon:
|
|
160
|
+
/* @__PURE__ */ t(f, { icon: H }),
|
|
166
161
|
/* @__PURE__ */ t("span", { className: "sr-only", children: "Previous Page" })
|
|
167
162
|
]
|
|
168
163
|
}
|
|
169
164
|
),
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
j.slice(
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
/* @__PURE__ */
|
|
165
|
+
u(0),
|
|
166
|
+
c && /* @__PURE__ */ t(f, { icon: v }),
|
|
167
|
+
j.slice(i, a).map(u),
|
|
168
|
+
p && /* @__PURE__ */ t(f, { icon: v }),
|
|
169
|
+
u(e - 1),
|
|
170
|
+
/* @__PURE__ */ n(
|
|
176
171
|
"button",
|
|
177
172
|
{
|
|
178
|
-
disabled:
|
|
179
|
-
className: `uofg-pagination-next ${
|
|
180
|
-
onClick: () =>
|
|
173
|
+
disabled: s >= e - 1,
|
|
174
|
+
className: `uofg-pagination-next ${y()}`,
|
|
175
|
+
onClick: () => l(s + 1),
|
|
181
176
|
children: [
|
|
182
|
-
/* @__PURE__ */ t(f, { icon:
|
|
177
|
+
/* @__PURE__ */ t(f, { icon: D }),
|
|
183
178
|
/* @__PURE__ */ t("span", { className: "sr-only", children: "Next Page" })
|
|
184
179
|
]
|
|
185
180
|
}
|
|
186
181
|
)
|
|
187
182
|
] }),
|
|
188
|
-
/* @__PURE__ */ t("span", { className: `uofg-pagination-seperator ${
|
|
189
|
-
/* @__PURE__ */
|
|
183
|
+
/* @__PURE__ */ t("span", { className: `uofg-pagination-seperator ${A()}` }),
|
|
184
|
+
/* @__PURE__ */ n("div", { className: `uofg-pagination-go-to-wrapper ${R()}`, children: [
|
|
190
185
|
/* @__PURE__ */ t(
|
|
191
|
-
|
|
186
|
+
_,
|
|
192
187
|
{
|
|
193
|
-
color:
|
|
188
|
+
color: m,
|
|
194
189
|
min: 1,
|
|
195
190
|
max: e,
|
|
196
|
-
value:
|
|
197
|
-
onInput: (
|
|
198
|
-
M(isNaN(
|
|
191
|
+
value: s + 1,
|
|
192
|
+
onInput: (r) => {
|
|
193
|
+
M(isNaN(r) ? 0 : N(r - 1, 0, e - 1));
|
|
199
194
|
},
|
|
200
195
|
className: `uofg-pagination-go-to-input ${T()}`,
|
|
201
196
|
children: /* @__PURE__ */ t("span", { className: "sr-only", children: "Input Page Number" })
|
|
202
197
|
}
|
|
203
198
|
),
|
|
204
199
|
/* @__PURE__ */ t(
|
|
205
|
-
|
|
200
|
+
V,
|
|
206
201
|
{
|
|
207
|
-
id: `uofg-pagination-skip-${
|
|
208
|
-
color:
|
|
202
|
+
id: `uofg-pagination-skip-${b}`,
|
|
203
|
+
color: m,
|
|
209
204
|
className: `uofg-pagination-go-to-button ${S()}`,
|
|
210
205
|
onClick: () => {
|
|
211
|
-
|
|
206
|
+
l(L);
|
|
212
207
|
},
|
|
213
208
|
children: "Go to page"
|
|
214
209
|
}
|
|
@@ -217,5 +212,5 @@ function re({
|
|
|
217
212
|
] });
|
|
218
213
|
}
|
|
219
214
|
export {
|
|
220
|
-
|
|
215
|
+
se as Pagination
|
|
221
216
|
};
|
package/dist/toaster.js
CHANGED
|
@@ -1,40 +1,75 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { e as
|
|
4
|
-
import { FontAwesomeIcon as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
import { jsx as o, jsxs as y } from "react/jsx-runtime";
|
|
3
|
+
import { e as T, d as v, o as N, g as C } from "./solid-CpJcQLq3.js";
|
|
4
|
+
import { FontAwesomeIcon as c } from "@fortawesome/react-fontawesome";
|
|
5
|
+
import { n as S } from "./index.browser-E4KzWirf.js";
|
|
6
|
+
import { useSyncExternalStore as A, useRef as F, useState as E, useEffect as k } from "react";
|
|
7
|
+
import { TransitionGroup as P, CSSTransition as R } from "react-transition-group";
|
|
8
|
+
import { twJoin as j } from "tailwind-merge";
|
|
9
|
+
import { tv as q } from "tailwind-variants";
|
|
10
|
+
let i = [];
|
|
11
|
+
const f = /* @__PURE__ */ new Set();
|
|
12
|
+
function d() {
|
|
13
|
+
f.forEach((e) => e());
|
|
14
|
+
}
|
|
15
|
+
function p(e) {
|
|
16
|
+
i = i.filter((t) => t.id !== e), d();
|
|
17
|
+
}
|
|
18
|
+
function a(e, t = "info", s = 3e3) {
|
|
19
|
+
const n = S();
|
|
20
|
+
i = [
|
|
21
|
+
...i,
|
|
22
|
+
{
|
|
23
|
+
id: n,
|
|
24
|
+
message: e,
|
|
25
|
+
type: t,
|
|
26
|
+
timeout: s
|
|
27
|
+
}
|
|
28
|
+
], d(), window.setTimeout(() => {
|
|
29
|
+
p(n);
|
|
30
|
+
}, s);
|
|
31
|
+
}
|
|
32
|
+
function I(e) {
|
|
33
|
+
return f.add(e), () => {
|
|
34
|
+
f.delete(e);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function g() {
|
|
38
|
+
return i;
|
|
39
|
+
}
|
|
40
|
+
function z() {
|
|
41
|
+
return A(I, g, g);
|
|
42
|
+
}
|
|
43
|
+
const G = {
|
|
44
|
+
add: a,
|
|
45
|
+
remove: p,
|
|
46
|
+
info: (e, t) => a(e, "info", t),
|
|
47
|
+
success: (e, t) => a(e, "success", t),
|
|
48
|
+
warning: (e, t) => a(e, "warning", t),
|
|
49
|
+
error: (e, t) => a(e, "error", t)
|
|
15
50
|
};
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
return /* @__PURE__ */
|
|
51
|
+
function J({ toast: e, onRemove: t, ...s }) {
|
|
52
|
+
const n = F(null);
|
|
53
|
+
return /* @__PURE__ */ o(R, { ...s, nodeRef: n, timeout: 300, classNames: "uofg-toast-transition", children: /* @__PURE__ */ o(M, { toast: e, onRemove: t, nodeRef: n }) });
|
|
19
54
|
}
|
|
20
|
-
function
|
|
55
|
+
function M({
|
|
21
56
|
toast: e,
|
|
22
|
-
onRemove:
|
|
23
|
-
nodeRef:
|
|
57
|
+
onRemove: t,
|
|
58
|
+
nodeRef: s
|
|
24
59
|
}) {
|
|
25
|
-
const [
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
let
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
60
|
+
const [n, x] = E(100);
|
|
61
|
+
k(() => {
|
|
62
|
+
const h = performance.now();
|
|
63
|
+
let m;
|
|
64
|
+
const l = (w) => {
|
|
65
|
+
const b = w - h, u = Math.max(0, 100 - b / e.timeout * 100);
|
|
66
|
+
x(u), u > 0 && (m = requestAnimationFrame(l));
|
|
32
67
|
};
|
|
33
|
-
return
|
|
34
|
-
cancelAnimationFrame(
|
|
68
|
+
return m = requestAnimationFrame(l), () => {
|
|
69
|
+
cancelAnimationFrame(m);
|
|
35
70
|
};
|
|
36
71
|
}, [e.timeout]);
|
|
37
|
-
const
|
|
72
|
+
const r = q({
|
|
38
73
|
slots: {
|
|
39
74
|
toast: "uofg-toast relative flex max-w-[50ch] gap-2 overflow-hidden p-6 text-left text-lg",
|
|
40
75
|
progress: "uofg-toast-progress absolute right-0 bottom-0 left-0 h-1 origin-left bg-current opacity-70",
|
|
@@ -58,35 +93,17 @@ function E({
|
|
|
58
93
|
}
|
|
59
94
|
}
|
|
60
95
|
})({ type: e.type });
|
|
61
|
-
return /* @__PURE__ */
|
|
62
|
-
e.type === "info" && /* @__PURE__ */
|
|
63
|
-
e.type === "success" && /* @__PURE__ */
|
|
64
|
-
e.type === "warning" && /* @__PURE__ */
|
|
65
|
-
e.type === "error" && /* @__PURE__ */
|
|
66
|
-
/* @__PURE__ */
|
|
67
|
-
/* @__PURE__ */
|
|
96
|
+
return /* @__PURE__ */ y("button", { onClick: () => t(e.id), ref: s, className: r.toast(), children: [
|
|
97
|
+
e.type === "info" && /* @__PURE__ */ o(c, { className: r.icon(), icon: T }),
|
|
98
|
+
e.type === "success" && /* @__PURE__ */ o(c, { className: r.icon(), icon: v }),
|
|
99
|
+
e.type === "warning" && /* @__PURE__ */ o(c, { className: r.icon(), icon: N }),
|
|
100
|
+
e.type === "error" && /* @__PURE__ */ o(c, { className: r.icon(), icon: C }),
|
|
101
|
+
/* @__PURE__ */ o("span", { className: r.message(), children: e.message }),
|
|
102
|
+
/* @__PURE__ */ o("span", { className: r.progress(), style: { width: `${n}%` }, "aria-hidden": "true" })
|
|
68
103
|
] });
|
|
69
104
|
}
|
|
70
|
-
function
|
|
71
|
-
const
|
|
72
|
-
i((n) => n.filter((a) => a.id !== s));
|
|
73
|
-
}, []), f = d(
|
|
74
|
-
(s, n = "info", a = 3e3) => {
|
|
75
|
-
const l = Date.now().toString();
|
|
76
|
-
console.log("Adding toast:", l, s, n, a), i((u) => [
|
|
77
|
-
...u,
|
|
78
|
-
{
|
|
79
|
-
id: l,
|
|
80
|
-
message: s,
|
|
81
|
-
type: n,
|
|
82
|
-
timeout: a
|
|
83
|
-
}
|
|
84
|
-
]), setTimeout(() => {
|
|
85
|
-
r(l);
|
|
86
|
-
}, a);
|
|
87
|
-
},
|
|
88
|
-
[r]
|
|
89
|
-
), o = F(
|
|
105
|
+
function Q() {
|
|
106
|
+
const e = z(), t = j(
|
|
90
107
|
"uofg-toaster",
|
|
91
108
|
"fixed",
|
|
92
109
|
"right-4",
|
|
@@ -98,12 +115,10 @@ function X({ children: e }) {
|
|
|
98
115
|
"items-end",
|
|
99
116
|
"gap-3"
|
|
100
117
|
);
|
|
101
|
-
return /* @__PURE__ */
|
|
102
|
-
e,
|
|
103
|
-
/* @__PURE__ */ t(A, { component: "div", className: o, children: c.map((s) => /* @__PURE__ */ t(S, { toast: s, onRemove: r }, s.id)) })
|
|
104
|
-
] });
|
|
118
|
+
return /* @__PURE__ */ o(P, { component: "div", className: t, children: e.map((s) => /* @__PURE__ */ o(J, { toast: s, onRemove: G.remove }, s.id)) });
|
|
105
119
|
}
|
|
106
120
|
export {
|
|
107
|
-
|
|
108
|
-
|
|
121
|
+
Q as Toaster,
|
|
122
|
+
G as toast,
|
|
123
|
+
z as useToaster
|
|
109
124
|
};
|