@uoguelph/react-components 1.10.0 → 1.10.1-rc.0
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/radio-group/radio-group.d.ts +9 -2
- package/dist/components/radio-group/radio.d.ts +1 -3
- package/dist/radio-group.js +11 -24
- package/dist/radio.js +11 -16
- package/package.json +1 -1
- package/dist/components/radio-group/radio-context.d.ts +0 -4
- package/dist/radio-context.d.ts +0 -2
- package/dist/radio-context.js +0 -5
|
@@ -4,10 +4,17 @@ export type RadioGroupProps<T> = PropsWithChildren<{
|
|
|
4
4
|
name?: string;
|
|
5
5
|
/** Whether the radios should be displayed inline or not. */
|
|
6
6
|
inline?: boolean;
|
|
7
|
+
/** The value of the selected radio. */
|
|
8
|
+
value: T | null;
|
|
9
|
+
/**
|
|
10
|
+
* The name of the attribute to use for the `value` prop of the radio inputs. This is used for when the value is an
|
|
11
|
+
* object, and you want to compare values by a specific property.
|
|
12
|
+
*/
|
|
13
|
+
by?: string;
|
|
7
14
|
/** The callback to call when the selected radio changes. */
|
|
8
|
-
onChange
|
|
15
|
+
onChange: (value: T | null) => void;
|
|
9
16
|
}>;
|
|
10
|
-
export declare function RadioGroup<T>({ name, inline, onChange, children }: RadioGroupProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function RadioGroup<T>({ name, inline, value, onChange, children }: RadioGroupProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
11
18
|
export declare namespace RadioGroup {
|
|
12
19
|
var displayName: string;
|
|
13
20
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
export type RadioProps<T> = PropsWithChildren<{
|
|
3
|
-
/** Whether the radio is selected or not initially. */
|
|
4
|
-
selected?: boolean;
|
|
5
3
|
/** The value of the radio. */
|
|
6
4
|
value: T;
|
|
7
5
|
}>;
|
|
8
|
-
export declare function Radio<T>({
|
|
6
|
+
export declare function Radio<T>({ children, value }: RadioProps<T>): import("react/jsx-runtime").JSX.Element;
|
package/dist/radio-group.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { RadioGroup as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function R({ name: t, inline: a = !1, onChange: s, children: i }) {
|
|
9
|
-
const [l, o] = d(null), n = c(() => ({ setSelected: o }), [o]), m = f({
|
|
2
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
3
|
+
import { RadioGroup as f } from "@headlessui/react";
|
|
4
|
+
import { tv as l } from "tailwind-variants";
|
|
5
|
+
import { Radio as R } from "./radio.js";
|
|
6
|
+
function m({ name: o, inline: a = !1, value: r, onChange: i, children: s }) {
|
|
7
|
+
const e = l({
|
|
10
8
|
slots: {
|
|
11
9
|
base: "flex gap-2"
|
|
12
10
|
},
|
|
@@ -17,22 +15,11 @@ function R({ name: t, inline: a = !1, onChange: s, children: i }) {
|
|
|
17
15
|
}
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
|
-
}), { base:
|
|
21
|
-
return /* @__PURE__ */ r(
|
|
22
|
-
u,
|
|
23
|
-
{
|
|
24
|
-
name: t,
|
|
25
|
-
value: l,
|
|
26
|
-
onChange: (e) => {
|
|
27
|
-
o(e), s?.(e);
|
|
28
|
-
},
|
|
29
|
-
className: `uofg-radio-group ${p()}`,
|
|
30
|
-
children: /* @__PURE__ */ r(x.Provider, { value: n, children: i })
|
|
31
|
-
}
|
|
32
|
-
);
|
|
18
|
+
}), { base: t } = e({ inline: a });
|
|
19
|
+
return /* @__PURE__ */ p(f, { name: o, value: r, onChange: i, className: `uofg-radio-group ${t()}`, children: s });
|
|
33
20
|
}
|
|
34
|
-
|
|
21
|
+
m.displayName = "RadioGroup";
|
|
35
22
|
export {
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
R as Radio,
|
|
24
|
+
m as RadioGroup
|
|
38
25
|
};
|
package/dist/radio.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { Field as
|
|
4
|
-
import {
|
|
5
|
-
import { tv as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const i = b(h);
|
|
9
|
-
g(() => {
|
|
10
|
-
r && i?.setSelected(o);
|
|
11
|
-
}, [i, r, o]);
|
|
12
|
-
const l = x({
|
|
2
|
+
import { jsxs as d, jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { Field as t, Radio as f, Label as n } from "@headlessui/react";
|
|
4
|
+
import { Fragment as u } from "react";
|
|
5
|
+
import { tv as b } from "tailwind-variants";
|
|
6
|
+
function v({ children: i, value: o }) {
|
|
7
|
+
const a = b({
|
|
13
8
|
slots: {
|
|
14
9
|
field: "flex items-center gap-2",
|
|
15
10
|
radio: "block aspect-square rounded-full border border-blue p-1.5 focus-visible:ring-2 focus-visible:ring-blue focus-visible:ring-offset-2",
|
|
@@ -26,12 +21,12 @@ function j({ selected: r, children: a, value: o }) {
|
|
|
26
21
|
}
|
|
27
22
|
}
|
|
28
23
|
}
|
|
29
|
-
}), { field:
|
|
30
|
-
return /* @__PURE__ */
|
|
31
|
-
/* @__PURE__ */ e(
|
|
32
|
-
/* @__PURE__ */ e(
|
|
24
|
+
}), { field: l, radio: s, circle: c } = a();
|
|
25
|
+
return /* @__PURE__ */ d(t, { className: `uofg-radio-field ${l()}`, children: [
|
|
26
|
+
/* @__PURE__ */ e(f, { value: o, as: u, children: ({ checked: r }) => /* @__PURE__ */ e("span", { className: `uofg-radio ${s({ checked: r })}`, children: /* @__PURE__ */ e("span", { className: `uofg-radio-circle ${c({ checked: r })}` }) }) }),
|
|
27
|
+
/* @__PURE__ */ e(n, { className: "uofg-radio-label", children: i })
|
|
33
28
|
] });
|
|
34
29
|
}
|
|
35
30
|
export {
|
|
36
|
-
|
|
31
|
+
v as Radio
|
|
37
32
|
};
|
package/package.json
CHANGED
package/dist/radio-context.d.ts
DELETED