@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.
Files changed (155) hide show
  1. package/dist/components/AlertBanner/AlertBanner.js +5 -2
  2. package/dist/components/Author/Author.js +5 -2
  3. package/dist/components/Card/Card.d.ts +96 -49
  4. package/dist/components/Card/Card.js +61 -60
  5. package/dist/components/Card/index.d.ts +2 -2
  6. package/dist/components/Card/index.js +2 -2
  7. package/dist/components/Checkbox/Checkbox.js +5 -2
  8. package/dist/components/DatePicker/DatePicker.js +5 -4
  9. package/dist/components/DatePicker/datepicker-utils.js +12 -11
  10. package/dist/components/Dialog/Dialog.js +5 -2
  11. package/dist/components/Expandable/Expandable.js +5 -2
  12. package/dist/components/FieldMarkers/Error.js +5 -2
  13. package/dist/components/FieldMarkers/Hint.js +5 -2
  14. package/dist/components/FieldMarkers/Label.js +5 -2
  15. package/dist/components/Fieldset/Fieldset.js +10 -4
  16. package/dist/components/Flourish/Flourish.js +6 -3
  17. package/dist/components/Form/Form.js +5 -2
  18. package/dist/components/Image/Image.d.ts +3 -5
  19. package/dist/components/Image/Image.js +10 -7
  20. package/dist/components/LoadingSpinner/LoadingSpinner.js +5 -2
  21. package/dist/components/Logo/Logo.js +5 -2
  22. package/dist/components/Picture/Picture.d.ts +15 -0
  23. package/dist/components/Picture/Picture.js +17 -0
  24. package/dist/components/Picture/index.d.ts +2 -0
  25. package/dist/components/Picture/index.js +5 -0
  26. package/dist/components/Prose/Prose.js +5 -2
  27. package/dist/components/Radio/Radio.js +5 -2
  28. package/dist/components/Searchbox/Searchbox.js +3 -2
  29. package/dist/components/Select/Select.js +5 -2
  30. package/dist/components/Signpost/Signpost.js +6 -6
  31. package/dist/components/SkipNav/SkipNav.js +5 -2
  32. package/dist/components/Squircle/Squircle.d.ts +8 -4
  33. package/dist/components/Squircle/Squircle.js +39 -6
  34. package/dist/components/Squircle/index.d.ts +2 -2
  35. package/dist/components/ValidationSummary/ValidationSummary.js +5 -2
  36. package/dist/components/icons/AccountCircleFilledIcon.js +5 -2
  37. package/dist/components/icons/AccountCircleIcon.js +5 -2
  38. package/dist/components/icons/AccountFilledIcon.js +5 -2
  39. package/dist/components/icons/AccountIcon.js +5 -2
  40. package/dist/components/icons/AddIcon.js +5 -2
  41. package/dist/components/icons/AppsFilledIcon.js +5 -2
  42. package/dist/components/icons/AppsIcon.js +5 -2
  43. package/dist/components/icons/ArrowDownIcon.js +5 -2
  44. package/dist/components/icons/ArrowLeftIcon.js +5 -2
  45. package/dist/components/icons/ArrowRightIcon.js +5 -2
  46. package/dist/components/icons/ArrowUpIcon.js +5 -2
  47. package/dist/components/icons/BackspaceFilledIcon.js +5 -2
  48. package/dist/components/icons/BackspaceIcon.js +5 -2
  49. package/dist/components/icons/BasketFilledIcon.js +5 -2
  50. package/dist/components/icons/BasketIcon.js +5 -2
  51. package/dist/components/icons/BellFilledIcon.js +5 -2
  52. package/dist/components/icons/BellIcon.js +5 -2
  53. package/dist/components/icons/BroomIcon.js +5 -2
  54. package/dist/components/icons/CalendarFilledIcon.js +5 -2
  55. package/dist/components/icons/CalendarIcon.js +5 -2
  56. package/dist/components/icons/CashFilledIcon.js +5 -2
  57. package/dist/components/icons/CashIcon.js +5 -2
  58. package/dist/components/icons/ChevronDownIcon.js +5 -2
  59. package/dist/components/icons/ChevronLeftIcon.js +5 -2
  60. package/dist/components/icons/ChevronRightIcon.js +5 -2
  61. package/dist/components/icons/ChevronUpIcon.js +5 -2
  62. package/dist/components/icons/CircleBurgerFilledIcon.js +5 -2
  63. package/dist/components/icons/CircleBurgerIcon.js +5 -2
  64. package/dist/components/icons/ClipboardFilledIcon.js +5 -2
  65. package/dist/components/icons/ClipboardIcon.js +5 -2
  66. package/dist/components/icons/ClockFilledIcon.js +5 -2
  67. package/dist/components/icons/ClockIcon.js +5 -2
  68. package/dist/components/icons/CloseAltFilledIcon.js +5 -2
  69. package/dist/components/icons/CloseAltIcon.js +5 -2
  70. package/dist/components/icons/CogIcon.js +5 -2
  71. package/dist/components/icons/CommunityFilledIcon.js +5 -2
  72. package/dist/components/icons/CommunityIcon.js +5 -2
  73. package/dist/components/icons/ComputerIcon.js +5 -2
  74. package/dist/components/icons/ContactFilledIcon.js +5 -2
  75. package/dist/components/icons/ContactIcon.js +5 -2
  76. package/dist/components/icons/ContactlessFilledIcon.js +5 -2
  77. package/dist/components/icons/ContactlessIcon.js +5 -2
  78. package/dist/components/icons/CoopLiveIcon.js +5 -2
  79. package/dist/components/icons/CoopLocationFilledIcon.js +5 -2
  80. package/dist/components/icons/CoopLogoIcon.js +5 -2
  81. package/dist/components/icons/CoopMembershipCardFilledIcon.js +5 -2
  82. package/dist/components/icons/CreditCardFilledIcon.js +5 -2
  83. package/dist/components/icons/CreditCardIcon.js +5 -2
  84. package/dist/components/icons/CrossIcon.js +5 -2
  85. package/dist/components/icons/DocumentIcon.js +5 -2
  86. package/dist/components/icons/DownloadIcon.js +5 -2
  87. package/dist/components/icons/EnterStoreIcon.js +5 -2
  88. package/dist/components/icons/ExitStoreIcon.js +5 -2
  89. package/dist/components/icons/EyeFilledIcon.js +5 -2
  90. package/dist/components/icons/EyeIcon.js +5 -2
  91. package/dist/components/icons/EyeStrikeFilledIcon.js +5 -2
  92. package/dist/components/icons/EyeStrikeIcon.js +5 -2
  93. package/dist/components/icons/FeedbackFilledIcon.js +5 -2
  94. package/dist/components/icons/FeedbackIcon.js +5 -2
  95. package/dist/components/icons/FilterIcon.js +5 -2
  96. package/dist/components/icons/GiftCardFilledIcon.js +5 -2
  97. package/dist/components/icons/GiftCardIcon.js +5 -2
  98. package/dist/components/icons/GiftFilledIcon.js +5 -2
  99. package/dist/components/icons/GiftIcon.js +5 -2
  100. package/dist/components/icons/HelpFilledIcon.js +5 -2
  101. package/dist/components/icons/HelpIcon.js +5 -2
  102. package/dist/components/icons/HomeFilledIcon.js +5 -2
  103. package/dist/components/icons/HomeIcon.js +5 -2
  104. package/dist/components/icons/HowDoIAssistantIcon.js +5 -2
  105. package/dist/components/icons/InfoIcon.js +5 -2
  106. package/dist/components/icons/KebabIcon.js +5 -2
  107. package/dist/components/icons/LoadingIcon.js +5 -2
  108. package/dist/components/icons/LocationFilledIcon.js +5 -2
  109. package/dist/components/icons/LocationIcon.js +5 -2
  110. package/dist/components/icons/LogoutIcon.js +5 -2
  111. package/dist/components/icons/MailIcon.js +5 -2
  112. package/dist/components/icons/MenuIcon.js +5 -2
  113. package/dist/components/icons/MessageIcon.js +5 -2
  114. package/dist/components/icons/MinusIcon.js +5 -2
  115. package/dist/components/icons/NotesFilledIcon.js +5 -2
  116. package/dist/components/icons/NotesIcon.js +5 -2
  117. package/dist/components/icons/OpenNewIcon.js +5 -2
  118. package/dist/components/icons/OwnBagIcon.js +5 -2
  119. package/dist/components/icons/PadlockIcon.js +5 -2
  120. package/dist/components/icons/PencilIcon.js +5 -2
  121. package/dist/components/icons/PhoneIcon.js +5 -2
  122. package/dist/components/icons/PowerIcon.js +5 -2
  123. package/dist/components/icons/SaveFilledIcon.js +5 -2
  124. package/dist/components/icons/SaveIcon.js +5 -2
  125. package/dist/components/icons/ScooterIcon.js +5 -2
  126. package/dist/components/icons/SearchFilledIcon.js +5 -2
  127. package/dist/components/icons/SearchIcon.js +5 -2
  128. package/dist/components/icons/SendIcon.js +5 -2
  129. package/dist/components/icons/SpannerIcon.js +5 -2
  130. package/dist/components/icons/StarFilledIcon.js +5 -2
  131. package/dist/components/icons/StarIcon.js +5 -2
  132. package/dist/components/icons/TickAltFilledIcon.js +5 -2
  133. package/dist/components/icons/TickAltIcon.js +5 -2
  134. package/dist/components/icons/TickIcon.js +5 -2
  135. package/dist/components/icons/TruckIcon.js +5 -2
  136. package/dist/components/icons/UserWipeIcon.js +5 -2
  137. package/dist/components/icons/VoucherFilledIcon.js +5 -2
  138. package/dist/components/icons/VoucherIcon.js +5 -2
  139. package/dist/components/icons/WarningCircleFilledIcon.js +5 -2
  140. package/dist/components/icons/WarningCircleIcon.js +5 -2
  141. package/dist/components/icons/WarningFilledIcon.js +5 -2
  142. package/dist/components/icons/WarningIcon.js +5 -2
  143. package/dist/components/icons/WifiIcon.js +5 -2
  144. package/dist/components/icons/WriteIcon.js +5 -2
  145. package/dist/hooks/useSlots.js +4 -3
  146. package/dist/index.d.ts +5 -3
  147. package/dist/index.js +3 -2
  148. package/package.json +10 -10
  149. package/src/components/Card/Card.tsx +146 -100
  150. package/src/components/Image/Image.tsx +15 -22
  151. package/src/components/Picture/Picture.tsx +36 -0
  152. package/src/components/Picture/index.ts +5 -0
  153. package/src/components/Signpost/Signpost.tsx +1 -1
  154. package/src/components/Squircle/Squircle.tsx +50 -13
  155. package/src/index.ts +1 -0
@@ -1,10 +1,8 @@
1
- import type { HTMLAttributes, JSX, Ref } from "react"
1
+ import type { ImgHTMLAttributes, JSX, Ref } from "react"
2
2
 
3
- export interface ImageProps extends HTMLAttributes<HTMLImageElement> {
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 = (src: string, width: string, height: string | undefined) => {
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, height)
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
@@ -0,0 +1,5 @@
1
+ import Picture from "./Picture"
2
+
3
+ export default Picture
4
+ export { Picture }
5
+ export * from "./Picture"
@@ -46,7 +46,7 @@ const Signpost = ({
46
46
 
47
47
  return (
48
48
  <div {...componentProps} ref={ref}>
49
- {image && <Image crop="wide" {...image} />}
49
+ {image && <Image {...image} />}
50
50
  {React.createElement(
51
51
  element,
52
52
  { href },
@@ -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 { hasUserBg } from "@/utils"
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?: "sm" | "md" | "lg"
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", !hasUserBg(className) && "bg-offer", className),
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
- <figcaption>{children}</figcaption>
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"