@pibit.ai/cure-design-system 0.6.7 → 0.6.8
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +270 -266
- package/dist/patterns/table/toolbar/GroupByDropdown.js +1 -1
- package/dist/patterns/table/toolbar/ToolbarRadio.d.ts +5 -17
- package/dist/patterns/table/toolbar/ToolbarRadio.d.ts.map +1 -1
- package/dist/primitives/radio/index.d.ts +2 -0
- package/dist/primitives/radio/index.d.ts.map +1 -0
- package/dist/primitives/radio/radio.d.ts +61 -0
- package/dist/primitives/radio/radio.d.ts.map +1 -0
- package/dist/primitives/radio/radio.js +75 -0
- package/dist/styles/components.css +1 -1
- package/package.json +1 -1
- package/dist/patterns/table/toolbar/ToolbarRadio.js +0 -64
|
@@ -3,9 +3,9 @@ import { useState as p, useEffect as O, useMemo as y } from "react";
|
|
|
3
3
|
import { cx as R } from "../../../utils/cn.js";
|
|
4
4
|
import { TOOLBAR_ICONS as _ } from "../toolbar-icons.js";
|
|
5
5
|
import { resolveColumnLabel as c } from "./tableToolbarHelpers.js";
|
|
6
|
-
import { RadioGroup as A, RadioButton as S } from "./ToolbarRadio.js";
|
|
7
6
|
import { Dropdown as v } from "../../../primitives/dropdown/dropdown.js";
|
|
8
7
|
import { Button as m } from "../../../primitives/button/button.js";
|
|
8
|
+
import { RadioGroup as A, RadioButton as S } from "../../../primitives/radio/radio.js";
|
|
9
9
|
const E = /* @__PURE__ */ new Set([
|
|
10
10
|
"string",
|
|
11
11
|
"number",
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
interface RadioButtonProps extends AriaRadioProps {
|
|
7
|
-
size?: "sm" | "md";
|
|
8
|
-
label?: ReactNode;
|
|
9
|
-
ref?: Ref<HTMLLabelElement>;
|
|
10
|
-
}
|
|
11
|
-
export declare const RadioButton: FC<RadioButtonProps>;
|
|
12
|
-
interface RadioGroupProps extends RadioGroupContextType, AriaRadioGroupProps {
|
|
13
|
-
children: ReactNode;
|
|
14
|
-
className?: string;
|
|
15
|
-
}
|
|
16
|
-
export declare const RadioGroup: FC<RadioGroupProps>;
|
|
17
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Internal alias kept so code and tests that import `./ToolbarRadio` keep working.
|
|
3
|
+
* Import from `@/primitives/radio` instead.
|
|
4
|
+
*/
|
|
5
|
+
export { RadioButton, RadioGroup } from '../../../primitives/radio';
|
|
18
6
|
//# sourceMappingURL=ToolbarRadio.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarRadio.d.ts","sourceRoot":"","sources":["../../../../src/patterns/table/toolbar/ToolbarRadio.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ToolbarRadio.d.ts","sourceRoot":"","sources":["../../../../src/patterns/table/toolbar/ToolbarRadio.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/primitives/radio/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,UAAU,EACV,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,SAAS,GACf,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ReactNode, Ref } from 'react';
|
|
2
|
+
import { RadioGroupProps as AriaRadioGroupProps, RadioProps as AriaRadioProps } from 'react-aria-components';
|
|
3
|
+
export type RadioSize = "xs" | "sm" | "md";
|
|
4
|
+
interface RadioGroupContextType {
|
|
5
|
+
size?: RadioSize;
|
|
6
|
+
}
|
|
7
|
+
export interface RadioButtonBaseProps {
|
|
8
|
+
/** `xs` and `sm` are a 16px circle, `md` is 20px. */
|
|
9
|
+
size?: RadioSize;
|
|
10
|
+
className?: string;
|
|
11
|
+
isFocusVisible?: boolean;
|
|
12
|
+
isSelected?: boolean;
|
|
13
|
+
isDisabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The circle on its own, for rows that handle selection themselves (menu rows, option cards
|
|
17
|
+
* built from buttons). Frozen to platform-ui's `base/radio-buttons`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const RadioButtonBase: {
|
|
20
|
+
({ className, isFocusVisible, isSelected, isDisabled, size }: RadioButtonBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
displayName: string;
|
|
22
|
+
};
|
|
23
|
+
export interface RadioButtonProps extends AriaRadioProps {
|
|
24
|
+
/** Overrides the group's `size` for this radio. */
|
|
25
|
+
size?: RadioSize;
|
|
26
|
+
label?: ReactNode;
|
|
27
|
+
/** Secondary text under the label. */
|
|
28
|
+
hint?: ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Replaces the built-in circle and label, for option cards that lay out their own content.
|
|
31
|
+
* Render `RadioButtonBase` inside it to keep the circle. The option stays a React Aria radio.
|
|
32
|
+
*/
|
|
33
|
+
children?: AriaRadioProps["children"];
|
|
34
|
+
ref?: Ref<HTMLLabelElement>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A radio option built on React Aria. Use it inside a `RadioGroup`.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* <RadioGroup aria-label="Format" value={format} onChange={setFormat}>
|
|
41
|
+
* <RadioButton value="csv" label="CSV" hint="Opens in any spreadsheet" />
|
|
42
|
+
* <RadioButton value="xlsx" label="Excel" />
|
|
43
|
+
* </RadioGroup>
|
|
44
|
+
*/
|
|
45
|
+
export declare const RadioButton: {
|
|
46
|
+
({ label, hint, className, size, children, ...ariaRadioProps }: RadioButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
displayName: string;
|
|
48
|
+
};
|
|
49
|
+
export interface RadioGroupProps extends RadioGroupContextType, AriaRadioGroupProps {
|
|
50
|
+
/** Size of every radio in the group, unless a radio sets its own. */
|
|
51
|
+
size?: RadioSize;
|
|
52
|
+
children: ReactNode;
|
|
53
|
+
className?: string;
|
|
54
|
+
}
|
|
55
|
+
/** A React Aria radio group. Stacks its options in a column; pass `className="flex-row"` for a row. */
|
|
56
|
+
export declare const RadioGroup: {
|
|
57
|
+
({ children, className, size, ...props }: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
58
|
+
displayName: string;
|
|
59
|
+
};
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=radio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../../src/primitives/radio/radio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAGL,KAAK,eAAe,IAAI,mBAAmB,EAC3C,KAAK,UAAU,IAAI,cAAc,EAElC,MAAM,uBAAuB,CAAC;AAG/B,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C,UAAU,qBAAqB;IAC7B,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAID,MAAM,WAAW,oBAAoB;IACnC,qDAAqD;IACrD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe;kEAAwE,oBAAoB;;CAoBvH,CAAC;AASF,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD,mDAAmD;IACnD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,sCAAsC;IACtC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IACtC,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW;oEAAmE,gBAAgB;;CAmD1G,CAAC;AAGF,MAAM,WAAW,eAAgB,SAAQ,qBAAqB,EAAE,mBAAmB;IACjF,qEAAqE;IACrE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,uGAAuG;AACvG,eAAO,MAAM,UAAU;8CAAoD,eAAe;;CAMzF,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx as i, jsxs as u, Fragment as h } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as N, useContext as v, useId as R } from "react";
|
|
3
|
+
import { RadioGroup as z, Radio as B, Text as w } from "react-aria-components";
|
|
4
|
+
import { cx as a } from "../../utils/cn.js";
|
|
5
|
+
const x = N(null), f = ({ className: e, isFocusVisible: t, isSelected: o, isDisabled: r, size: n = "sm" }) => /* @__PURE__ */ i(
|
|
6
|
+
"div",
|
|
7
|
+
{
|
|
8
|
+
className: a(
|
|
9
|
+
"flex size-4 min-h-4 min-w-4 cursor-pointer appearance-none items-center justify-center rounded-full bg-primary ring-1 ring-primary ring-inset",
|
|
10
|
+
n === "md" && "size-5 min-h-5 min-w-5",
|
|
11
|
+
o && !r && "bg-brand-solid ring-bg-brand-solid",
|
|
12
|
+
r && "cursor-not-allowed border-disabled bg-disabled_subtle",
|
|
13
|
+
t && "outline-2 outline-offset-2 outline-focus-ring",
|
|
14
|
+
e
|
|
15
|
+
),
|
|
16
|
+
children: /* @__PURE__ */ i(
|
|
17
|
+
"div",
|
|
18
|
+
{
|
|
19
|
+
className: a(
|
|
20
|
+
"size-1.5 rounded-full bg-fg-white opacity-0 transition-inherit-all",
|
|
21
|
+
n === "md" && "size-2",
|
|
22
|
+
r && "bg-fg-disabled_subtle",
|
|
23
|
+
o && "opacity-100"
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
f.displayName = "RadioButtonBase";
|
|
30
|
+
const d = {
|
|
31
|
+
xs: { root: "gap-2", textWrapper: "", label: "text-xs font-medium", hint: "text-xs" },
|
|
32
|
+
sm: { root: "gap-2", textWrapper: "", label: "text-sm font-medium", hint: "text-sm" },
|
|
33
|
+
md: { root: "gap-3", textWrapper: "gap-0.5", label: "text-md font-medium", hint: "text-md" }
|
|
34
|
+
}, G = ({ label: e, hint: t, className: o, size: r, children: n, ...m }) => {
|
|
35
|
+
const c = v(x), s = r ?? (c == null ? void 0 : c.size) ?? "sm", p = R(), b = e && t && !m["aria-label"] && !m["aria-labelledby"] ? p : void 0;
|
|
36
|
+
return /* @__PURE__ */ i(
|
|
37
|
+
B,
|
|
38
|
+
{
|
|
39
|
+
"aria-labelledby": b,
|
|
40
|
+
...m,
|
|
41
|
+
className: (l) => a(
|
|
42
|
+
// `relative` keeps React Aria's hidden input inside the label, so focusing it never scrolls the page.
|
|
43
|
+
"relative flex items-start",
|
|
44
|
+
l.isDisabled && "cursor-not-allowed",
|
|
45
|
+
d[s].root,
|
|
46
|
+
typeof o == "function" ? o(l) : o
|
|
47
|
+
),
|
|
48
|
+
children: n ?? (({ isSelected: l, isDisabled: g, isFocusVisible: y }) => /* @__PURE__ */ u(h, { children: [
|
|
49
|
+
/* @__PURE__ */ i(
|
|
50
|
+
f,
|
|
51
|
+
{
|
|
52
|
+
size: s,
|
|
53
|
+
isSelected: l,
|
|
54
|
+
isDisabled: g,
|
|
55
|
+
isFocusVisible: y,
|
|
56
|
+
className: e || t ? "mt-0.5" : ""
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
(e || t) && /* @__PURE__ */ u("div", { className: a("inline-flex flex-col", d[s].textWrapper), children: [
|
|
60
|
+
e && /* @__PURE__ */ i("p", { id: p, className: a("text-secondary select-none", d[s].label), children: e }),
|
|
61
|
+
t && // The description slot sets the input's aria-describedby, so the hint reads as a description.
|
|
62
|
+
/* @__PURE__ */ i(w, { slot: "description", className: a("text-tertiary", d[s].hint), children: t })
|
|
63
|
+
] })
|
|
64
|
+
] }))
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
G.displayName = "RadioButton";
|
|
69
|
+
const W = ({ children: e, className: t, size: o = "sm", ...r }) => /* @__PURE__ */ i(x.Provider, { value: { size: o }, children: /* @__PURE__ */ i(z, { ...r, className: a("flex flex-col gap-4", t), children: e }) });
|
|
70
|
+
W.displayName = "RadioGroup";
|
|
71
|
+
export {
|
|
72
|
+
G as RadioButton,
|
|
73
|
+
f as RadioButtonBase,
|
|
74
|
+
W as RadioGroup
|
|
75
|
+
};
|