@coopdigital/react 1.4.1 → 1.5.1

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 (205) hide show
  1. package/dist/components/AlertBanner/AlertBanner.d.ts +12 -2
  2. package/dist/components/AlertBanner/AlertBanner.js +3 -2
  3. package/dist/components/Author/Author.d.ts +7 -1
  4. package/dist/components/Author/Author.js +1 -0
  5. package/dist/components/Button/Button.d.ts +7 -1
  6. package/dist/components/Button/Button.js +1 -1
  7. package/dist/components/Card/Card.d.ts +41 -7
  8. package/dist/components/Card/Card.js +7 -6
  9. package/dist/components/Checkbox/Checkbox.d.ts +6 -4
  10. package/dist/components/Checkbox/Checkbox.js +8 -6
  11. package/dist/components/DatePicker/DatePicker.d.ts +8 -3
  12. package/dist/components/DatePicker/DatePicker.js +11 -12
  13. package/dist/components/Expandable/Expandable.d.ts +21 -5
  14. package/dist/components/Expandable/Expandable.js +4 -3
  15. package/dist/components/Field/Field.context.d.ts +14 -0
  16. package/dist/components/Field/Field.context.js +13 -0
  17. package/dist/components/Field/Field.d.ts +30 -8
  18. package/dist/components/Field/Field.js +32 -34
  19. package/dist/components/Field/index.js +1 -0
  20. package/dist/components/FieldMarkers/Label.d.ts +1 -1
  21. package/dist/components/FieldMarkers/Label.js +4 -0
  22. package/dist/components/FieldMarkers/Legend.d.ts +1 -1
  23. package/dist/components/Fieldset/Fieldset.d.ts +36 -8
  24. package/dist/components/Fieldset/Fieldset.js +6 -5
  25. package/dist/components/Flourish/Flourish.d.ts +7 -1
  26. package/dist/components/Flourish/Flourish.js +1 -0
  27. package/dist/components/Form/Form.d.ts +7 -1
  28. package/dist/components/Form/Form.js +1 -0
  29. package/dist/components/Image/Image.d.ts +7 -1
  30. package/dist/components/Image/Image.js +1 -0
  31. package/dist/components/Pill/Pill.d.ts +13 -3
  32. package/dist/components/Pill/Pill.js +3 -2
  33. package/dist/components/Popover/Popover.d.ts +33 -5
  34. package/dist/components/Popover/Popover.js +6 -5
  35. package/dist/components/Popover/index.js +1 -0
  36. package/dist/components/Radio/Radio.d.ts +6 -4
  37. package/dist/components/Radio/Radio.js +8 -6
  38. package/dist/components/RootSVG/RootSVG.d.ts +7 -1
  39. package/dist/components/RootSVG/RootSVG.js +1 -0
  40. package/dist/components/Searchbox/Searchbox.context.d.ts +13 -0
  41. package/dist/components/Searchbox/Searchbox.context.js +11 -0
  42. package/dist/components/Searchbox/Searchbox.d.ts +16 -12
  43. package/dist/components/Searchbox/Searchbox.js +25 -29
  44. package/dist/components/Select/Select.d.ts +18 -5
  45. package/dist/components/Select/Select.js +8 -9
  46. package/dist/components/Signpost/Signpost.d.ts +7 -1
  47. package/dist/components/Signpost/Signpost.js +1 -0
  48. package/dist/components/SkipNav/SkipNav.d.ts +7 -1
  49. package/dist/components/SkipNav/SkipNav.js +1 -0
  50. package/dist/components/Squircle/Squircle.d.ts +7 -1
  51. package/dist/components/Squircle/Squircle.js +1 -0
  52. package/dist/components/Tag/Tag.d.ts +7 -1
  53. package/dist/components/Tag/Tag.js +1 -0
  54. package/dist/components/TextInput/TextInput.d.ts +4 -3
  55. package/dist/components/TextInput/TextInput.js +5 -6
  56. package/dist/components/Textarea/Textarea.d.ts +4 -3
  57. package/dist/components/Textarea/Textarea.js +4 -7
  58. package/dist/components/ValidationSummary/ValidationSummary.d.ts +26 -4
  59. package/dist/components/ValidationSummary/ValidationSummary.js +7 -6
  60. package/dist/components/icons/AccountCircleFilledIcon.d.ts +1 -1
  61. package/dist/components/icons/AccountCircleIcon.d.ts +1 -1
  62. package/dist/components/icons/AccountFilledIcon.d.ts +1 -1
  63. package/dist/components/icons/AccountIcon.d.ts +1 -1
  64. package/dist/components/icons/AddIcon.d.ts +1 -1
  65. package/dist/components/icons/AppsFilledIcon.d.ts +1 -1
  66. package/dist/components/icons/AppsIcon.d.ts +1 -1
  67. package/dist/components/icons/ArrowDownIcon.d.ts +1 -1
  68. package/dist/components/icons/ArrowLeftIcon.d.ts +1 -1
  69. package/dist/components/icons/ArrowRightIcon.d.ts +1 -1
  70. package/dist/components/icons/ArrowUpIcon.d.ts +1 -1
  71. package/dist/components/icons/BackspaceFilledIcon.d.ts +1 -1
  72. package/dist/components/icons/BackspaceIcon.d.ts +1 -1
  73. package/dist/components/icons/BasketFilledIcon.d.ts +1 -1
  74. package/dist/components/icons/BasketIcon.d.ts +1 -1
  75. package/dist/components/icons/BellFilledIcon.d.ts +1 -1
  76. package/dist/components/icons/BellIcon.d.ts +1 -1
  77. package/dist/components/icons/BroomIcon.d.ts +1 -1
  78. package/dist/components/icons/CalendarFilledIcon.d.ts +1 -1
  79. package/dist/components/icons/CalendarIcon.d.ts +1 -1
  80. package/dist/components/icons/CashFilledIcon.d.ts +1 -1
  81. package/dist/components/icons/CashIcon.d.ts +1 -1
  82. package/dist/components/icons/ChevronDownIcon.d.ts +1 -1
  83. package/dist/components/icons/ChevronLeftIcon.d.ts +1 -1
  84. package/dist/components/icons/ChevronRightIcon.d.ts +1 -1
  85. package/dist/components/icons/ChevronUpIcon.d.ts +1 -1
  86. package/dist/components/icons/CircleBurgerFilledIcon.d.ts +1 -1
  87. package/dist/components/icons/CircleBurgerIcon.d.ts +1 -1
  88. package/dist/components/icons/ClipboardFilledIcon.d.ts +1 -1
  89. package/dist/components/icons/ClipboardIcon.d.ts +1 -1
  90. package/dist/components/icons/ClockFilledIcon.d.ts +1 -1
  91. package/dist/components/icons/ClockIcon.d.ts +1 -1
  92. package/dist/components/icons/CloseAltFilledIcon.d.ts +1 -1
  93. package/dist/components/icons/CloseAltIcon.d.ts +1 -1
  94. package/dist/components/icons/CogIcon.d.ts +1 -1
  95. package/dist/components/icons/CommunityFilledIcon.d.ts +1 -1
  96. package/dist/components/icons/CommunityIcon.d.ts +1 -1
  97. package/dist/components/icons/ComputerIcon.d.ts +1 -1
  98. package/dist/components/icons/ContactFilledIcon.d.ts +1 -1
  99. package/dist/components/icons/ContactIcon.d.ts +1 -1
  100. package/dist/components/icons/ContactlessFilledIcon.d.ts +1 -1
  101. package/dist/components/icons/ContactlessIcon.d.ts +1 -1
  102. package/dist/components/icons/CoopLiveIcon.d.ts +1 -1
  103. package/dist/components/icons/CoopLocationFilledIcon.d.ts +1 -1
  104. package/dist/components/icons/CoopLogoIcon.d.ts +1 -1
  105. package/dist/components/icons/CoopMembershipCardFilledIcon.d.ts +1 -1
  106. package/dist/components/icons/CreditCardFilledIcon.d.ts +1 -1
  107. package/dist/components/icons/CreditCardIcon.d.ts +1 -1
  108. package/dist/components/icons/CrossIcon.d.ts +1 -1
  109. package/dist/components/icons/DocumentIcon.d.ts +1 -1
  110. package/dist/components/icons/DownloadIcon.d.ts +1 -1
  111. package/dist/components/icons/EnterStoreIcon.d.ts +1 -1
  112. package/dist/components/icons/ExitStoreIcon.d.ts +1 -1
  113. package/dist/components/icons/EyeFilledIcon.d.ts +1 -1
  114. package/dist/components/icons/EyeIcon.d.ts +1 -1
  115. package/dist/components/icons/EyeStrikeFilledIcon.d.ts +1 -1
  116. package/dist/components/icons/EyeStrikeIcon.d.ts +1 -1
  117. package/dist/components/icons/FeedbackFilledIcon.d.ts +1 -1
  118. package/dist/components/icons/FeedbackIcon.d.ts +1 -1
  119. package/dist/components/icons/FilterIcon.d.ts +1 -1
  120. package/dist/components/icons/GiftCardFilledIcon.d.ts +1 -1
  121. package/dist/components/icons/GiftCardIcon.d.ts +1 -1
  122. package/dist/components/icons/GiftFilledIcon.d.ts +1 -1
  123. package/dist/components/icons/GiftIcon.d.ts +1 -1
  124. package/dist/components/icons/HelpFilledIcon.d.ts +1 -1
  125. package/dist/components/icons/HelpIcon.d.ts +1 -1
  126. package/dist/components/icons/HomeFilledIcon.d.ts +1 -1
  127. package/dist/components/icons/HomeIcon.d.ts +1 -1
  128. package/dist/components/icons/HowDoIAssistantIcon.d.ts +1 -1
  129. package/dist/components/icons/InfoIcon.d.ts +1 -1
  130. package/dist/components/icons/KebabIcon.d.ts +1 -1
  131. package/dist/components/icons/LoadingIcon.d.ts +1 -1
  132. package/dist/components/icons/LocationFilledIcon.d.ts +1 -1
  133. package/dist/components/icons/LocationIcon.d.ts +1 -1
  134. package/dist/components/icons/LogoutIcon.d.ts +1 -1
  135. package/dist/components/icons/MailIcon.d.ts +1 -1
  136. package/dist/components/icons/MenuIcon.d.ts +1 -1
  137. package/dist/components/icons/MessageIcon.d.ts +1 -1
  138. package/dist/components/icons/MinusIcon.d.ts +1 -1
  139. package/dist/components/icons/NotesFilledIcon.d.ts +1 -1
  140. package/dist/components/icons/NotesIcon.d.ts +1 -1
  141. package/dist/components/icons/OpenNewIcon.d.ts +1 -1
  142. package/dist/components/icons/OwnBagIcon.d.ts +1 -1
  143. package/dist/components/icons/PadlockIcon.d.ts +1 -1
  144. package/dist/components/icons/PencilIcon.d.ts +1 -1
  145. package/dist/components/icons/PhoneIcon.d.ts +1 -1
  146. package/dist/components/icons/PowerIcon.d.ts +1 -1
  147. package/dist/components/icons/SaveFilledIcon.d.ts +1 -1
  148. package/dist/components/icons/SaveIcon.d.ts +1 -1
  149. package/dist/components/icons/ScooterIcon.d.ts +1 -1
  150. package/dist/components/icons/SearchFilledIcon.d.ts +1 -1
  151. package/dist/components/icons/SearchIcon.d.ts +1 -1
  152. package/dist/components/icons/SendIcon.d.ts +1 -1
  153. package/dist/components/icons/SpannerIcon.d.ts +1 -1
  154. package/dist/components/icons/StarFilledIcon.d.ts +1 -1
  155. package/dist/components/icons/StarIcon.d.ts +1 -1
  156. package/dist/components/icons/TickAltFilledIcon.d.ts +1 -1
  157. package/dist/components/icons/TickAltIcon.d.ts +1 -1
  158. package/dist/components/icons/TickIcon.d.ts +1 -1
  159. package/dist/components/icons/TruckIcon.d.ts +1 -1
  160. package/dist/components/icons/UserWipeIcon.d.ts +1 -1
  161. package/dist/components/icons/VoucherFilledIcon.d.ts +1 -1
  162. package/dist/components/icons/VoucherIcon.d.ts +1 -1
  163. package/dist/components/icons/WarningFilledIcon.d.ts +1 -1
  164. package/dist/components/icons/WarningIcon.d.ts +1 -1
  165. package/dist/components/icons/WifiIcon.d.ts +1 -1
  166. package/dist/components/icons/WriteIcon.d.ts +1 -1
  167. package/dist/hooks/useSlots.d.ts +4 -2
  168. package/dist/hooks/useSlots.js +33 -7
  169. package/dist/index.js +10 -10
  170. package/dist/types/index.d.ts +14 -14
  171. package/dist/utils/index.d.ts +1 -0
  172. package/dist/utils/index.js +9 -7
  173. package/package.json +12 -11
  174. package/src/components/AlertBanner/AlertBanner.tsx +5 -2
  175. package/src/components/Author/Author.tsx +4 -1
  176. package/src/components/Button/Button.tsx +5 -1
  177. package/src/components/Card/Card.tsx +8 -6
  178. package/src/components/Checkbox/Checkbox.tsx +13 -9
  179. package/src/components/DatePicker/DatePicker.tsx +15 -15
  180. package/src/components/Expandable/Expandable.tsx +5 -8
  181. package/src/components/Field/Field.context.ts +29 -0
  182. package/src/components/Field/Field.tsx +61 -56
  183. package/src/components/FieldMarkers/Label.tsx +4 -0
  184. package/src/components/Fieldset/Fieldset.tsx +7 -5
  185. package/src/components/Flourish/Flourish.tsx +4 -1
  186. package/src/components/Form/Form.tsx +4 -1
  187. package/src/components/Image/Image.tsx +4 -1
  188. package/src/components/Pill/Pill.tsx +4 -2
  189. package/src/components/Popover/Popover.tsx +7 -5
  190. package/src/components/Radio/Radio.tsx +12 -9
  191. package/src/components/RootSVG/RootSVG.tsx +4 -1
  192. package/src/components/Searchbox/Searchbox.context.tsx +20 -0
  193. package/src/components/Searchbox/Searchbox.tsx +55 -44
  194. package/src/components/Select/Select.tsx +11 -11
  195. package/src/components/Signpost/Signpost.tsx +4 -1
  196. package/src/components/SkipNav/SkipNav.tsx +4 -1
  197. package/src/components/Squircle/Squircle.tsx +4 -1
  198. package/src/components/Tag/Tag.tsx +4 -1
  199. package/src/components/TextInput/TextInput.tsx +8 -8
  200. package/src/components/Textarea/Textarea.tsx +7 -8
  201. package/src/components/ValidationSummary/ValidationSummary.tsx +12 -5
  202. package/src/hooks/useSlots.ts +37 -9
  203. package/src/types/index.ts +18 -14
  204. package/src/utils/index.ts +8 -6
  205. package/dist/node_modules/merge-refs/dist/index.js +0 -36
