@uoguelph/react-components 1.3.0 → 1.3.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.
|
@@ -14,7 +14,7 @@ export type NumberInputProps = PropsWithChildren<{
|
|
|
14
14
|
max?: number;
|
|
15
15
|
/** Callback to call when the input changes */
|
|
16
16
|
onInput?: (value: number, e?: FormEvent<HTMLInputElement>) => void;
|
|
17
|
-
/** The
|
|
17
|
+
/** The colour of the input's control buttons */
|
|
18
18
|
color?: 'red' | 'yellow' | 'blue' | 'green';
|
|
19
19
|
} & Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'onInput'>>;
|
|
20
20
|
export declare function NumberInput({ initialValue, color, placeholder, onInput, children, className, min, max, value, ...rest }: NumberInputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -9,11 +9,17 @@ export type PaginationProps = {
|
|
|
9
9
|
defaultPage?: number;
|
|
10
10
|
/** A callback for when the user has selected an item. */
|
|
11
11
|
onChange: (page: number) => void;
|
|
12
|
-
/**
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The colour of the pagination controls
|
|
14
|
+
*
|
|
15
|
+
* @default 'yellow'
|
|
16
|
+
*/
|
|
17
|
+
color?: 'red' | 'yellow' | 'blue' | 'green';
|
|
14
18
|
/** Whether to hide the manual page selector */
|
|
15
19
|
hideInput?: boolean;
|
|
16
20
|
/** Whether to hide the list of pages */
|
|
17
21
|
hideList?: boolean;
|
|
22
|
+
/** Additional classes to apply to the component */
|
|
23
|
+
className?: string;
|
|
18
24
|
};
|
|
19
|
-
export declare function Pagination({ page, count, visible, defaultPage, onChange, color, hideInput, hideList, }: PaginationProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare function Pagination({ page, count, visible, defaultPage, onChange, color, hideInput, hideList, className, }: PaginationProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/pagination.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as f, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { j as x } from "./solid-D19hAF5t.js";
|
|
3
3
|
import { FontAwesomeIcon as u } from "@fortawesome/react-fontawesome";
|
|
4
|
-
import { useState as y, useEffect as
|
|
5
|
-
import {
|
|
4
|
+
import { useState as y, useEffect as q } from "react";
|
|
5
|
+
import { twMerge as B } from "tailwind-merge";
|
|
6
|
+
import { tv as F } from "tailwind-variants";
|
|
6
7
|
import { c as N } from "./math-utils-CnAd98v6.js";
|
|
7
|
-
import { Button as
|
|
8
|
-
import { NumberInput as
|
|
9
|
-
var
|
|
8
|
+
import { Button as G } from "./button.js";
|
|
9
|
+
import { NumberInput as S } from "./number-input.js";
|
|
10
|
+
var V = {
|
|
10
11
|
prefix: "fad",
|
|
11
12
|
iconName: "chevrons-right",
|
|
12
13
|
icon: [
|
|
@@ -16,7 +17,7 @@ var G = {
|
|
|
16
17
|
"f324",
|
|
17
18
|
["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"]
|
|
18
19
|
]
|
|
19
|
-
},
|
|
20
|
+
}, _ = {
|
|
20
21
|
prefix: "fad",
|
|
21
22
|
iconName: "chevrons-left",
|
|
22
23
|
icon: [
|
|
@@ -27,7 +28,7 @@ var G = {
|
|
|
27
28
|
["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"]
|
|
28
29
|
]
|
|
29
30
|
};
|
|
30
|
-
function
|
|
31
|
+
function Z({
|
|
31
32
|
page: d,
|
|
32
33
|
count: o,
|
|
33
34
|
visible: w,
|
|
@@ -35,28 +36,29 @@ function U({
|
|
|
35
36
|
onChange: c,
|
|
36
37
|
color: p = "yellow",
|
|
37
38
|
hideInput: $ = !1,
|
|
38
|
-
hideList: k = !1
|
|
39
|
+
hideList: k = !1,
|
|
40
|
+
className: L
|
|
39
41
|
}) {
|
|
40
|
-
const [t,
|
|
41
|
-
|
|
42
|
+
const [t, M] = y(h ?? 0), [P, j] = y(h ?? 0), C = [...Array(o).keys()], s = Math.max(Math.ceil(w), 3);
|
|
43
|
+
q(() => {
|
|
42
44
|
l(d ?? 0);
|
|
43
45
|
}, [d]);
|
|
44
|
-
const l = (
|
|
45
|
-
const v = N(
|
|
46
|
-
c == null || c(v),
|
|
47
|
-
},
|
|
46
|
+
const l = (r) => {
|
|
47
|
+
const v = N(r, 0, o - 1);
|
|
48
|
+
c == null || c(v), M(v);
|
|
49
|
+
}, m = (r) => /* @__PURE__ */ e("li", { className: "uog:contents", children: /* @__PURE__ */ e(
|
|
48
50
|
"button",
|
|
49
51
|
{
|
|
50
|
-
className: `uofg-pagination-item ${
|
|
52
|
+
className: `uofg-pagination-item ${W({ active: t === r })}`,
|
|
51
53
|
onClick: () => {
|
|
52
|
-
l(
|
|
54
|
+
l(r);
|
|
53
55
|
},
|
|
54
|
-
children:
|
|
56
|
+
children: r + 1
|
|
55
57
|
}
|
|
56
|
-
) },
|
|
57
|
-
let i, a,
|
|
58
|
-
o <=
|
|
59
|
-
const { base: I, list:
|
|
58
|
+
) }, r);
|
|
59
|
+
let i, a, g, n;
|
|
60
|
+
o <= s || o < 5 ? (i = 1, a = o - 1, g = !1, n = !1) : t < s - 1 ? (i = 1, a = s, n = !0, g = !1) : t > o - s ? (i = o - s, a = o - 1, g = !0, n = !1) : (i = t - Math.floor(s / 2), a = i + s, g = i > 1, n = a < o);
|
|
61
|
+
const { base: I, list: z, seperator: E, control: b, item: W, inputWrapper: A, goTo: R, input: T } = F({
|
|
60
62
|
slots: {
|
|
61
63
|
base: "uog:flex uog:w-full uog:flex-col uog:md:flex-row uog:gap-4 uog:items-center uog:justify-center",
|
|
62
64
|
list: "uog:flex uog:gap-4 uog:items-center uog:justify-center",
|
|
@@ -133,52 +135,52 @@ function U({
|
|
|
133
135
|
hideList: k ?? !1,
|
|
134
136
|
hideInput: $ ?? !1
|
|
135
137
|
});
|
|
136
|
-
return /* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
+
return /* @__PURE__ */ f("div", { className: `uofg-pagination ${B(I(), L)}`, children: [
|
|
139
|
+
/* @__PURE__ */ f("ul", { className: `uofg-pagination-list ${z()}`, children: [
|
|
138
140
|
/* @__PURE__ */ e("li", { className: "uog:contents", children: /* @__PURE__ */ e(
|
|
139
141
|
"button",
|
|
140
142
|
{
|
|
141
143
|
disabled: t <= 0,
|
|
142
144
|
className: `uofg-pagination-previous ${b()}`,
|
|
143
145
|
onClick: () => l(t - 1),
|
|
144
|
-
children: /* @__PURE__ */ e(u, { icon:
|
|
146
|
+
children: /* @__PURE__ */ e(u, { icon: _ })
|
|
145
147
|
}
|
|
146
148
|
) }),
|
|
147
|
-
/* @__PURE__ */ e("li", { className: "uog:contents", children:
|
|
148
|
-
n && /* @__PURE__ */ e(u, { icon: x }),
|
|
149
|
-
C.slice(i, a).map(f),
|
|
149
|
+
/* @__PURE__ */ e("li", { className: "uog:contents", children: m(0) }),
|
|
150
150
|
g && /* @__PURE__ */ e(u, { icon: x }),
|
|
151
|
-
|
|
151
|
+
C.slice(i, a).map(m),
|
|
152
|
+
n && /* @__PURE__ */ e(u, { icon: x }),
|
|
153
|
+
/* @__PURE__ */ e("li", { className: "uog:contents", children: m(o - 1) }),
|
|
152
154
|
/* @__PURE__ */ e("li", { className: "uog:contents", children: /* @__PURE__ */ e(
|
|
153
155
|
"button",
|
|
154
156
|
{
|
|
155
157
|
disabled: t >= o - 1,
|
|
156
158
|
className: `uofg-pagination-next ${b()}`,
|
|
157
159
|
onClick: () => l(t + 1),
|
|
158
|
-
children: /* @__PURE__ */ e(u, { icon:
|
|
160
|
+
children: /* @__PURE__ */ e(u, { icon: V })
|
|
159
161
|
}
|
|
160
162
|
) })
|
|
161
163
|
] }),
|
|
162
|
-
/* @__PURE__ */ e("span", { className: `uofg-pagination-seperator ${
|
|
163
|
-
/* @__PURE__ */
|
|
164
|
+
/* @__PURE__ */ e("span", { className: `uofg-pagination-seperator ${E()}` }),
|
|
165
|
+
/* @__PURE__ */ f("div", { className: `uofg-pagination-go-to-wrapper ${A()}`, children: [
|
|
164
166
|
/* @__PURE__ */ e(
|
|
165
|
-
|
|
167
|
+
S,
|
|
166
168
|
{
|
|
167
169
|
color: p,
|
|
168
170
|
min: 1,
|
|
169
171
|
max: o,
|
|
170
172
|
value: t + 1,
|
|
171
|
-
onInput: (
|
|
172
|
-
j(isNaN(
|
|
173
|
+
onInput: (r) => {
|
|
174
|
+
j(isNaN(r) ? 0 : N(r - 1, 0, o - 1));
|
|
173
175
|
},
|
|
174
|
-
className: `uofg-pagination-go-to-input ${
|
|
176
|
+
className: `uofg-pagination-go-to-input ${T()}`
|
|
175
177
|
}
|
|
176
178
|
),
|
|
177
179
|
/* @__PURE__ */ e(
|
|
178
|
-
|
|
180
|
+
G,
|
|
179
181
|
{
|
|
180
182
|
color: p,
|
|
181
|
-
className: `uofg-pagination-go-to-button ${
|
|
183
|
+
className: `uofg-pagination-go-to-button ${R()}`,
|
|
182
184
|
onClick: () => {
|
|
183
185
|
l(P);
|
|
184
186
|
},
|
|
@@ -189,5 +191,5 @@ function U({
|
|
|
189
191
|
] });
|
|
190
192
|
}
|
|
191
193
|
export {
|
|
192
|
-
|
|
194
|
+
Z as Pagination
|
|
193
195
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uoguelph/react-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "University of Guelph React Components Library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"bugs": {
|
|
85
85
|
"url": "https://github.com/ccswbs/uofg-components/issues"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "2a9a13f4af35d833daf38dfd27b1346df69f2a57"
|
|
88
88
|
}
|