@uoguelph/react-components 1.4.1-rc.1 → 1.4.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.
- package/dist/pagination.js +71 -55
- package/dist/text-input.js +23 -20
- package/package.json +2 -2
package/dist/pagination.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { j as
|
|
4
|
-
import { FontAwesomeIcon as
|
|
5
|
-
import { useState as
|
|
2
|
+
import { jsxs as l, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { j as y } from "./solid-D19hAF5t.js";
|
|
4
|
+
import { FontAwesomeIcon as m } from "@fortawesome/react-fontawesome";
|
|
5
|
+
import { useState as x, useEffect as q } from "react";
|
|
6
6
|
import { twMerge as B } from "tailwind-merge";
|
|
7
7
|
import { tv as F } from "tailwind-variants";
|
|
8
|
-
import { c as
|
|
8
|
+
import { c as N } from "./math-utils-CnAd98v6.js";
|
|
9
9
|
import { Button as G } from "./button.js";
|
|
10
10
|
import { NumberInput as S } from "./number-input.js";
|
|
11
11
|
var V = {
|
|
@@ -30,37 +30,46 @@ var V = {
|
|
|
30
30
|
]
|
|
31
31
|
};
|
|
32
32
|
function Z({
|
|
33
|
-
page:
|
|
33
|
+
page: h,
|
|
34
34
|
count: e,
|
|
35
|
-
visible:
|
|
35
|
+
visible: w,
|
|
36
36
|
defaultPage: b,
|
|
37
37
|
onChange: f,
|
|
38
|
-
color:
|
|
39
|
-
hideInput:
|
|
40
|
-
hideList:
|
|
41
|
-
className:
|
|
38
|
+
color: u = "yellow",
|
|
39
|
+
hideInput: P = !1,
|
|
40
|
+
hideList: $ = !1,
|
|
41
|
+
className: k
|
|
42
42
|
}) {
|
|
43
|
-
const [r,
|
|
43
|
+
const [r, C] = x(b ?? 0), [I, L] = x(b ?? 0), M = [...Array(e).keys()], i = Math.max(Math.ceil(w), 3);
|
|
44
44
|
q(() => {
|
|
45
|
-
|
|
46
|
-
}, [
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
f == null || f(
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
n(h ?? 0);
|
|
46
|
+
}, [h]);
|
|
47
|
+
const n = (s) => {
|
|
48
|
+
const g = N(s, 0, e - 1);
|
|
49
|
+
f == null || f(g), C(g);
|
|
50
|
+
}, d = (s) => {
|
|
51
|
+
const g = r === s;
|
|
52
|
+
return /* @__PURE__ */ l(
|
|
53
|
+
"button",
|
|
54
|
+
{
|
|
55
|
+
className: `uofg-pagination-item ${A({ active: g })}`,
|
|
56
|
+
onClick: () => {
|
|
57
|
+
n(s);
|
|
58
|
+
},
|
|
59
|
+
children: [
|
|
60
|
+
/* @__PURE__ */ t("span", { className: "sr-only", children: "Page" }),
|
|
61
|
+
" ",
|
|
62
|
+
s + 1,
|
|
63
|
+
" ",
|
|
64
|
+
g ? /* @__PURE__ */ t("span", { className: "sr-only", children: "(Current Page)" }) : ""
|
|
65
|
+
]
|
|
56
66
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const { base: I, list: z, seperator: E, control: h, item: W, inputWrapper: A, goTo: R, input: T } = F({
|
|
67
|
+
s
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
let o, a, c, p;
|
|
71
|
+
e <= i || e < 5 ? (o = 1, a = e - 1, c = !1, p = !1) : r < i - 1 ? (o = 1, a = i, p = !0, c = !1) : r > e - i ? (o = e - i, a = e - 1, c = !0, p = !1) : (o = r - Math.floor(i / 2), a = o + i, c = o > 1, p = a < e);
|
|
72
|
+
const { base: j, list: z, seperator: E, control: v, item: A, inputWrapper: W, goTo: R, input: T } = F({
|
|
64
73
|
slots: {
|
|
65
74
|
base: "flex w-full flex-col items-center justify-center gap-4 md:flex-row",
|
|
66
75
|
list: "flex items-center justify-center gap-4",
|
|
@@ -133,58 +142,65 @@ function Z({
|
|
|
133
142
|
}
|
|
134
143
|
]
|
|
135
144
|
})({
|
|
136
|
-
color:
|
|
137
|
-
hideList:
|
|
138
|
-
hideInput:
|
|
145
|
+
color: u ?? "yellow",
|
|
146
|
+
hideList: $ ?? !1,
|
|
147
|
+
hideInput: P ?? !1
|
|
139
148
|
});
|
|
140
|
-
return /* @__PURE__ */
|
|
141
|
-
/* @__PURE__ */
|
|
142
|
-
/* @__PURE__ */
|
|
149
|
+
return /* @__PURE__ */ l("div", { className: `uofg-pagination ${B(j(), k)}`, children: [
|
|
150
|
+
/* @__PURE__ */ l("div", { className: `uofg-pagination-list ${z()}`, children: [
|
|
151
|
+
/* @__PURE__ */ l(
|
|
143
152
|
"button",
|
|
144
153
|
{
|
|
145
154
|
disabled: r <= 0,
|
|
146
|
-
className: `uofg-pagination-previous ${
|
|
147
|
-
onClick: () =>
|
|
148
|
-
children:
|
|
155
|
+
className: `uofg-pagination-previous ${v()}`,
|
|
156
|
+
onClick: () => n(r - 1),
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ t(m, { icon: _ }),
|
|
159
|
+
/* @__PURE__ */ t("span", { className: "sr-only", children: "Previous Page" })
|
|
160
|
+
]
|
|
149
161
|
}
|
|
150
162
|
),
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
/* @__PURE__ */
|
|
163
|
+
d(0),
|
|
164
|
+
c && /* @__PURE__ */ t(m, { icon: y }),
|
|
165
|
+
M.slice(o, a).map(d),
|
|
166
|
+
p && /* @__PURE__ */ t(m, { icon: y }),
|
|
167
|
+
d(e - 1),
|
|
168
|
+
/* @__PURE__ */ l(
|
|
157
169
|
"button",
|
|
158
170
|
{
|
|
159
171
|
disabled: r >= e - 1,
|
|
160
|
-
className: `uofg-pagination-next ${
|
|
161
|
-
onClick: () =>
|
|
162
|
-
children:
|
|
172
|
+
className: `uofg-pagination-next ${v()}`,
|
|
173
|
+
onClick: () => n(r + 1),
|
|
174
|
+
children: [
|
|
175
|
+
/* @__PURE__ */ t(m, { icon: V }),
|
|
176
|
+
/* @__PURE__ */ t("span", { className: "sr-only", children: "Next Page" })
|
|
177
|
+
]
|
|
163
178
|
}
|
|
164
179
|
)
|
|
165
180
|
] }),
|
|
166
181
|
/* @__PURE__ */ t("span", { className: `uofg-pagination-seperator ${E()}` }),
|
|
167
|
-
/* @__PURE__ */
|
|
182
|
+
/* @__PURE__ */ l("div", { className: `uofg-pagination-go-to-wrapper ${W()}`, children: [
|
|
168
183
|
/* @__PURE__ */ t(
|
|
169
184
|
S,
|
|
170
185
|
{
|
|
171
|
-
color:
|
|
186
|
+
color: u,
|
|
172
187
|
min: 1,
|
|
173
188
|
max: e,
|
|
174
189
|
value: r + 1,
|
|
175
|
-
onInput: (
|
|
176
|
-
|
|
190
|
+
onInput: (s) => {
|
|
191
|
+
L(isNaN(s) ? 0 : N(s - 1, 0, e - 1));
|
|
177
192
|
},
|
|
178
|
-
className: `uofg-pagination-go-to-input ${T()}
|
|
193
|
+
className: `uofg-pagination-go-to-input ${T()}`,
|
|
194
|
+
children: /* @__PURE__ */ t("span", { className: "sr-only", children: "Input Page Number" })
|
|
179
195
|
}
|
|
180
196
|
),
|
|
181
197
|
/* @__PURE__ */ t(
|
|
182
198
|
G,
|
|
183
199
|
{
|
|
184
|
-
color:
|
|
200
|
+
color: u,
|
|
185
201
|
className: `uofg-pagination-go-to-button ${R()}`,
|
|
186
202
|
onClick: () => {
|
|
187
|
-
|
|
203
|
+
n(I);
|
|
188
204
|
},
|
|
189
205
|
children: "Go to page"
|
|
190
206
|
}
|
package/dist/text-input.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
2
|
+
import { jsxs as l, jsx as o } from "react/jsx-runtime";
|
|
3
3
|
import { h as y } from "./regular-DmWV6rTj.js";
|
|
4
4
|
import { FontAwesomeIcon as N } from "@fortawesome/react-fontawesome";
|
|
5
|
-
import { Field as B, Label as
|
|
6
|
-
import { useState as
|
|
5
|
+
import { Field as B, Label as C, Input as E } from "@headlessui/react";
|
|
6
|
+
import { useState as $, useRef as j, useEffect as I } from "react";
|
|
7
7
|
import { twMerge as k } from "tailwind-merge";
|
|
8
8
|
import { tv as F } from "tailwind-variants";
|
|
9
9
|
function P({
|
|
10
|
-
initialValue:
|
|
11
|
-
type:
|
|
10
|
+
initialValue: c = "",
|
|
11
|
+
type: p = "text",
|
|
12
12
|
placeholder: f = "",
|
|
13
13
|
onInput: i,
|
|
14
|
-
children:
|
|
14
|
+
children: s,
|
|
15
15
|
className: m,
|
|
16
16
|
hideClear: x,
|
|
17
|
-
value:
|
|
17
|
+
value: u,
|
|
18
18
|
...b
|
|
19
19
|
}) {
|
|
20
|
-
const [n,
|
|
20
|
+
const [n, a] = $(c), e = j(null);
|
|
21
21
|
I(() => {
|
|
22
|
-
|
|
23
|
-
}, [
|
|
22
|
+
a(u ?? "");
|
|
23
|
+
}, [u]);
|
|
24
24
|
const d = F({
|
|
25
25
|
slots: {
|
|
26
26
|
base: "flex flex-col gap-0.5",
|
|
@@ -40,26 +40,26 @@ function P({
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
}), { base: g, wrapper:
|
|
44
|
-
return /* @__PURE__ */
|
|
45
|
-
|
|
46
|
-
/* @__PURE__ */
|
|
43
|
+
}), { base: g, wrapper: h, input: w, clearButton: v } = d({ empty: (n == null ? void 0 : n.length) === 0 });
|
|
44
|
+
return /* @__PURE__ */ l(B, { className: `uofg-text-input-field ${k(g(), m)}`, children: [
|
|
45
|
+
s && /* @__PURE__ */ o(C, { className: "uofg-text-input-label", children: s }),
|
|
46
|
+
/* @__PURE__ */ l("div", { className: `uofg-text-input-wrapper ${h()}`, children: [
|
|
47
47
|
/* @__PURE__ */ o(
|
|
48
|
-
|
|
48
|
+
E,
|
|
49
49
|
{
|
|
50
50
|
...b,
|
|
51
51
|
ref: e,
|
|
52
52
|
value: n,
|
|
53
|
-
type:
|
|
53
|
+
type: p,
|
|
54
54
|
placeholder: f,
|
|
55
55
|
onInput: (t) => {
|
|
56
56
|
var r;
|
|
57
|
-
|
|
57
|
+
a((r = t == null ? void 0 : t.target) == null ? void 0 : r.value), i == null || i(t);
|
|
58
58
|
},
|
|
59
|
-
className: `uofg-text-input ${
|
|
59
|
+
className: `uofg-text-input ${w()}`
|
|
60
60
|
}
|
|
61
61
|
),
|
|
62
|
-
/* @__PURE__ */
|
|
62
|
+
/* @__PURE__ */ l(
|
|
63
63
|
"button",
|
|
64
64
|
{
|
|
65
65
|
className: `uofg-text-input-clear-button ${v({ hide: x })}`,
|
|
@@ -69,7 +69,10 @@ function P({
|
|
|
69
69
|
const t = (r = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value")) == null ? void 0 : r.set;
|
|
70
70
|
t == null || t.call(e.current, ""), e.current.dispatchEvent(new Event("input", { bubbles: !0 })), e.current.focus();
|
|
71
71
|
},
|
|
72
|
-
children:
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ o(N, { icon: y }),
|
|
74
|
+
/* @__PURE__ */ o("span", { className: "sr-only", children: "Clear text" })
|
|
75
|
+
]
|
|
73
76
|
}
|
|
74
77
|
)
|
|
75
78
|
] })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uoguelph/react-components",
|
|
3
|
-
"version": "1.4.1
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "University of Guelph React Components Library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"bugs": {
|
|
77
77
|
"url": "https://github.com/ccswbs/uofg-components/issues"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "451236eee706208e21e88751876f83b7918e11d9"
|
|
80
80
|
}
|