@@ -15,13 +15,23 @@ interface AlertBannerHeadingProps extends HTMLAttributes<HTMLHeadingElement> {
15
15
  /** **(Optional)** Specify additional CSS classes to be applied to the Heading. */
16
16
  className?: string;
17
17
  }
18
- export declare const AlertBanner: {
18
+ declare const AlertBanner: {
19
19
  ({ children, className, ref, variant, ...props }: AlertBannerProps): JSX.Element;
20
+ slot: {
21
+ name: string;
22
+ };
20
23
  Heading: {
21
24
  ({ children, className }: AlertBannerHeadingProps): JSX.Element;
22
- config: {
25
+ slot: {
23
26
  name: string;
24
27
  };
25
28
  };
26
29
  };
30
+ declare const AlertBannerHeading: {
31
+ ({ children, className }: AlertBannerHeadingProps): JSX.Element;
32
+ slot: {
33
+ name: string;
34
+ };
35
+ };
27
36
  export default AlertBanner;
37
+ export { AlertBanner, AlertBannerHeading };
@@ -12,7 +12,8 @@ const AlertBanner = ({ children, className, ref, variant = "default", ...props }
12
12
  const AlertBannerHeading = ({ children, className }) => {
13
13
  return jsx("h2", { className: className, children: children });
14
14
  };
15
- AlertBannerHeading.config = { name: "AlertBannerHeading" };
15
+ AlertBanner.slot = { name: "AlertBanner" };
16
+ AlertBannerHeading.slot = { name: "AlertBannerHeading" };
16
17
  AlertBanner.Heading = AlertBannerHeading;
17
18
 
18
- export { AlertBanner, AlertBanner as default };
19
+ export { AlertBanner, AlertBannerHeading, AlertBanner as default };
@@ -16,5 +16,11 @@ export interface AuthorProps extends HTMLAttributes<HTMLDivElement> {
16
16
  /** **(Optional)** Specify the Author size. */
17
17
  size?: "sm" | "md";
18
18
  }
19
- export declare const Author: ({ author, className, date, datePrefix, image, ref, size, ...props }: AuthorProps) => JSX.Element;
19
+ declare const Author: {
20
+ ({ author, className, date, datePrefix, image, ref, size, ...props }: AuthorProps): JSX.Element;
21
+ slot: {
22
+ name: string;
23
+ };
24
+ };
20
25
  export default Author;
26
+ export { Author };
@@ -17,5 +17,6 @@ const Author = ({ author = "Co-op team", className, date, datePrefix = "", image
17
17
  };
18
18
  return (jsxs("div", { ...componentProps, ref: ref, children: [image && jsx(Image, { ...imageProps }), jsxs("div", { className: "coop-author--content", children: [jsxs("span", { children: [jsx("span", { children: datePrefix ? datePrefix + " " : "" }), jsx("span", { className: "coop-author--date", children: date })] }), jsxs("span", { children: ["by ", author] })] })] }));
19
19
  };
20
+ Author.slot = { name: "Author" };
20
21
 
21
22
  export { Author, Author as default };
@@ -26,5 +26,11 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
26
26
  /** **(Optional)** Specify the Button variant. */
27
27
  variant?: "solid" | "ghost" | "text";
28
28
  }
29
- export declare const Button: ({ as, children, className, href, isDisabled, isFullWidth, isLoading, loadingText, onClick, ref, size, variant, ...props }: ButtonProps) => JSX.Element;
29
+ declare const Button: {
30
+ ({ as, children, className, href, isDisabled, isFullWidth, isLoading, loadingText, onClick, ref, size, variant, ...props }: ButtonProps): JSX.Element;
31
+ slot: {
32
+ name: string;
33
+ };
34
+ };
30
35
  export default Button;
36
+ export { Button };
@@ -1,4 +1,3 @@
1
-
2
1
  "use client";
3
2
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
4
3
  import clsx from 'clsx';
@@ -34,5 +33,6 @@ const Button = ({ as, children, className, href, isDisabled = false, isFullWidth
34
33
  const finalChildren = isPending || isLoading ? (jsxs(Fragment, { children: [loadingText, jsx(LoadingIcon, { stroke: "currentColor", strokeWidth: "1px" })] })) : (children);
35
34
  return React.createElement(element, { ...componentProps, ref }, finalChildren);
36
35
  };
36
+ Button.slot = { name: "Button" };
37
37
 
38
38
  export { Button, Button as default };
@@ -48,37 +48,71 @@ interface CardBadgeProps extends HTMLAttributes<HTMLDivElement> {
48
48
  position?: "inset" | "popout";
49
49
  }
50
50
  type CardImageProps = ImageProps;
51
- export declare const Card: {
51
+ declare const Card: {
52
52
  ({ chevron, children, className, href, hrefAs, imagePosition, orientation, ref, ...props }: CardProps): JSX.Element;
53
+ slot: {
54
+ name: string;
55
+ };
53
56
  Label: {
54
57
  ({ children, className }: CardLabelProps): JSX.Element;
55
- config: {
58
+ slot: {
56
59
  name: string;
57
60
  };
58
61
  };
59
62
  Heading: {
60
63
  ({ as, children, className }: CardHeadingProps): JSX.Element;
61
- config: {
64
+ slot: {
62
65
  name: string;
63
66
  };
64
67
  };
65
68
  Badge: {
66
69
  ({ align, children, position, ...props }: CardBadgeProps): JSX.Element;
67
- config: {
70
+ slot: {
68
71
  name: string;
69
72
  };
70
73
  };
71
74
  Body: {
72
75
  ({ children }: CardBodyProps): JSX.Element;
73
- config: {
76
+ slot: {
74
77
  name: string;
75
78
  };
76
79
  };
77
80
  Image: {
78
- (props: CardImageProps): import("react/jsx-runtime").JSX.Element;
79
- config: {
81
+ (props: CardImageProps): JSX.Element;
82
+ slot: {
80
83
  name: string;
81
84
  };
82
85
  };
83
86
  };
87
+ declare const CardHeading: {
88
+ ({ as, children, className }: CardHeadingProps): JSX.Element;
89
+ slot: {
90
+ name: string;
91
+ };
92
+ };
93
+ declare const CardLabel: {
94
+ ({ children, className }: CardLabelProps): JSX.Element;
95
+ slot: {
96
+ name: string;
97
+ };
98
+ };
99
+ declare const CardBadge: {
100
+ ({ align, children, position, ...props }: CardBadgeProps): JSX.Element;
101
+ slot: {
102
+ name: string;
103
+ };
104
+ };
105
+ declare const CardBody: {
106
+ ({ children }: CardBodyProps): JSX.Element;
107
+ slot: {
108
+ name: string;
109
+ };
110
+ };
111
+ declare const CardImage: {
112
+ (props: CardImageProps): JSX.Element;
113
+ slot: {
114
+ name: string;
115
+ };
116
+ };
84
117
  export default Card;
118
+ export { Card, CardBadge, CardBody, CardHeading, CardImage, CardLabel };
@@ -55,15 +55,16 @@ const CardImage = (props) => {
55
55
  var _a;
56
56
  return jsx(Image, { ...props, crop: (_a = props.crop) !== null && _a !== void 0 ? _a : "wide" });
57
57
  };
58
- CardLabel.config = { name: "CardLabel" };
59
- CardHeading.config = { name: "CardHeading" };
60
- CardBadge.config = { name: "CardBadge" };
61
- CardBody.config = { name: "CardBody" };
62
- CardImage.config = { name: "CardImage" };
58
+ Card.slot = { name: "Card" };
59
+ CardLabel.slot = { name: "CardLabel" };
60
+ CardHeading.slot = { name: "CardHeading" };
61
+ CardBadge.slot = { name: "CardBadge" };
62
+ CardBody.slot = { name: "CardBody" };
63
+ CardImage.slot = { name: "CardImage" };
63
64
  Card.Label = CardLabel;
64
65
  Card.Heading = CardHeading;
65
66
  Card.Badge = CardBadge;
66
67
  Card.Body = CardBody;
67
68
  Card.Image = CardImage;
68
69
 
69
- export { Card, Card as default };
70
+ export { Card, CardBadge, CardBody, CardHeading, CardImage, CardLabel, Card as default };
@@ -16,11 +16,13 @@ export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement
16
16
  /** **(Optional)** Specify the Checkbox size. */
17
17
  size?: StandardSizes;
18
18
  }
19
- export declare const Checkbox: {
19
+ declare const Checkbox: {
20
20
  ({ className, disabled, error, id, name, ref, size, ...props }: CheckboxProps): JSX.Element;
21
- config: {
22
- isField: true;
23
- isInline: true;
21
+ slot: {
22
+ field: boolean;
23
+ inline: boolean;
24
+ name: string;
24
25
  };
25
26
  };
26
27
  export default Checkbox;
28
+ export { Checkbox };
@@ -1,24 +1,26 @@
1
+ "use client";
1
2
  import { jsx } from 'react/jsx-runtime';
2
3
  import clsx from 'clsx';
3
- import { useId } from '../../hooks/useId.js';
4
+ import { useField } from '../Field/Field.context.js';
4
5
 
5
6
  const Checkbox = ({ className, disabled, error = false, id, name, ref, size, ...props }) => {
6
- const uid = useId(id);
7
+ const field = useField();
7
8
  const componentProps = {
8
9
  className: clsx("coop-checkbox", "coop-field-element", className),
9
10
  "data-error": error || undefined,
10
11
  "data-size": size !== null && size !== void 0 ? size : undefined,
11
12
  disabled,
12
- id: uid,
13
+ id: id !== null && id !== void 0 ? id : field === null || field === void 0 ? void 0 : field.id,
13
14
  name,
14
15
  type: "checkbox",
15
16
  ...props,
16
17
  };
17
18
  return jsx("input", { ...componentProps, ref: ref });
18
19
  };
19
- Checkbox.config = {
20
- isField: true,
21
- isInline: true,
20
+ Checkbox.slot = {
21
+ field: true,
22
+ inline: true,
23
+ name: "Checkbox",
22
24
  };
23
25
 
24
26
  export { Checkbox, Checkbox as default };
@@ -1,6 +1,6 @@
1
1
  import type { InputHTMLAttributes, JSX, Ref } from "react";
2
2
  import type { DayPickerProps, Mode } from "react-day-picker";
3
- import type { ComponentConfig, StandardSizes } from "../../types";
3
+ import type { StandardSizes } from "../../types";
4
4
  import type { DateRange } from "./datepicker-utils";
5
5
  type OnDateSelectHandler = (selected: string | string[] | {
6
6
  from?: string;
@@ -55,8 +55,13 @@ export interface DatePickerProps extends Omit<InputHTMLAttributes<HTMLInputEleme
55
55
  */
56
56
  startDate?: Date;
57
57
  }
58
- export declare const DatePicker: {
58
+ declare const DatePicker: {
59
59
  ({ className, closeOnSelect, dateFormat, disabled, disabledDates, endDate, error, id, initialDate, initialSelected, mode, name, onChange, onSelect, ref, required, size, startDate, ...props }: DatePickerProps): JSX.Element;
60
- config: ComponentConfig;
60
+ slot: {
61
+ field: boolean;
62
+ name: string;
63
+ suffix: string;
64
+ };
61
65
  };
62
66
  export default DatePicker;
67
+ export { DatePicker };
@@ -1,11 +1,10 @@
1
-
2
1
  "use client";
3
2
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
4
3
  import clsx from 'clsx';
5
4
  import { useMemo, useReducer, useCallback } from 'react';
6
5
  import { DayPicker } from 'react-day-picker';
7
- import { useId } from '../../hooks/useId.js';
8
6
  import { Button } from '../Button/Button.js';
7
+ import { useField } from '../Field/Field.context.js';
9
8
  import { CalendarIcon } from '../icons/CalendarIcon.js';
10
9
  import { CrossIcon } from '../icons/CrossIcon.js';
11
10
  import { TickIcon } from '../icons/TickIcon.js';
@@ -14,10 +13,6 @@ import { TextInput } from '../TextInput/TextInput.js';
14
13
  import { getInitialDate, getStartDate, getEndDate, getDefaultMonth, getDateValues, shouldClose, shouldSkipParsing } from './datepicker-utils.js';
15
14
 
16
15
  const now = new Date();
17
- const componentConfig = {
18
- fieldSuffix: "_display",
19
- isField: true,
20
- };
21
16
  const baseValueProps = {
22
17
  readOnly: true,
23
18
  type: "hidden",
@@ -42,7 +37,7 @@ const Calendar = ({ captionLayout = "label", className, disabled, endMonth, form
42
37
  };
43
38
  const DatePicker = ({ className, closeOnSelect = true, dateFormat = "dd/MM/yyyy", disabled, disabledDates, endDate, error = false, id, initialDate = now, initialSelected = false, mode = "single", name, onChange, onSelect, ref, required = false, size, startDate, ...props }) => {
44
39
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
45
- const uid = useId(id);
40
+ const field = useField();
46
41
  initialDate = getInitialDate(mode, initialDate);
47
42
  const startDateProp = startDate;
48
43
  const endDateProp = endDate;
@@ -113,7 +108,7 @@ const DatePicker = ({ className, closeOnSelect = true, dateFormat = "dd/MM/yyyy"
113
108
  };
114
109
  const valueProps = {
115
110
  ...baseValueProps,
116
- id: uid,
111
+ id: id !== null && id !== void 0 ? id : field === null || field === void 0 ? void 0 : field.id,
117
112
  name: name,
118
113
  };
119
114
  const getPlaceholder = () => {
@@ -127,9 +122,9 @@ const DatePicker = ({ className, closeOnSelect = true, dateFormat = "dd/MM/yyyy"
127
122
  return lowerCaseDateFormat;
128
123
  }
129
124
  };
130
- return (jsxs("div", { ...componentProps, children: [jsxs(Popover, { onOpenChange: setOpen, open: state.open, children: [jsx(Popover.Anchor, { className: "coop-datepicker-inner", children: jsx(TextInput, { autoComplete: "off", className: "coop-datepicker-input", disabled: disabled, id: uid + componentConfig.fieldSuffix,
125
+ return (jsxs("div", { ...componentProps, children: [jsxs(Popover, { onOpenChange: setOpen, open: state.open, children: [jsx(Popover.Anchor, { className: "coop-datepicker-inner", children: jsx(TextInput, { autoComplete: "off", className: "coop-datepicker-input", disabled: disabled, id: valueProps.id + "_display",
131
126
  //maxLength={dateFormat.length}
132
- name: name + componentConfig.fieldSuffix, onChange: updateFromInput, placeholder: getPlaceholder(), ref: ref, required: required, size: size, suffix: disabled ? (jsx("span", { className: "coop-datepicker-trigger", children: jsx(CalendarIcon, { width: 24 }) })) : (jsx(Popover.Trigger, { "aria-label": "Choose date", className: "coop-datepicker-trigger", children: jsx(CalendarIcon, { width: 24 }) })), suffixInline: true, value: (_f = (_e = state === null || state === void 0 ? void 0 : state[mode]) === null || _e === void 0 ? void 0 : _e.input) !== null && _f !== void 0 ? _f : "" }) }), jsxs(Popover.Content, { "aria-label": "Date picker", className: "coop-datepicker-calendar bg-white", collisionPadding: 16, sideOffset: 4, children: [jsx(Calendar
127
+ name: name + "_display", onChange: updateFromInput, placeholder: getPlaceholder(), ref: ref, required: required, size: size, suffix: disabled ? (jsx("span", { className: "coop-datepicker-trigger", children: jsx(CalendarIcon, { width: 24 }) })) : (jsx(Popover.Trigger, { "aria-label": "Choose date", className: "coop-datepicker-trigger", children: jsx(CalendarIcon, { width: 24 }) })), suffixInline: true, value: (_f = (_e = state === null || state === void 0 ? void 0 : state[mode]) === null || _e === void 0 ? void 0 : _e.input) !== null && _f !== void 0 ? _f : "" }) }), jsxs(Popover.Content, { "aria-label": "Date picker", className: "coop-datepicker-calendar bg-white", collisionPadding: 16, sideOffset: 4, children: [jsx(Calendar
133
128
  // jsx-ally throws here because we set autoFocus, but this
134
129
  // is not a standard element. Daypicker uses this value to
135
130
  // focus the day rather than the nav when it renders.
@@ -141,8 +136,12 @@ const DatePicker = ({ className, closeOnSelect = true, dateFormat = "dd/MM/yyyy"
141
136
  // eslint-disable-next-line jsx-a11y/no-autofocus
142
137
  autoFocus: true, captionLayout: "dropdown",
143
138
  //defaultMonth={defaultMonth}
144
- disabled: disabledDates, endMonth: endDate, month: state.view, onMonthChange: setView, onSelect: updateValues, startMonth: startDate, ...calendarProps[mode] }), jsxs("div", { className: "coop-datepicker-actions", children: [jsxs(Button, { "aria-label": "Cancel", className: "bg-tint-grey", onClick: resetState, size: "sm", children: ["Clear ", jsx(CrossIcon, { stroke: "black", strokeWidth: 1 })] }), jsx(Popover.Close, { asChild: true, children: jsxs(Button, { "aria-label": "Accept", size: "sm", children: ["OK ", jsx(TickIcon, { stroke: "white", strokeWidth: 1 })] }) })] })] })] }), jsx("div", { "aria-live": "assertive", className: "sr-only coop-datepicker-status", role: "status", children: (_g = state.message) !== null && _g !== void 0 ? _g : footerMessage[mode] }), mode === "single" && (jsx("input", { ...valueProps, value: (_l = (_j = (_h = state.single) === null || _h === void 0 ? void 0 : _h.field) !== null && _j !== void 0 ? _j : (_k = state.single) === null || _k === void 0 ? void 0 : _k.input) !== null && _l !== void 0 ? _l : "" })), mode === "multiple" && (jsx("input", { ...valueProps, value: (_q = (_o = (_m = state.multiple) === null || _m === void 0 ? void 0 : _m.field) !== null && _o !== void 0 ? _o : (_p = state.multiple) === null || _p === void 0 ? void 0 : _p.input) !== null && _q !== void 0 ? _q : "" })), mode === "range" && (jsxs(Fragment, { children: [jsx("input", { ...baseValueProps, id: `${uid}_start`, name: `${name}_start`, value: (_v = (_t = (_s = (_r = state.range) === null || _r === void 0 ? void 0 : _r.field) === null || _s === void 0 ? void 0 : _s.from) !== null && _t !== void 0 ? _t : (_u = state.range) === null || _u === void 0 ? void 0 : _u.input) !== null && _v !== void 0 ? _v : "" }), jsx("input", { ...baseValueProps, id: `${uid}_end`, name: `${name}_end`, value: (_0 = (_y = (_x = (_w = state.range) === null || _w === void 0 ? void 0 : _w.field) === null || _x === void 0 ? void 0 : _x.to) !== null && _y !== void 0 ? _y : (_z = state.range) === null || _z === void 0 ? void 0 : _z.input) !== null && _0 !== void 0 ? _0 : "" })] }))] }));
139
+ disabled: disabledDates, endMonth: endDate, month: state.view, onMonthChange: setView, onSelect: updateValues, startMonth: startDate, ...calendarProps[mode] }), jsxs("div", { className: "coop-datepicker-actions", children: [jsxs(Button, { "aria-label": "Cancel", className: "bg-tint-grey", onClick: resetState, size: "sm", children: ["Clear ", jsx(CrossIcon, { stroke: "black", strokeWidth: 1 })] }), jsx(Popover.Close, { asChild: true, children: jsxs(Button, { "aria-label": "Accept", size: "sm", children: ["OK ", jsx(TickIcon, { stroke: "white", strokeWidth: 1 })] }) })] })] })] }), jsx("div", { "aria-live": "assertive", className: "sr-only coop-datepicker-status", role: "status", children: (_g = state.message) !== null && _g !== void 0 ? _g : footerMessage[mode] }), mode === "single" && (jsx("input", { ...valueProps, value: (_l = (_j = (_h = state.single) === null || _h === void 0 ? void 0 : _h.field) !== null && _j !== void 0 ? _j : (_k = state.single) === null || _k === void 0 ? void 0 : _k.input) !== null && _l !== void 0 ? _l : "" })), mode === "multiple" && (jsx("input", { ...valueProps, value: (_q = (_o = (_m = state.multiple) === null || _m === void 0 ? void 0 : _m.field) !== null && _o !== void 0 ? _o : (_p = state.multiple) === null || _p === void 0 ? void 0 : _p.input) !== null && _q !== void 0 ? _q : "" })), mode === "range" && (jsxs(Fragment, { children: [jsx("input", { ...baseValueProps, id: `${valueProps.id}_start`, name: `${name}_start`, value: (_v = (_t = (_s = (_r = state.range) === null || _r === void 0 ? void 0 : _r.field) === null || _s === void 0 ? void 0 : _s.from) !== null && _t !== void 0 ? _t : (_u = state.range) === null || _u === void 0 ? void 0 : _u.input) !== null && _v !== void 0 ? _v : "" }), jsx("input", { ...baseValueProps, id: `${valueProps.id}_end`, name: `${name}_end`, value: (_0 = (_y = (_x = (_w = state.range) === null || _w === void 0 ? void 0 : _w.field) === null || _x === void 0 ? void 0 : _x.to) !== null && _y !== void 0 ? _y : (_z = state.range) === null || _z === void 0 ? void 0 : _z.input) !== null && _0 !== void 0 ? _0 : "" })] }))] }));
140
+ };
141
+ DatePicker.slot = {
142
+ field: true,
143
+ name: "DatePicker",
144
+ suffix: "_display",
145
145
  };
146
- DatePicker.config = componentConfig;
147
146
 
148
147
  export { DatePicker, DatePicker as default };
@@ -19,19 +19,35 @@ interface ExpandableContentProps extends HTMLAttributes<HTMLElement> {
19
19
  /** **(Optional)** Specify additional CSS classes to be applied to the content wrapper. */
20
20
  className?: string;
21
21
  }
22
- export declare const Expandable: {
22
+ declare const Expandable: {
23
23
  ({ children, className, ref, ...props }: ExpandableProps): JSX.Element;
24
+ slot: {
25
+ name: string;
26
+ };
24
27
  Summary: {
25
- ({ children, className, ...props }: ExpandableSummaryProps): import("react/jsx-runtime").JSX.Element;
26
- config: {
28
+ ({ children, className, ...props }: ExpandableSummaryProps): JSX.Element;
29
+ slot: {
27
30
  name: string;
28
31
  };
29
32
  };
30
33
  Content: {
31
- ({ children, className, ...props }: ExpandableContentProps): import("react/jsx-runtime").JSX.Element;
32
- config: {
34
+ ({ children, className, ...props }: ExpandableContentProps): JSX.Element;
35
+ slot: {
33
36
  name: string;
34
37
  };
35
38
  };
36
39
  };
40
+ declare const ExpandableSummary: {
41
+ ({ children, className, ...props }: ExpandableSummaryProps): JSX.Element;
42
+ slot: {
43
+ name: string;
44
+ };
45
+ };
46
+ declare const ExpandableContent: {
47
+ ({ children, className, ...props }: ExpandableContentProps): JSX.Element;
48
+ slot: {
49
+ name: string;
50
+ };
51
+ };
37
52
  export default Expandable;
53
+ export { Expandable, ExpandableContent, ExpandableSummary };
@@ -26,9 +26,10 @@ const ExpandableSummary = ({ children, className, ...props }) => {
26
26
  const ExpandableContent = ({ children, className, ...props }) => {
27
27
  return (jsx("div", { className: clsx("coop-expandable--content", className), ...props, children: children }));
28
28
  };
29
- ExpandableSummary.config = { name: "ExpandableSummary" };
30
- ExpandableContent.config = { name: "ExpandableContent" };
29
+ Expandable.slot = { name: "Expandable" };
30
+ ExpandableSummary.slot = { name: "ExpandableSummary" };
31
+ ExpandableContent.slot = { name: "ExpandableContent" };
31
32
  Expandable.Summary = ExpandableSummary;
32
33
  Expandable.Content = ExpandableContent;
33
34
 
34
- export { Expandable, Expandable as default };
35
+ export { Expandable, ExpandableContent, ExpandableSummary, Expandable as default };
@@ -0,0 +1,14 @@
1
+ export interface FieldConfig {
2
+ disabled: boolean;
3
+ id: string;
4
+ inline?: boolean;
5
+ suffix?: string;
6
+ }
7
+ export interface FieldContextValue {
8
+ disabled?: boolean;
9
+ id?: string;
10
+ inline?: boolean;
11
+ suffix?: string;
12
+ }
13
+ export declare const FieldContext: import("react").Context<FieldContextValue | null>;
14
+ export declare const useField: () => FieldContextValue | null;
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { createContext, useContext } from 'react';
3
+
4
+ const FieldContext = createContext(null);
5
+ const useField = () => {
6
+ const context = useContext(FieldContext);
7
+ if (!context) {
8
+ return null;
9
+ }
10
+ return context;
11
+ };
12
+
13
+ export { FieldContext, useField };
@@ -19,25 +19,47 @@ interface FieldProps extends HTMLAttributes<HTMLDivElement> {
19
19
  /** **(Optional)** Specify a custom React ref for this component. */
20
20
  ref?: Ref<HTMLDivElement>;
21
21
  }
22
- export declare const Field: {
23
- ({ boxed, children, className, error, hideErrorBar, ref, ...props }: FieldProps): import("react/jsx-runtime").JSX.Element;
22
+ declare const Field: {
23
+ ({ boxed, children, className, error, hideErrorBar, ref, ...props }: FieldProps): React.JSX.Element;
24
+ slot: {
25
+ name: string;
26
+ };
24
27
  Label: {
25
- (props: LabelProps): import("react/jsx-runtime").JSX.Element;
26
- config: {
28
+ (props: LabelProps): React.JSX.Element;
29
+ slot: {
27
30
  name: string;
28
31
  };
29
32
  };
30
33
  Hint: {
31
- (props: HintProps): import("react/jsx-runtime").JSX.Element;
32
- config: {
34
+ (props: HintProps): React.JSX.Element;
35
+ slot: {
33
36
  name: string;
34
37
  };
35
38
  };
36
39
  Error: {
37
- (props: ErrorProps): import("react/jsx-runtime").JSX.Element;
38
- config: {
40
+ (props: ErrorProps): React.JSX.Element;
41
+ slot: {
39
42
  name: string;
40
43
  };
41
44
  };
42
45
  };
46
+ declare const FieldLabel: {
47
+ (props: LabelProps): React.JSX.Element;
48
+ slot: {
49
+ name: string;
50
+ };
51
+ };
52
+ declare const FieldHint: {
53
+ (props: HintProps): React.JSX.Element;
54
+ slot: {
55
+ name: string;
56
+ };
57
+ };
58
+ declare const FieldError: {
59
+ (props: ErrorProps): React.JSX.Element;
60
+ slot: {
61
+ name: string;
62
+ };
63
+ };
43
64
  export default Field;
65
+ export { Field, FieldError, FieldHint, FieldLabel };
@@ -1,11 +1,13 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
1
+ "use client";
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
3
  import clsx from 'clsx';
3
- import React from 'react';
4
4
  import { useId } from '../../hooks/useId.js';
5
5
  import { useSlots } from '../../hooks/useSlots.js';
6
+ import { getSlotProp } from '../../utils/index.js';
6
7
  import { Error } from '../FieldMarkers/Error.js';
7
8
  import { Hint } from '../FieldMarkers/Hint.js';
8
9
  import { Label } from '../FieldMarkers/Label.js';
10
+ import { FieldContext } from './Field.context.js';
9
11
 
10
12
  const componentSlots = {
11
13
  Children: null,
@@ -15,57 +17,53 @@ const componentSlots = {
15
17
  FieldLabel: null,
16
18
  };
17
19
  const Field = ({ boxed = false, children, className, error = false, hideErrorBar = false, ref, ...props }) => {
18
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
20
+ var _a, _b;
19
21
  const slots = { ...useSlots(componentSlots, children) };
20
22
  const hasMarkers = !!((_b = (_a = slots.FieldLabel) !== null && _a !== void 0 ? _a : slots.FieldError) !== null && _b !== void 0 ? _b : slots.FieldHint);
21
- let isInline = false;
22
- let control;
23
- let controlSuffix = "";
24
- let controlId = useId();
25
- let controlDisabled = false;
23
+ const internalId = useId();
24
+ const controlProps = {
25
+ disabled: false,
26
+ id: internalId,
27
+ };
26
28
  if (Array.isArray(slots.Children)) {
27
29
  slots.Children = slots.Children.filter((child) => {
28
- var _a, _b;
29
- if ((_b = (_a = child === null || child === void 0 ? void 0 : child.type) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.isField) {
30
- control = child;
31
- return false;
30
+ //resolveComponentName(child)
31
+ var _a, _b, _c, _d;
32
+ if (child && typeof child === "object" && "type" in child) {
33
+ if (typeof (child === null || child === void 0 ? void 0 : child.type) === "function" && "slot" in child.type) {
34
+ const { slot } = child === null || child === void 0 ? void 0 : child.type;
35
+ slots.Control = child;
36
+ if (slots.Control.props) {
37
+ controlProps.inline = (_a = slot.inline) !== null && _a !== void 0 ? _a : false;
38
+ controlProps.disabled = (_b = getSlotProp(slots.Control, "disabled")) !== null && _b !== void 0 ? _b : false;
39
+ controlProps.id = (_c = getSlotProp(slots.Control, "id")) !== null && _c !== void 0 ? _c : controlProps.id;
40
+ controlProps.suffix = (_d = slot.suffix) !== null && _d !== void 0 ? _d : undefined;
41
+ }
42
+ return false;
43
+ }
32
44
  }
33
45
  return true;
34
46
  });
35
47
  }
36
- if (React.isValidElement(control)) {
37
- const controlProps = control.props;
38
- controlId = (_c = controlProps.id) !== null && _c !== void 0 ? _c : controlId;
39
- controlDisabled = (_d = controlProps.disabled) !== null && _d !== void 0 ? _d : false;
40
- controlSuffix = (_g = (_f = (_e = control === null || control === void 0 ? void 0 : control.type) === null || _e === void 0 ? void 0 : _e.config) === null || _f === void 0 ? void 0 : _f.fieldSuffix) !== null && _g !== void 0 ? _g : "";
41
- isInline = (_k = (_j = (_h = control === null || control === void 0 ? void 0 : control.type) === null || _h === void 0 ? void 0 : _h.config) === null || _j === void 0 ? void 0 : _j.isInline) !== null && _k !== void 0 ? _k : false;
42
- slots.Control = controlProps.id
43
- ? control
44
- : React.cloneElement(control, { id: controlId });
45
- }
46
- if (React.isValidElement(slots.FieldLabel) && !slots.FieldLabel.props.htmlFor) {
47
- slots.FieldLabel = React.cloneElement(slots.FieldLabel, {
48
- htmlFor: controlId + controlSuffix,
49
- });
50
- }
51
48
  const componentProps = {
52
49
  ...props,
53
- "aria-disabled": controlDisabled || undefined,
54
- className: clsx("coop-field", isInline && "coop-field-inline", className),
50
+ "aria-disabled": controlProps.disabled || undefined,
51
+ className: clsx("coop-field", controlProps.inline && "coop-field-inline", className),
55
52
  "data-boxed": boxed || undefined,
56
53
  "data-error": error || undefined,
57
54
  "data-hide-error": hideErrorBar || undefined,
58
55
  };
59
- return (jsxs("div", { ...componentProps, ref: ref, children: [!isInline && hasMarkers && (jsxs("div", { className: "coop-field-markers", children: [slots.FieldLabel, slots.FieldHint, slots.FieldError] })), slots.Control && (jsxs("div", { className: "coop-field-control", children: [slots.Control, isInline && hasMarkers && (jsxs("div", { className: "coop-field-markers", children: [slots.FieldLabel, slots.FieldHint, slots.FieldError] }))] })), slots.Children] }));
56
+ return (jsx(FieldContext.Provider, { value: { ...controlProps }, children: jsxs("div", { ...componentProps, ref: ref, children: [!(controlProps === null || controlProps === void 0 ? void 0 : controlProps.inline) && hasMarkers && (jsxs("div", { className: "coop-field-markers", children: [slots.FieldLabel, slots.FieldHint, slots.FieldError] })), slots.Control && (jsxs("div", { className: "coop-field-control", children: [slots.Control, (controlProps === null || controlProps === void 0 ? void 0 : controlProps.inline) && hasMarkers && (jsxs("div", { className: "coop-field-markers", children: [slots.FieldLabel, slots.FieldHint, slots.FieldError] }))] })), slots.Children] }) }));
60
57
  };
61
58
  const FieldLabel = (props) => jsx(Label, { ...props });
62
59
  const FieldHint = (props) => jsx(Hint, { ...props });
63
60
  const FieldError = (props) => jsx(Error, { ...props });
64
- FieldLabel.config = { name: "FieldLabel" };
65
- FieldHint.config = { name: "FieldHint" };
66
- FieldError.config = { name: "FieldError" };
61
+ Field.slot = { name: "Field" };
62
+ FieldLabel.slot = { name: "FieldLabel" };
63
+ FieldHint.slot = { name: "FieldHint" };
64
+ FieldError.slot = { name: "FieldError" };
67
65
  Field.Label = FieldLabel;
68
66
  Field.Hint = FieldHint;
69
67
  Field.Error = FieldError;
70
68
 
71
- export { Field, Field as default };
69
+ export { Field, FieldError, FieldHint, FieldLabel, Field as default };
@@ -1,4 +1,5 @@
1
1
  import { Field } from './Field.js';
2
+ export { FieldError, FieldHint, FieldLabel } from './Field.js';
2
3
 
3
4
 
4
5
 
@@ -9,5 +9,5 @@ export interface LabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
9
9
  /** **(Optional)** Specify a custom React ref for this component. */
10
10
  ref?: Ref<HTMLLabelElement>;
11
11
  }
12
- export declare const Label: ({ children, className, isVisible, ref, ...props }: LabelProps) => import("react/jsx-runtime").JSX.Element;
12
+ export declare const Label: ({ children, className, isVisible, ref, ...props }: LabelProps) => import("react").JSX.Element;
13
13
  export default Label;
@@ -1,9 +1,13 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import clsx from 'clsx';
3
+ import { useField } from '../Field/Field.context.js';
3
4
 
4
5
  const Label = ({ children, className, isVisible = true, ref, ...props }) => {
6
+ var _a, _b;
7
+ const field = useField();
5
8
  const componentProps = {
6
9
  className: clsx("coop-field-label", !isVisible && "sr-only", className),
10
+ htmlFor: (_a = props.htmlFor) !== null && _a !== void 0 ? _a : ((field === null || field === void 0 ? void 0 : field.id) ? field.id + ((_b = field === null || field === void 0 ? void 0 : field.suffix) !== null && _b !== void 0 ? _b : "") : undefined),
7
11
  ...props,
8
12
  };
9
13
  return (jsx("label", { ...componentProps, ref: ref, children: jsx("span", { children: children }) }));
@@ -9,5 +9,5 @@ export interface LegendProps extends HTMLAttributes<HTMLLegendElement> {
9
9
  /** **(Optional)** Specify a custom React ref for this component. */
10
10
  ref?: Ref<HTMLLegendElement>;
11
11
  }
12
- export declare const Legend: ({ children, className, isVisible, ref, ...props }: LegendProps) => import("react/jsx-runtime").JSX.Element;
12
+ export declare const Legend: ({ children, className, isVisible, ref, ...props }: LegendProps) => import("react").JSX.Element;
13
13
  export default Legend;