@coopdigital/react 1.15.2 → 1.16.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/Card/Card.js +9 -12
- package/dist/components/Checkbox/Checkbox.js +1 -1
- package/dist/components/Field/Field.js +11 -20
- package/dist/components/Radio/Radio.js +1 -1
- package/dist/components/Select/Select.js +1 -1
- package/dist/components/TextInput/TextInput.js +5 -2
- package/dist/components/Textarea/Textarea.js +1 -1
- package/dist/components/ValidationSummary/ValidationSummary.js +5 -5
- package/package.json +3 -3
- package/src/components/Card/Card.tsx +10 -9
- package/src/components/Checkbox/Checkbox.tsx +1 -1
- package/src/components/Field/Field.tsx +6 -6
- package/src/components/Radio/Radio.tsx +1 -1
- package/src/components/Select/Select.tsx +1 -1
- package/src/components/TextInput/TextInput.tsx +4 -2
- package/src/components/Textarea/Textarea.tsx +1 -1
- package/src/components/ValidationSummary/ValidationSummary.tsx +5 -7
|
@@ -26,7 +26,6 @@ function getCardLinkElement(as, href) {
|
|
|
26
26
|
const Card = ({ adaptive, chevron = false, children, className, href, hrefAs, orientation, ref, signpost, ...props }) => {
|
|
27
27
|
const { element: linkElement, props: linkProps } = getCardLinkElement(hrefAs, href);
|
|
28
28
|
const slots = { ...useSlots(componentSlots, children) };
|
|
29
|
-
const innerProps = { className: "coop-card--inner" };
|
|
30
29
|
const hasLinkWrapper = href && !slots.CardHeading;
|
|
31
30
|
const componentProps = {
|
|
32
31
|
className: clsx("coop-card", !hasUserBg(className) && "bg-white", className),
|
|
@@ -43,22 +42,20 @@ const Card = ({ adaptive, chevron = false, children, className, href, hrefAs, or
|
|
|
43
42
|
slots.CardImage,
|
|
44
43
|
slots.CardBadge,
|
|
45
44
|
React.createElement(hasLinkWrapper ? linkElement : "div", hasLinkWrapper ? {
|
|
46
|
-
href,
|
|
47
|
-
...innerProps
|
|
48
|
-
} : innerProps, /* @__PURE__ */ jsxs("div", {
|
|
49
45
|
className: "coop-card--content",
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
})
|
|
46
|
+
href
|
|
47
|
+
} : { className: "coop-card--content" }, /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
48
|
+
slots.CardLabel,
|
|
49
|
+
slots.CardHeading,
|
|
50
|
+
slots.CardBody,
|
|
51
|
+
slots.Children
|
|
52
|
+
] })),
|
|
53
|
+
(chevron || signpost) && /* @__PURE__ */ jsx("span", {
|
|
57
54
|
"aria-hidden": "true",
|
|
58
55
|
className: "coop-card--icon",
|
|
59
56
|
role: "presentation",
|
|
60
57
|
children: /* @__PURE__ */ jsx(ChevronRightIcon, {})
|
|
61
|
-
})
|
|
58
|
+
})
|
|
62
59
|
]
|
|
63
60
|
});
|
|
64
61
|
};
|
|
@@ -6,7 +6,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
6
|
const Checkbox = ({ className, disabled, error = false, id, name, ref, size, ...props }) => {
|
|
7
7
|
const field = useField();
|
|
8
8
|
return /* @__PURE__ */ jsx("input", {
|
|
9
|
-
className: clsx("coop-checkbox",
|
|
9
|
+
className: clsx("coop-checkbox", className),
|
|
10
10
|
"data-error": error || void 0,
|
|
11
11
|
"data-size": size ?? void 0,
|
|
12
12
|
disabled,
|
|
@@ -7,7 +7,7 @@ import { Error } from "../FieldMarkers/Error.js";
|
|
|
7
7
|
import { Hint } from "../FieldMarkers/Hint.js";
|
|
8
8
|
import { Label } from "../FieldMarkers/Label.js";
|
|
9
9
|
import clsx from "clsx";
|
|
10
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import "react";
|
|
12
12
|
//#region src/components/Field/Field.tsx
|
|
13
13
|
const componentSlots = {
|
|
@@ -54,25 +54,16 @@ const Field = ({ boxed = false, children, className, error = false, hideErrorBar
|
|
|
54
54
|
...componentProps,
|
|
55
55
|
ref,
|
|
56
56
|
children: [
|
|
57
|
-
!controlProps?.inline && hasMarkers && /* @__PURE__ */ jsxs(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
children: [slots.Control, controlProps?.inline && hasMarkers && /* @__PURE__ */ jsxs("div", {
|
|
68
|
-
className: "coop-field-markers",
|
|
69
|
-
children: [
|
|
70
|
-
slots.FieldLabel,
|
|
71
|
-
slots.FieldHint,
|
|
72
|
-
slots.FieldError
|
|
73
|
-
]
|
|
74
|
-
})]
|
|
75
|
-
}),
|
|
57
|
+
!controlProps?.inline && hasMarkers && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
58
|
+
slots.FieldLabel,
|
|
59
|
+
slots.FieldHint,
|
|
60
|
+
slots.FieldError
|
|
61
|
+
] }),
|
|
62
|
+
slots.Control && /* @__PURE__ */ jsxs(Fragment, { children: [slots.Control, controlProps?.inline && hasMarkers && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
63
|
+
slots.FieldLabel,
|
|
64
|
+
slots.FieldHint,
|
|
65
|
+
slots.FieldError
|
|
66
|
+
] })] }),
|
|
76
67
|
slots.Children
|
|
77
68
|
]
|
|
78
69
|
})
|
|
@@ -6,7 +6,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
6
|
const Radio = ({ className, disabled, error = false, id, name, ref, size, ...props }) => {
|
|
7
7
|
const field = useField();
|
|
8
8
|
return /* @__PURE__ */ jsx("input", {
|
|
9
|
-
className: clsx("coop-radio",
|
|
9
|
+
className: clsx("coop-radio", className),
|
|
10
10
|
"data-error": error || void 0,
|
|
11
11
|
"data-size": size ?? void 0,
|
|
12
12
|
disabled,
|
|
@@ -6,7 +6,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
6
|
const Select = ({ children, className, disabled, error, fit = false, id, name, ref, size, ...props }) => {
|
|
7
7
|
const field = useField();
|
|
8
8
|
return /* @__PURE__ */ jsx("select", {
|
|
9
|
-
className: clsx("coop-select",
|
|
9
|
+
className: clsx("coop-select", className),
|
|
10
10
|
"data-error": error ?? void 0,
|
|
11
11
|
"data-fit": fit || void 0,
|
|
12
12
|
"data-size": size ?? void 0,
|
|
@@ -7,7 +7,7 @@ const TextInput = ({ "aria-placeholder": ariaPlaceholder, className, disabled, e
|
|
|
7
7
|
const field = useField();
|
|
8
8
|
const componentProps = {
|
|
9
9
|
"aria-placeholder": placeholder ?? ariaPlaceholder ?? void 0,
|
|
10
|
-
className: clsx("coop-text-input",
|
|
10
|
+
className: clsx("coop-text-input", className),
|
|
11
11
|
"data-error": error || void 0,
|
|
12
12
|
"data-fit": fit || void 0,
|
|
13
13
|
"data-size": size?.length ? size : void 0,
|
|
@@ -26,7 +26,7 @@ const TextInput = ({ "aria-placeholder": ariaPlaceholder, className, disabled, e
|
|
|
26
26
|
className: "coop-text-input--suffix",
|
|
27
27
|
"data-inline": suffixInline || void 0
|
|
28
28
|
} : {};
|
|
29
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
29
|
+
return prefix || suffix ? /* @__PURE__ */ jsxs("div", {
|
|
30
30
|
className: "coop-text-input-wrapper",
|
|
31
31
|
children: [
|
|
32
32
|
prefix && /* @__PURE__ */ jsx("span", {
|
|
@@ -42,6 +42,9 @@ const TextInput = ({ "aria-placeholder": ariaPlaceholder, className, disabled, e
|
|
|
42
42
|
children: suffix
|
|
43
43
|
})
|
|
44
44
|
]
|
|
45
|
+
}) : /* @__PURE__ */ jsx("input", {
|
|
46
|
+
...componentProps,
|
|
47
|
+
ref
|
|
45
48
|
});
|
|
46
49
|
};
|
|
47
50
|
TextInput.slot = { name: "TextInput" };
|
|
@@ -13,7 +13,7 @@ const Textarea = ({ "aria-placeholder": ariaPlaceholder, className, cols = 30, c
|
|
|
13
13
|
const field = useField();
|
|
14
14
|
const componentProps = {
|
|
15
15
|
"aria-placeholder": placeholder ?? ariaPlaceholder ?? void 0,
|
|
16
|
-
className: clsx("coop-textarea",
|
|
16
|
+
className: clsx("coop-textarea", className),
|
|
17
17
|
cols,
|
|
18
18
|
"data-error": error ?? void 0,
|
|
19
19
|
"data-fit": fit || void 0,
|
|
@@ -30,7 +30,7 @@ const ValidationSummary = ({ autoScroll = true, children, className, forceMount
|
|
|
30
30
|
]);
|
|
31
31
|
if (!hasErrors && !forceMount) return null;
|
|
32
32
|
return /* @__PURE__ */ jsxs("div", {
|
|
33
|
-
className: clsx("coop-validation-summary
|
|
33
|
+
className: clsx("coop-validation-summary", className),
|
|
34
34
|
...props,
|
|
35
35
|
"aria-live": "assertive",
|
|
36
36
|
ref: mergeRefs(internalRef, ref),
|
|
@@ -44,11 +44,11 @@ const ValidationSummary = ({ autoScroll = true, children, className, forceMount
|
|
|
44
44
|
]
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
|
-
const ValidationSummaryHeading = ({ as = "h2", children
|
|
48
|
-
return React.createElement(as, { className: clsx("coop-validation-summary--heading", className) }, children);
|
|
47
|
+
const ValidationSummaryHeading = ({ as = "h2", children, className }) => {
|
|
48
|
+
return React.createElement(as, { className: clsx("coop-validation-summary--heading", className) }, children ?? "There's a problem");
|
|
49
49
|
};
|
|
50
|
-
const ValidationSummaryPrompt = ({ children
|
|
51
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
50
|
+
const ValidationSummaryPrompt = ({ children }) => {
|
|
51
|
+
return children ? /* @__PURE__ */ jsx(Fragment, { children }) : /* @__PURE__ */ jsx("p", { children: "Check the form. You must:" });
|
|
52
52
|
};
|
|
53
53
|
const focusable = [
|
|
54
54
|
"INPUT",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coopdigital/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.16.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -102,12 +102,12 @@
|
|
|
102
102
|
"storybook": "$storybook"
|
|
103
103
|
},
|
|
104
104
|
"dependencies": {
|
|
105
|
-
"@coopdigital/styles": "^1.
|
|
105
|
+
"@coopdigital/styles": "^1.12.1",
|
|
106
106
|
"@radix-ui/react-popover": "^1.1.23",
|
|
107
107
|
"clsx": "^2.1.1",
|
|
108
108
|
"date-fns": "^4.4.0",
|
|
109
109
|
"merge-refs": "^2.0.0",
|
|
110
110
|
"react-day-picker": "^10.0.1"
|
|
111
111
|
},
|
|
112
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "f55d477f98dd57a88d7527a208b33abbf8be3ef8"
|
|
113
113
|
}
|
|
@@ -112,7 +112,6 @@ const Card = ({
|
|
|
112
112
|
const { element: linkElement, props: linkProps } = getCardLinkElement(hrefAs, href)
|
|
113
113
|
|
|
114
114
|
const slots = { ...useSlots(componentSlots, children) }
|
|
115
|
-
const innerProps = { className: "coop-card--inner" }
|
|
116
115
|
const hasLinkWrapper = href && !slots.CardHeading
|
|
117
116
|
|
|
118
117
|
const componentProps = {
|
|
@@ -134,18 +133,20 @@ const Card = ({
|
|
|
134
133
|
{slots.CardBadge}
|
|
135
134
|
{React.createElement(
|
|
136
135
|
hasLinkWrapper ? linkElement : "div",
|
|
137
|
-
hasLinkWrapper
|
|
138
|
-
|
|
136
|
+
hasLinkWrapper
|
|
137
|
+
? { className: "coop-card--content", href }
|
|
138
|
+
: { className: "coop-card--content" },
|
|
139
|
+
<>
|
|
139
140
|
{slots.CardLabel}
|
|
140
141
|
{slots.CardHeading}
|
|
141
142
|
{slots.CardBody}
|
|
142
143
|
{slots.Children}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
</>
|
|
145
|
+
)}
|
|
146
|
+
{(chevron || signpost) && (
|
|
147
|
+
<span aria-hidden="true" className="coop-card--icon" role="presentation">
|
|
148
|
+
<ChevronRightIcon />
|
|
149
|
+
</span>
|
|
149
150
|
)}
|
|
150
151
|
</article>
|
|
151
152
|
)
|
|
@@ -39,7 +39,7 @@ const Checkbox = ({
|
|
|
39
39
|
const field = useField()
|
|
40
40
|
|
|
41
41
|
const componentProps = {
|
|
42
|
-
className: clsx("coop-checkbox",
|
|
42
|
+
className: clsx("coop-checkbox", className),
|
|
43
43
|
"data-error": error || undefined,
|
|
44
44
|
"data-size": size ?? undefined,
|
|
45
45
|
disabled,
|
|
@@ -95,23 +95,23 @@ const Field = ({
|
|
|
95
95
|
<FieldContext.Provider value={{ ...controlProps }}>
|
|
96
96
|
<div {...componentProps} ref={ref}>
|
|
97
97
|
{!controlProps?.inline && hasMarkers && (
|
|
98
|
-
|
|
98
|
+
<>
|
|
99
99
|
{slots.FieldLabel}
|
|
100
100
|
{slots.FieldHint}
|
|
101
101
|
{slots.FieldError}
|
|
102
|
-
|
|
102
|
+
</>
|
|
103
103
|
)}
|
|
104
104
|
{slots.Control && (
|
|
105
|
-
|
|
105
|
+
<>
|
|
106
106
|
{slots.Control}
|
|
107
107
|
{controlProps?.inline && hasMarkers && (
|
|
108
|
-
|
|
108
|
+
<>
|
|
109
109
|
{slots.FieldLabel}
|
|
110
110
|
{slots.FieldHint}
|
|
111
111
|
{slots.FieldError}
|
|
112
|
-
|
|
112
|
+
</>
|
|
113
113
|
)}
|
|
114
|
-
|
|
114
|
+
</>
|
|
115
115
|
)}
|
|
116
116
|
{slots.Children}
|
|
117
117
|
</div>
|
|
@@ -35,7 +35,7 @@ const Radio = ({
|
|
|
35
35
|
const field = useField()
|
|
36
36
|
|
|
37
37
|
const componentProps = {
|
|
38
|
-
className: clsx("coop-radio",
|
|
38
|
+
className: clsx("coop-radio", className),
|
|
39
39
|
"data-error": error || undefined,
|
|
40
40
|
"data-size": size ?? undefined,
|
|
41
41
|
disabled,
|
|
@@ -68,7 +68,7 @@ const Select = ({
|
|
|
68
68
|
const field = useField()
|
|
69
69
|
|
|
70
70
|
const componentProps = {
|
|
71
|
-
className: clsx("coop-select",
|
|
71
|
+
className: clsx("coop-select", className),
|
|
72
72
|
"data-error": error ?? undefined,
|
|
73
73
|
"data-fit": fit || undefined,
|
|
74
74
|
"data-size": size ?? undefined,
|
|
@@ -77,7 +77,7 @@ const TextInput = ({
|
|
|
77
77
|
|
|
78
78
|
const componentProps = {
|
|
79
79
|
"aria-placeholder": placeholder ?? ariaPlaceholder ?? undefined,
|
|
80
|
-
className: clsx("coop-text-input",
|
|
80
|
+
className: clsx("coop-text-input", className),
|
|
81
81
|
"data-error": error || undefined,
|
|
82
82
|
"data-fit": fit || undefined,
|
|
83
83
|
"data-size": size?.length ? size : undefined,
|
|
@@ -99,12 +99,14 @@ const TextInput = ({
|
|
|
99
99
|
|
|
100
100
|
//const formItemProps = { "aria-disabled": disabled ? true : undefined }
|
|
101
101
|
|
|
102
|
-
return (
|
|
102
|
+
return prefix || suffix ? (
|
|
103
103
|
<div className="coop-text-input-wrapper">
|
|
104
104
|
{prefix && <span {...prefixProps}>{prefix}</span>}
|
|
105
105
|
<input {...componentProps} ref={ref} />
|
|
106
106
|
{suffix && <span {...suffixProps}>{suffix}</span>}
|
|
107
107
|
</div>
|
|
108
|
+
) : (
|
|
109
|
+
<input {...componentProps} ref={ref} />
|
|
108
110
|
)
|
|
109
111
|
}
|
|
110
112
|
|
|
@@ -75,7 +75,7 @@ const Textarea = ({
|
|
|
75
75
|
|
|
76
76
|
const componentProps = {
|
|
77
77
|
"aria-placeholder": placeholder ?? ariaPlaceholder ?? undefined,
|
|
78
|
-
className: clsx("coop-textarea",
|
|
78
|
+
className: clsx("coop-textarea", className),
|
|
79
79
|
cols,
|
|
80
80
|
"data-error": error ?? undefined,
|
|
81
81
|
"data-fit": fit || undefined,
|
|
@@ -101,7 +101,7 @@ const ValidationSummary = ({
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
const componentProps = {
|
|
104
|
-
className: clsx("coop-validation-summary
|
|
104
|
+
className: clsx("coop-validation-summary", className),
|
|
105
105
|
...props,
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -123,20 +123,18 @@ const ValidationSummary = ({
|
|
|
123
123
|
|
|
124
124
|
const ValidationSummaryHeading = ({
|
|
125
125
|
as = "h2",
|
|
126
|
-
children
|
|
126
|
+
children,
|
|
127
127
|
className,
|
|
128
128
|
}: ValidationSummaryHeadingProps): JSX.Element => {
|
|
129
129
|
return React.createElement(
|
|
130
130
|
as,
|
|
131
131
|
{ className: clsx("coop-validation-summary--heading", className) },
|
|
132
|
-
children
|
|
132
|
+
children ?? "There's a problem"
|
|
133
133
|
)
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
const ValidationSummaryPrompt = ({
|
|
137
|
-
children
|
|
138
|
-
}: ValidationSummaryPromptProps): JSX.Element => {
|
|
139
|
-
return <>{children}</>
|
|
136
|
+
const ValidationSummaryPrompt = ({ children }: ValidationSummaryPromptProps): JSX.Element => {
|
|
137
|
+
return children ? <>{children}</> : <p>Check the form. You must:</p>
|
|
140
138
|
}
|
|
141
139
|
|
|
142
140
|
const focusable = ["INPUT", "TEXTAREA", "SELECT"]
|