@coopdigital/react 1.19.1 → 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.
- package/dist/components/AlertBanner/AlertBanner.js +5 -2
- package/dist/components/Author/Author.js +5 -2
- package/dist/components/Card/Card.d.ts +96 -49
- package/dist/components/Card/Card.js +61 -60
- package/dist/components/Card/index.d.ts +2 -2
- package/dist/components/Card/index.js +2 -2
- package/dist/components/Checkbox/Checkbox.js +5 -2
- package/dist/components/DatePicker/DatePicker.js +5 -4
- package/dist/components/DatePicker/datepicker-utils.js +12 -11
- package/dist/components/Dialog/Dialog.js +5 -2
- package/dist/components/Expandable/Expandable.js +5 -2
- package/dist/components/FieldMarkers/Error.js +5 -2
- package/dist/components/FieldMarkers/Hint.js +5 -2
- package/dist/components/FieldMarkers/Label.js +5 -2
- package/dist/components/Fieldset/Fieldset.js +10 -4
- package/dist/components/Flourish/Flourish.js +6 -3
- package/dist/components/Form/Form.js +5 -2
- package/dist/components/Image/Image.d.ts +3 -5
- package/dist/components/Image/Image.js +10 -7
- package/dist/components/LoadingSpinner/LoadingSpinner.js +5 -2
- package/dist/components/Logo/Logo.js +5 -2
- package/dist/components/Picture/Picture.d.ts +15 -0
- package/dist/components/Picture/Picture.js +17 -0
- package/dist/components/Picture/index.d.ts +2 -0
- package/dist/components/Picture/index.js +5 -0
- package/dist/components/Prose/Prose.js +5 -2
- package/dist/components/Radio/Radio.js +5 -2
- package/dist/components/Searchbox/Searchbox.js +3 -2
- package/dist/components/Select/Select.js +5 -2
- package/dist/components/Signpost/Signpost.js +6 -6
- package/dist/components/SkipNav/SkipNav.js +5 -2
- package/dist/components/Squircle/Squircle.d.ts +8 -4
- package/dist/components/Squircle/Squircle.js +39 -6
- package/dist/components/Squircle/index.d.ts +2 -2
- package/dist/components/ValidationSummary/ValidationSummary.js +5 -2
- package/dist/components/icons/AccountCircleFilledIcon.js +5 -2
- package/dist/components/icons/AccountCircleIcon.js +5 -2
- package/dist/components/icons/AccountFilledIcon.js +5 -2
- package/dist/components/icons/AccountIcon.js +5 -2
- package/dist/components/icons/AddIcon.js +5 -2
- package/dist/components/icons/AppsFilledIcon.js +5 -2
- package/dist/components/icons/AppsIcon.js +5 -2
- package/dist/components/icons/ArrowDownIcon.js +5 -2
- package/dist/components/icons/ArrowLeftIcon.js +5 -2
- package/dist/components/icons/ArrowRightIcon.js +5 -2
- package/dist/components/icons/ArrowUpIcon.js +5 -2
- package/dist/components/icons/BackspaceFilledIcon.js +5 -2
- package/dist/components/icons/BackspaceIcon.js +5 -2
- package/dist/components/icons/BasketFilledIcon.js +5 -2
- package/dist/components/icons/BasketIcon.js +5 -2
- package/dist/components/icons/BellFilledIcon.js +5 -2
- package/dist/components/icons/BellIcon.js +5 -2
- package/dist/components/icons/BroomIcon.js +5 -2
- package/dist/components/icons/CalendarFilledIcon.js +5 -2
- package/dist/components/icons/CalendarIcon.js +5 -2
- package/dist/components/icons/CashFilledIcon.js +5 -2
- package/dist/components/icons/CashIcon.js +5 -2
- package/dist/components/icons/ChevronDownIcon.js +5 -2
- package/dist/components/icons/ChevronLeftIcon.js +5 -2
- package/dist/components/icons/ChevronRightIcon.js +5 -2
- package/dist/components/icons/ChevronUpIcon.js +5 -2
- package/dist/components/icons/CircleBurgerFilledIcon.js +5 -2
- package/dist/components/icons/CircleBurgerIcon.js +5 -2
- package/dist/components/icons/ClipboardFilledIcon.js +5 -2
- package/dist/components/icons/ClipboardIcon.js +5 -2
- package/dist/components/icons/ClockFilledIcon.js +5 -2
- package/dist/components/icons/ClockIcon.js +5 -2
- package/dist/components/icons/CloseAltFilledIcon.js +5 -2
- package/dist/components/icons/CloseAltIcon.js +5 -2
- package/dist/components/icons/CogIcon.js +5 -2
- package/dist/components/icons/CommunityFilledIcon.js +5 -2
- package/dist/components/icons/CommunityIcon.js +5 -2
- package/dist/components/icons/ComputerIcon.js +5 -2
- package/dist/components/icons/ContactFilledIcon.js +5 -2
- package/dist/components/icons/ContactIcon.js +5 -2
- package/dist/components/icons/ContactlessFilledIcon.js +5 -2
- package/dist/components/icons/ContactlessIcon.js +5 -2
- package/dist/components/icons/CoopLiveIcon.js +5 -2
- package/dist/components/icons/CoopLocationFilledIcon.js +5 -2
- package/dist/components/icons/CoopLogoIcon.js +5 -2
- package/dist/components/icons/CoopMembershipCardFilledIcon.js +5 -2
- package/dist/components/icons/CreditCardFilledIcon.js +5 -2
- package/dist/components/icons/CreditCardIcon.js +5 -2
- package/dist/components/icons/CrossIcon.js +5 -2
- package/dist/components/icons/DocumentIcon.js +5 -2
- package/dist/components/icons/DownloadIcon.js +5 -2
- package/dist/components/icons/EnterStoreIcon.js +5 -2
- package/dist/components/icons/ExitStoreIcon.js +5 -2
- package/dist/components/icons/EyeFilledIcon.js +5 -2
- package/dist/components/icons/EyeIcon.js +5 -2
- package/dist/components/icons/EyeStrikeFilledIcon.js +5 -2
- package/dist/components/icons/EyeStrikeIcon.js +5 -2
- package/dist/components/icons/FeedbackFilledIcon.js +5 -2
- package/dist/components/icons/FeedbackIcon.js +5 -2
- package/dist/components/icons/FilterIcon.js +5 -2
- package/dist/components/icons/GiftCardFilledIcon.js +5 -2
- package/dist/components/icons/GiftCardIcon.js +5 -2
- package/dist/components/icons/GiftFilledIcon.js +5 -2
- package/dist/components/icons/GiftIcon.js +5 -2
- package/dist/components/icons/HelpFilledIcon.js +5 -2
- package/dist/components/icons/HelpIcon.js +5 -2
- package/dist/components/icons/HomeFilledIcon.js +5 -2
- package/dist/components/icons/HomeIcon.js +5 -2
- package/dist/components/icons/HowDoIAssistantIcon.js +5 -2
- package/dist/components/icons/InfoIcon.js +5 -2
- package/dist/components/icons/KebabIcon.js +5 -2
- package/dist/components/icons/LoadingIcon.js +5 -2
- package/dist/components/icons/LocationFilledIcon.js +5 -2
- package/dist/components/icons/LocationIcon.js +5 -2
- package/dist/components/icons/LogoutIcon.js +5 -2
- package/dist/components/icons/MailIcon.js +5 -2
- package/dist/components/icons/MenuIcon.js +5 -2
- package/dist/components/icons/MessageIcon.js +5 -2
- package/dist/components/icons/MinusIcon.js +5 -2
- package/dist/components/icons/NotesFilledIcon.js +5 -2
- package/dist/components/icons/NotesIcon.js +5 -2
- package/dist/components/icons/OpenNewIcon.js +5 -2
- package/dist/components/icons/OwnBagIcon.js +5 -2
- package/dist/components/icons/PadlockIcon.js +5 -2
- package/dist/components/icons/PencilIcon.js +5 -2
- package/dist/components/icons/PhoneIcon.js +5 -2
- package/dist/components/icons/PowerIcon.js +5 -2
- package/dist/components/icons/SaveFilledIcon.js +5 -2
- package/dist/components/icons/SaveIcon.js +5 -2
- package/dist/components/icons/ScooterIcon.js +5 -2
- package/dist/components/icons/SearchFilledIcon.js +5 -2
- package/dist/components/icons/SearchIcon.js +5 -2
- package/dist/components/icons/SendIcon.js +5 -2
- package/dist/components/icons/SpannerIcon.js +5 -2
- package/dist/components/icons/StarFilledIcon.js +5 -2
- package/dist/components/icons/StarIcon.js +5 -2
- package/dist/components/icons/TickAltFilledIcon.js +5 -2
- package/dist/components/icons/TickAltIcon.js +5 -2
- package/dist/components/icons/TickIcon.js +5 -2
- package/dist/components/icons/TruckIcon.js +5 -2
- package/dist/components/icons/UserWipeIcon.js +5 -2
- package/dist/components/icons/VoucherFilledIcon.js +5 -2
- package/dist/components/icons/VoucherIcon.js +5 -2
- package/dist/components/icons/WarningCircleFilledIcon.js +5 -2
- package/dist/components/icons/WarningCircleIcon.js +5 -2
- package/dist/components/icons/WarningFilledIcon.js +5 -2
- package/dist/components/icons/WarningIcon.js +5 -2
- package/dist/components/icons/WifiIcon.js +5 -2
- package/dist/components/icons/WriteIcon.js +5 -2
- package/dist/hooks/useSlots.js +4 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +3 -2
- package/package.json +10 -10
- package/src/components/Card/Card.tsx +146 -100
- package/src/components/Image/Image.tsx +15 -22
- package/src/components/Picture/Picture.tsx +36 -0
- package/src/components/Picture/index.ts +5 -0
- package/src/components/Signpost/Signpost.tsx +1 -1
- package/src/components/Squircle/Squircle.tsx +50 -13
- package/src/index.ts +1 -0
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ImgHTMLAttributes, JSX, Ref } from "react"
|
|
2
2
|
|
|
3
|
-
export interface ImageProps extends
|
|
3
|
+
export interface ImageProps extends ImgHTMLAttributes<HTMLImageElement> {
|
|
4
4
|
/** Specify text to describe the image. Refer to Experience Library guidelines on writing good alt text. */
|
|
5
5
|
alt: string
|
|
6
|
-
/** **(Optional)** Specify the image crop mode. */
|
|
7
|
-
crop?: "square" | "wide" | "none"
|
|
8
6
|
/** **(Optional)** Specify the height of the image. */
|
|
9
7
|
height?: string
|
|
10
8
|
/** **(Optional)** Specify a custom React ref for this component. */
|
|
@@ -15,7 +13,15 @@ export interface ImageProps extends HTMLAttributes<HTMLImageElement> {
|
|
|
15
13
|
width?: string
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
const getContentfulParams = (
|
|
16
|
+
const getContentfulParams = ({
|
|
17
|
+
height,
|
|
18
|
+
src,
|
|
19
|
+
width,
|
|
20
|
+
}: {
|
|
21
|
+
height?: string
|
|
22
|
+
src: string
|
|
23
|
+
width: string
|
|
24
|
+
}) => {
|
|
19
25
|
const url = !src.startsWith("http") ? new URL("https://" + src) : new URL(src)
|
|
20
26
|
const params = [
|
|
21
27
|
["fm", "webp"],
|
|
@@ -26,7 +32,7 @@ const getContentfulParams = (src: string, width: string, height: string | undefi
|
|
|
26
32
|
]
|
|
27
33
|
|
|
28
34
|
params.forEach(([k, v]) => {
|
|
29
|
-
if (!url.searchParams.has(k)) url.searchParams.set(k, v)
|
|
35
|
+
if (k && v && !url.searchParams.has(k)) url.searchParams.set(k, v)
|
|
30
36
|
})
|
|
31
37
|
|
|
32
38
|
return {
|
|
@@ -36,32 +42,19 @@ const getContentfulParams = (src: string, width: string, height: string | undefi
|
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
|
|
39
|
-
const Image = ({
|
|
40
|
-
alt,
|
|
41
|
-
crop,
|
|
42
|
-
height,
|
|
43
|
-
ref,
|
|
44
|
-
src,
|
|
45
|
-
width = "640",
|
|
46
|
-
...props
|
|
47
|
-
}: ImageProps): JSX.Element => {
|
|
45
|
+
const Image = ({ alt, height, ref, src, width = "640", ...props }: ImageProps): JSX.Element => {
|
|
48
46
|
let params = { height, src, width }
|
|
49
47
|
|
|
50
48
|
if (src.includes("images.ctfassets.net")) {
|
|
51
|
-
params = getContentfulParams(src, width
|
|
49
|
+
params = getContentfulParams({ height, src, width })
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
const dimensions = {
|
|
55
|
-
"data-crop": crop,
|
|
56
53
|
height: params.height,
|
|
57
54
|
width: params.width,
|
|
58
55
|
}
|
|
59
56
|
|
|
60
|
-
return
|
|
61
|
-
<picture>
|
|
62
|
-
<img alt={alt} loading="lazy" src={params.src} {...dimensions} {...props} ref={ref} />
|
|
63
|
-
</picture>
|
|
64
|
-
)
|
|
57
|
+
return <img alt={alt} loading="lazy" src={params.src} {...dimensions} {...props} ref={ref} />
|
|
65
58
|
}
|
|
66
59
|
|
|
67
60
|
Image.slot = { name: "Image" }
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { HTMLAttributes, JSX, ReactNode, Ref } from "react"
|
|
2
|
+
|
|
3
|
+
import clsx from "clsx"
|
|
4
|
+
|
|
5
|
+
export interface PictureProps extends HTMLAttributes<HTMLPictureElement> {
|
|
6
|
+
/** **(Optional)** Content inside the component. */
|
|
7
|
+
children?: string | ReactNode
|
|
8
|
+
/** **(Optional)** Specify additional CSS classes. */
|
|
9
|
+
className?: string
|
|
10
|
+
/** **(Optional)** Specify the image crop mode. */
|
|
11
|
+
crop?: "square" | "wide" | "thin" | "squircle" | "none"
|
|
12
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
13
|
+
ref?: Ref<HTMLPictureElement>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const Picture = ({
|
|
17
|
+
children,
|
|
18
|
+
className,
|
|
19
|
+
crop,
|
|
20
|
+
ref,
|
|
21
|
+
...props
|
|
22
|
+
}: PictureProps): JSX.Element => {
|
|
23
|
+
const componentProps = {
|
|
24
|
+
className: clsx("coop-picture", className),
|
|
25
|
+
"data-crop": crop ?? undefined,
|
|
26
|
+
...props,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<picture {...componentProps} ref={ref}>
|
|
31
|
+
{children}
|
|
32
|
+
</picture>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default Picture
|
|
@@ -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
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from "./components/Image/Image"
|
|
|
14
14
|
export * from "./components/LoadingSpinner/LoadingSpinner"
|
|
15
15
|
export * from "./components/Logo/Logo"
|
|
16
16
|
export * from "./components/PasswordInput/PasswordInput"
|
|
17
|
+
export * from "./components/Picture"
|
|
17
18
|
export * from "./components/Pill/Pill"
|
|
18
19
|
export * from "./components/Popover/Popover"
|
|
19
20
|
export * from "./components/Radio/Radio"
|