@coopdigital/react 1.20.0 → 1.21.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HTMLAttributes, JSX, Ref } from "react";
|
|
1
|
+
import { HTMLAttributes, JSX, Ref, SVGAttributes } from "react";
|
|
2
2
|
//#region src/components/Squircle/Squircle.d.ts
|
|
3
3
|
interface SquircleProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
4
|
/** **(Optional)** Main content inside the component. It can be any valid JSX or string. */
|
|
@@ -7,14 +7,18 @@ interface SquircleProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
7
7
|
className?: string;
|
|
8
8
|
/** **(Optional)** Specify a custom React ref for this component. */
|
|
9
9
|
ref?: Ref<HTMLDivElement>;
|
|
10
|
+
}
|
|
11
|
+
interface SquircleSvgProps extends SVGAttributes<SVGElement> {
|
|
10
12
|
/** **(Optional)** Specify the Squircle size. */
|
|
11
|
-
size?:
|
|
13
|
+
size?: string | number;
|
|
12
14
|
}
|
|
13
15
|
declare const Squircle: {
|
|
14
|
-
({ children, className, ref,
|
|
16
|
+
({ children, className, ref, ...props }: SquircleProps): JSX.Element;
|
|
17
|
+
Svg: ({ size, ...props }: SquircleSvgProps) => JSX.Element;
|
|
18
|
+
Text: ({ children, className, ...props }: HTMLAttributes<HTMLDivElement>) => JSX.Element;
|
|
15
19
|
slot: {
|
|
16
20
|
name: string;
|
|
17
21
|
};
|
|
18
22
|
};
|
|
19
23
|
//#endregion
|
|
20
|
-
export { Squircle, Squircle as default, SquircleProps };
|
|
24
|
+
export { Squircle, Squircle as default, SquircleProps, SquircleSvgProps };
|
|
@@ -1,19 +1,49 @@
|
|
|
1
|
-
import { hasUserBg } from "../../utils/index.js";
|
|
2
1
|
import clsx from "clsx";
|
|
3
2
|
import { jsx } from "react/jsx-runtime";
|
|
4
3
|
//#region src/components/Squircle/Squircle.tsx
|
|
5
|
-
const Squircle = ({ children, className, ref,
|
|
4
|
+
const Squircle = ({ children, className, ref, ...props }) => {
|
|
6
5
|
const componentProps = {
|
|
7
|
-
className: clsx("coop-squircle",
|
|
8
|
-
"data-size": size.length && size !== "md" ? size : void 0,
|
|
6
|
+
className: clsx("coop-squircle", className),
|
|
9
7
|
...props
|
|
10
8
|
};
|
|
11
9
|
return /* @__PURE__ */ jsx("figure", {
|
|
12
10
|
...componentProps,
|
|
13
11
|
ref,
|
|
14
|
-
children
|
|
12
|
+
children
|
|
15
13
|
});
|
|
16
14
|
};
|
|
15
|
+
const sizeMap = {
|
|
16
|
+
sm: "32",
|
|
17
|
+
md: "64",
|
|
18
|
+
lg: "96"
|
|
19
|
+
};
|
|
20
|
+
const SquircleSvg = ({ size, ...props }) => {
|
|
21
|
+
const safeSize = sizeMap[size] ?? size ?? "64";
|
|
22
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
23
|
+
height: safeSize,
|
|
24
|
+
width: safeSize,
|
|
25
|
+
...props,
|
|
26
|
+
"aria-hidden": "true",
|
|
27
|
+
viewBox: "0 0 64 64",
|
|
28
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
29
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
30
|
+
d: "M0,32 C0,10.56,10.56,0,32,0 S64,10.56,64,32 S53.44,64,32,64 S0,53.44,0,32",
|
|
31
|
+
vectorEffect: "non-scaling-stroke"
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
const SquircleText = ({ children, className, ...props }) => {
|
|
36
|
+
const componentProps = {
|
|
37
|
+
className,
|
|
38
|
+
...props
|
|
39
|
+
};
|
|
40
|
+
return /* @__PURE__ */ jsx("figcaption", {
|
|
41
|
+
...componentProps,
|
|
42
|
+
children
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
Squircle.Svg = SquircleSvg;
|
|
46
|
+
Squircle.Text = SquircleText;
|
|
17
47
|
Squircle.slot = { name: "Squircle" };
|
|
18
48
|
//#endregion
|
|
19
49
|
export { Squircle, Squircle as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Squircle, SquircleProps } from "./Squircle.js";
|
|
2
|
-
export { Squircle, Squircle as default, SquircleProps };
|
|
1
|
+
import { Squircle, SquircleProps, SquircleSvgProps } from "./Squircle.js";
|
|
2
|
+
export { Squircle, Squircle as default, SquircleProps, SquircleSvgProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -25,8 +25,8 @@ import { Searchbox, SearchboxButton, SearchboxInput, SearchboxProps } from "./co
|
|
|
25
25
|
import { Select, SelectOption, SelectOptionGroup, SelectProps } from "./components/Select/Select.js";
|
|
26
26
|
import { Signpost, SignpostProps } from "./components/Signpost/Signpost.js";
|
|
27
27
|
import { SkipNav, SkipNavProps } from "./components/SkipNav/SkipNav.js";
|
|
28
|
-
import { Squircle, SquircleProps } from "./components/Squircle/Squircle.js";
|
|
28
|
+
import { Squircle, SquircleProps, SquircleSvgProps } from "./components/Squircle/Squircle.js";
|
|
29
29
|
import { Tag, TagProps } from "./components/Tag/Tag.js";
|
|
30
30
|
import { Textarea, TextareaProps } from "./components/Textarea/Textarea.js";
|
|
31
31
|
import { ValidationSummary, ValidationSummaryErrors, ValidationSummaryHeading, ValidationSummaryPrompt, ValidationSummaryProps } from "./components/ValidationSummary/ValidationSummary.js";
|
|
32
|
-
export { AlertBanner, AlertBannerHeading, AlertBannerProps, Author, AuthorProps, Button, ButtonProps, Card, CardBadge, CardContent, CardHeading, CardIcon, CardImage, CardLink, CardPicture, CardProps, Checkbox, CheckboxProps, DatePicker, DatePickerProps, Dialog, DialogBody, DialogHeader, DialogProps, Expandable, ExpandableContent, ExpandableProps, ExpandableSummary, Field, FieldError, FieldHint, FieldLabel, Fieldset, FieldsetError, FieldsetFields, FieldsetHint, FieldsetLegend, FieldsetProps, Flourish, FlourishProps, Form, FormProps, Image, ImageProps, LoadingSpinner, LoadingSpinnerProps, Logo, LogoProps, PasswordInput, PasswordInputProps, Picture, PictureProps, Pill, PillBadge, PillProps, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverProps, PopoverTrigger, Radio, RadioProps, RootSVG, Searchbox, SearchboxButton, SearchboxInput, SearchboxProps, Select, SelectOption, SelectOptionGroup, SelectProps, Signpost, SignpostProps, SkipNav, SkipNavProps, Squircle, SquircleProps, Tag, TagProps, TextInput, TextInputProps, Textarea, TextareaProps, ValidationSummary, ValidationSummaryErrors, ValidationSummaryHeading, ValidationSummaryPrompt, ValidationSummaryProps };
|
|
32
|
+
export { AlertBanner, AlertBannerHeading, AlertBannerProps, Author, AuthorProps, Button, ButtonProps, Card, CardBadge, CardContent, CardHeading, CardIcon, CardImage, CardLink, CardPicture, CardProps, Checkbox, CheckboxProps, DatePicker, DatePickerProps, Dialog, DialogBody, DialogHeader, DialogProps, Expandable, ExpandableContent, ExpandableProps, ExpandableSummary, Field, FieldError, FieldHint, FieldLabel, Fieldset, FieldsetError, FieldsetFields, FieldsetHint, FieldsetLegend, FieldsetProps, Flourish, FlourishProps, Form, FormProps, Image, ImageProps, LoadingSpinner, LoadingSpinnerProps, Logo, LogoProps, PasswordInput, PasswordInputProps, Picture, PictureProps, Pill, PillBadge, PillProps, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverProps, PopoverTrigger, Radio, RadioProps, RootSVG, Searchbox, SearchboxButton, SearchboxInput, SearchboxProps, Select, SelectOption, SelectOptionGroup, SelectProps, Signpost, SignpostProps, SkipNav, SkipNavProps, Squircle, SquircleProps, SquircleSvgProps, Tag, TagProps, TextInput, TextInputProps, Textarea, TextareaProps, ValidationSummary, ValidationSummaryErrors, ValidationSummaryHeading, ValidationSummaryPrompt, ValidationSummaryProps };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coopdigital/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.21.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -103,12 +103,12 @@
|
|
|
103
103
|
"storybook": "$storybook"
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
|
-
"@coopdigital/styles": "^1.
|
|
106
|
+
"@coopdigital/styles": "^1.15.0",
|
|
107
107
|
"@radix-ui/react-popover": "^1.1.23",
|
|
108
108
|
"clsx": "^2.1.1",
|
|
109
109
|
"date-fns": "^4.4.0",
|
|
110
110
|
"merge-refs": "^2.0.0",
|
|
111
111
|
"react-day-picker": "^10.0.1"
|
|
112
112
|
},
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "a54fd337dade28ed2d1e1f7d4d0e2cfeb7b90c9e"
|
|
114
114
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { HTMLAttributes, JSX, Ref } from "react"
|
|
1
|
+
import type { HTMLAttributes, JSX, Ref, SVGAttributes } from "react"
|
|
2
2
|
|
|
3
3
|
import clsx from "clsx"
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
// import { useSlots } from "@/hooks"
|
|
6
|
+
|
|
7
|
+
// import { hasUserBg } from "@/utils"
|
|
6
8
|
|
|
7
9
|
export interface SquircleProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
10
|
/** **(Optional)** Main content inside the component. It can be any valid JSX or string. */
|
|
@@ -11,30 +13,65 @@ export interface SquircleProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11
13
|
className?: string
|
|
12
14
|
/** **(Optional)** Specify a custom React ref for this component. */
|
|
13
15
|
ref?: Ref<HTMLDivElement>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface SquircleSvgProps extends SVGAttributes<SVGElement> {
|
|
14
19
|
/** **(Optional)** Specify the Squircle size. */
|
|
15
|
-
size?:
|
|
20
|
+
size?: string | number
|
|
16
21
|
}
|
|
17
22
|
|
|
18
|
-
const Squircle = ({
|
|
19
|
-
children,
|
|
20
|
-
className,
|
|
21
|
-
ref,
|
|
22
|
-
size = "md",
|
|
23
|
-
...props
|
|
24
|
-
}: SquircleProps): JSX.Element => {
|
|
23
|
+
const Squircle = ({ children, className, ref, ...props }: SquircleProps): JSX.Element => {
|
|
25
24
|
const componentProps = {
|
|
26
|
-
className: clsx("coop-squircle",
|
|
27
|
-
"data-size": size.length && size !== "md" ? size : undefined,
|
|
25
|
+
className: clsx("coop-squircle", className),
|
|
28
26
|
...props,
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
return (
|
|
32
30
|
<figure {...componentProps} ref={ref}>
|
|
33
|
-
|
|
31
|
+
{children}
|
|
34
32
|
</figure>
|
|
35
33
|
)
|
|
36
34
|
}
|
|
37
35
|
|
|
36
|
+
// oxlint-disable-next-line perfectionist/sort-objects
|
|
37
|
+
const sizeMap = { sm: "32", md: "64", lg: "96" }
|
|
38
|
+
|
|
39
|
+
const SquircleSvg = ({ size, ...props }: SquircleSvgProps) => {
|
|
40
|
+
const safeSize = sizeMap[size as keyof typeof sizeMap] ?? size ?? "64"
|
|
41
|
+
const dimensions = {
|
|
42
|
+
height: safeSize,
|
|
43
|
+
width: safeSize,
|
|
44
|
+
}
|
|
45
|
+
return (
|
|
46
|
+
<svg
|
|
47
|
+
{...dimensions}
|
|
48
|
+
{...props}
|
|
49
|
+
aria-hidden="true"
|
|
50
|
+
viewBox="0 0 64 64"
|
|
51
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
52
|
+
>
|
|
53
|
+
<path
|
|
54
|
+
d="M0,32 C0,10.56,10.56,0,32,0 S64,10.56,64,32 S53.44,64,32,64 S0,53.44,0,32"
|
|
55
|
+
vectorEffect="non-scaling-stroke"
|
|
56
|
+
/>
|
|
57
|
+
</svg>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const SquircleText = ({
|
|
62
|
+
children,
|
|
63
|
+
className,
|
|
64
|
+
...props
|
|
65
|
+
}: HTMLAttributes<HTMLDivElement>): JSX.Element => {
|
|
66
|
+
const componentProps = {
|
|
67
|
+
className,
|
|
68
|
+
...props,
|
|
69
|
+
}
|
|
70
|
+
return <figcaption {...componentProps}>{children}</figcaption>
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
Squircle.Svg = SquircleSvg
|
|
74
|
+
Squircle.Text = SquircleText
|
|
38
75
|
Squircle.slot = { name: "Squircle" }
|
|
39
76
|
|
|
40
77
|
export default Squircle
|