@uoguelph/react-components 1.3.0 → 1.3.2
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 m, jsx as
|
|
1
|
+
import { jsxs as m, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { j as x } from "./solid-D19hAF5t.js";
|
|
3
|
-
import { FontAwesomeIcon as
|
|
4
|
-
import { useState as y, useEffect as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
3
|
+
import { FontAwesomeIcon as n } from "@fortawesome/react-fontawesome";
|
|
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";
|
|
7
|
+
import { c as w } from "./math-utils-CnAd98v6.js";
|
|
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,36 +28,37 @@ 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
|
-
count:
|
|
33
|
-
visible:
|
|
33
|
+
count: e,
|
|
34
|
+
visible: N,
|
|
34
35
|
defaultPage: h,
|
|
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
|
-
|
|
42
|
+
const [t, M] = y(h ?? 0), [P, j] = y(h ?? 0), C = [...Array(e).keys()], i = Math.max(Math.ceil(N), 3);
|
|
43
|
+
q(() => {
|
|
44
|
+
g(d ?? 0);
|
|
43
45
|
}, [d]);
|
|
44
|
-
const
|
|
45
|
-
const v =
|
|
46
|
-
c == null || c(v),
|
|
47
|
-
}, f = (
|
|
46
|
+
const g = (r) => {
|
|
47
|
+
const v = w(r, 0, e - 1);
|
|
48
|
+
c == null || c(v), M(v);
|
|
49
|
+
}, f = (r) => /* @__PURE__ */ o("li", { className: "uog:contents", children: /* @__PURE__ */ o(
|
|
48
50
|
"button",
|
|
49
51
|
{
|
|
50
|
-
className: `uofg-pagination-item ${
|
|
52
|
+
className: `uofg-pagination-item ${W({ active: t === r })}`,
|
|
51
53
|
onClick: () => {
|
|
52
|
-
|
|
54
|
+
g(r);
|
|
53
55
|
},
|
|
54
|
-
children:
|
|
56
|
+
children: r + 1
|
|
55
57
|
}
|
|
56
|
-
) },
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
const { base: I, list:
|
|
58
|
+
) }, r);
|
|
59
|
+
let s, a, l, u;
|
|
60
|
+
e <= i || e < 5 ? (s = 1, a = e - 1, l = !1, u = !1) : t < i - 1 ? (s = 1, a = i, u = !0, l = !1) : t > e - i ? (s = e - i, a = e - 1, l = !0, u = !1) : (s = t - Math.floor(i / 2), a = s + i, l = s > 1, u = a < e);
|
|
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,54 +135,54 @@ function U({
|
|
|
133
135
|
hideList: k ?? !1,
|
|
134
136
|
hideInput: $ ?? !1
|
|
135
137
|
});
|
|
136
|
-
return /* @__PURE__ */ m("div", { className: `uofg-pagination ${I()}`, children: [
|
|
137
|
-
/* @__PURE__ */ m("ul", { className: `uofg-pagination-list ${
|
|
138
|
-
/* @__PURE__ */
|
|
138
|
+
return /* @__PURE__ */ m("div", { className: `uofg-pagination ${B(I(), L)}`, children: [
|
|
139
|
+
/* @__PURE__ */ m("ul", { className: `uofg-pagination-list ${z()}`, children: [
|
|
140
|
+
/* @__PURE__ */ o("li", { className: "uog:contents", children: /* @__PURE__ */ o(
|
|
139
141
|
"button",
|
|
140
142
|
{
|
|
141
143
|
disabled: t <= 0,
|
|
142
144
|
className: `uofg-pagination-previous ${b()}`,
|
|
143
|
-
onClick: () =>
|
|
144
|
-
children: /* @__PURE__ */
|
|
145
|
+
onClick: () => g(t - 1),
|
|
146
|
+
children: /* @__PURE__ */ o(n, { icon: _ })
|
|
145
147
|
}
|
|
146
148
|
) }),
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
C.slice(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
/* @__PURE__ */
|
|
149
|
+
f(0),
|
|
150
|
+
l && /* @__PURE__ */ o(n, { icon: x }),
|
|
151
|
+
C.slice(s, a).map(f),
|
|
152
|
+
u && /* @__PURE__ */ o(n, { icon: x }),
|
|
153
|
+
f(e - 1),
|
|
154
|
+
/* @__PURE__ */ o("li", { className: "uog:contents", children: /* @__PURE__ */ o(
|
|
153
155
|
"button",
|
|
154
156
|
{
|
|
155
|
-
disabled: t >=
|
|
157
|
+
disabled: t >= e - 1,
|
|
156
158
|
className: `uofg-pagination-next ${b()}`,
|
|
157
|
-
onClick: () =>
|
|
158
|
-
children: /* @__PURE__ */
|
|
159
|
+
onClick: () => g(t + 1),
|
|
160
|
+
children: /* @__PURE__ */ o(n, { icon: V })
|
|
159
161
|
}
|
|
160
162
|
) })
|
|
161
163
|
] }),
|
|
162
|
-
/* @__PURE__ */
|
|
163
|
-
/* @__PURE__ */ m("div", { className: `uofg-pagination-go-to-wrapper ${
|
|
164
|
-
/* @__PURE__ */
|
|
165
|
-
|
|
164
|
+
/* @__PURE__ */ o("span", { className: `uofg-pagination-seperator ${E()}` }),
|
|
165
|
+
/* @__PURE__ */ m("div", { className: `uofg-pagination-go-to-wrapper ${A()}`, children: [
|
|
166
|
+
/* @__PURE__ */ o(
|
|
167
|
+
S,
|
|
166
168
|
{
|
|
167
169
|
color: p,
|
|
168
170
|
min: 1,
|
|
169
|
-
max:
|
|
171
|
+
max: e,
|
|
170
172
|
value: t + 1,
|
|
171
|
-
onInput: (
|
|
172
|
-
j(isNaN(
|
|
173
|
+
onInput: (r) => {
|
|
174
|
+
j(isNaN(r) ? 0 : w(r - 1, 0, e - 1));
|
|
173
175
|
},
|
|
174
|
-
className: `uofg-pagination-go-to-input ${
|
|
176
|
+
className: `uofg-pagination-go-to-input ${T()}`
|
|
175
177
|
}
|
|
176
178
|
),
|
|
177
|
-
/* @__PURE__ */
|
|
178
|
-
|
|
179
|
+
/* @__PURE__ */ o(
|
|
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
|
+
g(P);
|
|
184
186
|
},
|
|
185
187
|
children: "Go to page"
|
|
186
188
|
}
|
|
@@ -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.2",
|
|
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": "e5f51f54bd5588ef083fd48aa5931f6c405cb06e"
|
|
88
88
|
}
|