@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.
- package/dist/components/AlertBanner/AlertBanner.d.ts +12 -2
- package/dist/components/AlertBanner/AlertBanner.js +3 -2
- package/dist/components/Author/Author.d.ts +7 -1
- package/dist/components/Author/Author.js +1 -0
- package/dist/components/Button/Button.d.ts +7 -1
- package/dist/components/Button/Button.js +1 -1
- package/dist/components/Card/Card.d.ts +41 -7
- package/dist/components/Card/Card.js +7 -6
- package/dist/components/Checkbox/Checkbox.d.ts +6 -4
- package/dist/components/Checkbox/Checkbox.js +8 -6
- package/dist/components/DatePicker/DatePicker.d.ts +8 -3
- package/dist/components/DatePicker/DatePicker.js +11 -12
- package/dist/components/Expandable/Expandable.d.ts +21 -5
- package/dist/components/Expandable/Expandable.js +4 -3
- package/dist/components/Field/Field.context.d.ts +14 -0
- package/dist/components/Field/Field.context.js +13 -0
- package/dist/components/Field/Field.d.ts +30 -8
- package/dist/components/Field/Field.js +32 -34
- package/dist/components/Field/index.js +1 -0
- package/dist/components/FieldMarkers/Label.d.ts +1 -1
- package/dist/components/FieldMarkers/Label.js +4 -0
- package/dist/components/FieldMarkers/Legend.d.ts +1 -1
- package/dist/components/Fieldset/Fieldset.d.ts +36 -8
- package/dist/components/Fieldset/Fieldset.js +6 -5
- package/dist/components/Flourish/Flourish.d.ts +7 -1
- package/dist/components/Flourish/Flourish.js +1 -0
- package/dist/components/Form/Form.d.ts +7 -1
- package/dist/components/Form/Form.js +1 -0
- package/dist/components/Image/Image.d.ts +7 -1
- package/dist/components/Image/Image.js +1 -0
- package/dist/components/Pill/Pill.d.ts +13 -3
- package/dist/components/Pill/Pill.js +3 -2
- package/dist/components/Popover/Popover.d.ts +33 -5
- package/dist/components/Popover/Popover.js +6 -5
- package/dist/components/Popover/index.js +1 -0
- package/dist/components/Radio/Radio.d.ts +6 -4
- package/dist/components/Radio/Radio.js +8 -6
- package/dist/components/RootSVG/RootSVG.d.ts +7 -1
- package/dist/components/RootSVG/RootSVG.js +1 -0
- package/dist/components/Searchbox/Searchbox.context.d.ts +13 -0
- package/dist/components/Searchbox/Searchbox.context.js +11 -0
- package/dist/components/Searchbox/Searchbox.d.ts +16 -12
- package/dist/components/Searchbox/Searchbox.js +25 -29
- package/dist/components/Select/Select.d.ts +18 -5
- package/dist/components/Select/Select.js +8 -9
- package/dist/components/Signpost/Signpost.d.ts +7 -1
- package/dist/components/Signpost/Signpost.js +1 -0
- package/dist/components/SkipNav/SkipNav.d.ts +7 -1
- package/dist/components/SkipNav/SkipNav.js +1 -0
- package/dist/components/Squircle/Squircle.d.ts +7 -1
- package/dist/components/Squircle/Squircle.js +1 -0
- package/dist/components/Tag/Tag.d.ts +7 -1
- package/dist/components/Tag/Tag.js +1 -0
- package/dist/components/TextInput/TextInput.d.ts +4 -3
- package/dist/components/TextInput/TextInput.js +5 -6
- package/dist/components/Textarea/Textarea.d.ts +4 -3
- package/dist/components/Textarea/Textarea.js +4 -7
- package/dist/components/ValidationSummary/ValidationSummary.d.ts +26 -4
- package/dist/components/ValidationSummary/ValidationSummary.js +7 -6
- package/dist/components/icons/AccountCircleFilledIcon.d.ts +1 -1
- package/dist/components/icons/AccountCircleIcon.d.ts +1 -1
- package/dist/components/icons/AccountFilledIcon.d.ts +1 -1
- package/dist/components/icons/AccountIcon.d.ts +1 -1
- package/dist/components/icons/AddIcon.d.ts +1 -1
- package/dist/components/icons/AppsFilledIcon.d.ts +1 -1
- package/dist/components/icons/AppsIcon.d.ts +1 -1
- package/dist/components/icons/ArrowDownIcon.d.ts +1 -1
- package/dist/components/icons/ArrowLeftIcon.d.ts +1 -1
- package/dist/components/icons/ArrowRightIcon.d.ts +1 -1
- package/dist/components/icons/ArrowUpIcon.d.ts +1 -1
- package/dist/components/icons/BackspaceFilledIcon.d.ts +1 -1
- package/dist/components/icons/BackspaceIcon.d.ts +1 -1
- package/dist/components/icons/BasketFilledIcon.d.ts +1 -1
- package/dist/components/icons/BasketIcon.d.ts +1 -1
- package/dist/components/icons/BellFilledIcon.d.ts +1 -1
- package/dist/components/icons/BellIcon.d.ts +1 -1
- package/dist/components/icons/BroomIcon.d.ts +1 -1
- package/dist/components/icons/CalendarFilledIcon.d.ts +1 -1
- package/dist/components/icons/CalendarIcon.d.ts +1 -1
- package/dist/components/icons/CashFilledIcon.d.ts +1 -1
- package/dist/components/icons/CashIcon.d.ts +1 -1
- package/dist/components/icons/ChevronDownIcon.d.ts +1 -1
- package/dist/components/icons/ChevronLeftIcon.d.ts +1 -1
- package/dist/components/icons/ChevronRightIcon.d.ts +1 -1
- package/dist/components/icons/ChevronUpIcon.d.ts +1 -1
- package/dist/components/icons/CircleBurgerFilledIcon.d.ts +1 -1
- package/dist/components/icons/CircleBurgerIcon.d.ts +1 -1
- package/dist/components/icons/ClipboardFilledIcon.d.ts +1 -1
- package/dist/components/icons/ClipboardIcon.d.ts +1 -1
- package/dist/components/icons/ClockFilledIcon.d.ts +1 -1
- package/dist/components/icons/ClockIcon.d.ts +1 -1
- package/dist/components/icons/CloseAltFilledIcon.d.ts +1 -1
- package/dist/components/icons/CloseAltIcon.d.ts +1 -1
- package/dist/components/icons/CogIcon.d.ts +1 -1
- package/dist/components/icons/CommunityFilledIcon.d.ts +1 -1
- package/dist/components/icons/CommunityIcon.d.ts +1 -1
- package/dist/components/icons/ComputerIcon.d.ts +1 -1
- package/dist/components/icons/ContactFilledIcon.d.ts +1 -1
- package/dist/components/icons/ContactIcon.d.ts +1 -1
- package/dist/components/icons/ContactlessFilledIcon.d.ts +1 -1
- package/dist/components/icons/ContactlessIcon.d.ts +1 -1
- package/dist/components/icons/CoopLiveIcon.d.ts +1 -1
- package/dist/components/icons/CoopLocationFilledIcon.d.ts +1 -1
- package/dist/components/icons/CoopLogoIcon.d.ts +1 -1
- package/dist/components/icons/CoopMembershipCardFilledIcon.d.ts +1 -1
- package/dist/components/icons/CreditCardFilledIcon.d.ts +1 -1
- package/dist/components/icons/CreditCardIcon.d.ts +1 -1
- package/dist/components/icons/CrossIcon.d.ts +1 -1
- package/dist/components/icons/DocumentIcon.d.ts +1 -1
- package/dist/components/icons/DownloadIcon.d.ts +1 -1
- package/dist/components/icons/EnterStoreIcon.d.ts +1 -1
- package/dist/components/icons/ExitStoreIcon.d.ts +1 -1
- package/dist/components/icons/EyeFilledIcon.d.ts +1 -1
- package/dist/components/icons/EyeIcon.d.ts +1 -1
- package/dist/components/icons/EyeStrikeFilledIcon.d.ts +1 -1
- package/dist/components/icons/EyeStrikeIcon.d.ts +1 -1
- package/dist/components/icons/FeedbackFilledIcon.d.ts +1 -1
- package/dist/components/icons/FeedbackIcon.d.ts +1 -1
- package/dist/components/icons/FilterIcon.d.ts +1 -1
- package/dist/components/icons/GiftCardFilledIcon.d.ts +1 -1
- package/dist/components/icons/GiftCardIcon.d.ts +1 -1
- package/dist/components/icons/GiftFilledIcon.d.ts +1 -1
- package/dist/components/icons/GiftIcon.d.ts +1 -1
- package/dist/components/icons/HelpFilledIcon.d.ts +1 -1
- package/dist/components/icons/HelpIcon.d.ts +1 -1
- package/dist/components/icons/HomeFilledIcon.d.ts +1 -1
- package/dist/components/icons/HomeIcon.d.ts +1 -1
- package/dist/components/icons/HowDoIAssistantIcon.d.ts +1 -1
- package/dist/components/icons/InfoIcon.d.ts +1 -1
- package/dist/components/icons/KebabIcon.d.ts +1 -1
- package/dist/components/icons/LoadingIcon.d.ts +1 -1
- package/dist/components/icons/LocationFilledIcon.d.ts +1 -1
- package/dist/components/icons/LocationIcon.d.ts +1 -1
- package/dist/components/icons/LogoutIcon.d.ts +1 -1
- package/dist/components/icons/MailIcon.d.ts +1 -1
- package/dist/components/icons/MenuIcon.d.ts +1 -1
- package/dist/components/icons/MessageIcon.d.ts +1 -1
- package/dist/components/icons/MinusIcon.d.ts +1 -1
- package/dist/components/icons/NotesFilledIcon.d.ts +1 -1
- package/dist/components/icons/NotesIcon.d.ts +1 -1
- package/dist/components/icons/OpenNewIcon.d.ts +1 -1
- package/dist/components/icons/OwnBagIcon.d.ts +1 -1
- package/dist/components/icons/PadlockIcon.d.ts +1 -1
- package/dist/components/icons/PencilIcon.d.ts +1 -1
- package/dist/components/icons/PhoneIcon.d.ts +1 -1
- package/dist/components/icons/PowerIcon.d.ts +1 -1
- package/dist/components/icons/SaveFilledIcon.d.ts +1 -1
- package/dist/components/icons/SaveIcon.d.ts +1 -1
- package/dist/components/icons/ScooterIcon.d.ts +1 -1
- package/dist/components/icons/SearchFilledIcon.d.ts +1 -1
- package/dist/components/icons/SearchIcon.d.ts +1 -1
- package/dist/components/icons/SendIcon.d.ts +1 -1
- package/dist/components/icons/SpannerIcon.d.ts +1 -1
- package/dist/components/icons/StarFilledIcon.d.ts +1 -1
- package/dist/components/icons/StarIcon.d.ts +1 -1
- package/dist/components/icons/TickAltFilledIcon.d.ts +1 -1
- package/dist/components/icons/TickAltIcon.d.ts +1 -1
- package/dist/components/icons/TickIcon.d.ts +1 -1
- package/dist/components/icons/TruckIcon.d.ts +1 -1
- package/dist/components/icons/UserWipeIcon.d.ts +1 -1
- package/dist/components/icons/VoucherFilledIcon.d.ts +1 -1
- package/dist/components/icons/VoucherIcon.d.ts +1 -1
- package/dist/components/icons/WarningFilledIcon.d.ts +1 -1
- package/dist/components/icons/WarningIcon.d.ts +1 -1
- package/dist/components/icons/WifiIcon.d.ts +1 -1
- package/dist/components/icons/WriteIcon.d.ts +1 -1
- package/dist/hooks/useSlots.d.ts +4 -2
- package/dist/hooks/useSlots.js +33 -7
- package/dist/index.js +10 -10
- package/dist/types/index.d.ts +14 -14
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +9 -7
- package/package.json +12 -11
- package/src/components/AlertBanner/AlertBanner.tsx +5 -2
- package/src/components/Author/Author.tsx +4 -1
- package/src/components/Button/Button.tsx +5 -1
- package/src/components/Card/Card.tsx +8 -6
- package/src/components/Checkbox/Checkbox.tsx +13 -9
- package/src/components/DatePicker/DatePicker.tsx +15 -15
- package/src/components/Expandable/Expandable.tsx +5 -8
- package/src/components/Field/Field.context.ts +29 -0
- package/src/components/Field/Field.tsx +61 -56
- package/src/components/FieldMarkers/Label.tsx +4 -0
- package/src/components/Fieldset/Fieldset.tsx +7 -5
- package/src/components/Flourish/Flourish.tsx +4 -1
- package/src/components/Form/Form.tsx +4 -1
- package/src/components/Image/Image.tsx +4 -1
- package/src/components/Pill/Pill.tsx +4 -2
- package/src/components/Popover/Popover.tsx +7 -5
- package/src/components/Radio/Radio.tsx +12 -9
- package/src/components/RootSVG/RootSVG.tsx +4 -1
- package/src/components/Searchbox/Searchbox.context.tsx +20 -0
- package/src/components/Searchbox/Searchbox.tsx +55 -44
- package/src/components/Select/Select.tsx +11 -11
- package/src/components/Signpost/Signpost.tsx +4 -1
- package/src/components/SkipNav/SkipNav.tsx +4 -1
- package/src/components/Squircle/Squircle.tsx +4 -1
- package/src/components/Tag/Tag.tsx +4 -1
- package/src/components/TextInput/TextInput.tsx +8 -8
- package/src/components/Textarea/Textarea.tsx +7 -8
- package/src/components/ValidationSummary/ValidationSummary.tsx +12 -5
- package/src/hooks/useSlots.ts +37 -9
- package/src/types/index.ts +18 -14
- package/src/utils/index.ts +8 -6
- 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
58
|
+
slot: {
|
|
56
59
|
name: string;
|
|
57
60
|
};
|
|
58
61
|
};
|
|
59
62
|
Heading: {
|
|
60
63
|
({ as, children, className }: CardHeadingProps): JSX.Element;
|
|
61
|
-
|
|
64
|
+
slot: {
|
|
62
65
|
name: string;
|
|
63
66
|
};
|
|
64
67
|
};
|
|
65
68
|
Badge: {
|
|
66
69
|
({ align, children, position, ...props }: CardBadgeProps): JSX.Element;
|
|
67
|
-
|
|
70
|
+
slot: {
|
|
68
71
|
name: string;
|
|
69
72
|
};
|
|
70
73
|
};
|
|
71
74
|
Body: {
|
|
72
75
|
({ children }: CardBodyProps): JSX.Element;
|
|
73
|
-
|
|
76
|
+
slot: {
|
|
74
77
|
name: string;
|
|
75
78
|
};
|
|
76
79
|
};
|
|
77
80
|
Image: {
|
|
78
|
-
(props: CardImageProps):
|
|
79
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
19
|
+
declare const Checkbox: {
|
|
20
20
|
({ className, disabled, error, id, name, ref, size, ...props }: CheckboxProps): JSX.Element;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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 {
|
|
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
|
|
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:
|
|
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.
|
|
20
|
-
|
|
21
|
-
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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:
|
|
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:
|
|
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 +
|
|
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: `${
|
|
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
|
-
|
|
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):
|
|
26
|
-
|
|
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):
|
|
32
|
-
|
|
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
|
-
|
|
30
|
-
|
|
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
|
-
|
|
23
|
-
({ boxed, children, className, error, hideErrorBar, ref, ...props }: FieldProps):
|
|
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):
|
|
26
|
-
|
|
28
|
+
(props: LabelProps): React.JSX.Element;
|
|
29
|
+
slot: {
|
|
27
30
|
name: string;
|
|
28
31
|
};
|
|
29
32
|
};
|
|
30
33
|
Hint: {
|
|
31
|
-
(props: HintProps):
|
|
32
|
-
|
|
34
|
+
(props: HintProps): React.JSX.Element;
|
|
35
|
+
slot: {
|
|
33
36
|
name: string;
|
|
34
37
|
};
|
|
35
38
|
};
|
|
36
39
|
Error: {
|
|
37
|
-
(props: ErrorProps):
|
|
38
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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":
|
|
54
|
-
className: clsx("coop-field",
|
|
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: [!
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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 };
|
|
@@ -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
|
|
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
|
|
12
|
+
export declare const Legend: ({ children, className, isVisible, ref, ...props }: LegendProps) => import("react").JSX.Element;
|
|
13
13
|
export default Legend;
|