@coopdigital/react 0.13.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,7 +26,7 @@ const Button = (_a) => {
26
26
  setIsPending(false);
27
27
  }
28
28
  }), [onClick, isPending]);
29
- const componentProps = Object.assign({ "aria-disabled": isDisabled ? true : undefined, "aria-label": ariaLabel, "aria-live": "assertive", className: `${variant == "text" ? "coop-link" : "coop-button"} ${className}`, "data-loading": isLoading || isPending ? true : undefined, "data-size": size.length && size != "md" ? size : undefined, "data-variant": variant !== "text" ? variant : undefined, "data-width": isFullWidth ? "full" : undefined, href, onClick: handleClick }, props);
29
+ const componentProps = Object.assign({ "aria-disabled": isDisabled ? true : undefined, "aria-label": ariaLabel, "aria-live": "assertive", className: `${variant == "text" ? "coop-link" : "coop-button"} ${className}`, "data-loading": isLoading || isPending ? true : undefined, "data-size": size.length && size !== "md" ? size : undefined, "data-variant": variant !== "text" ? variant : undefined, "data-width": isFullWidth ? "full" : undefined, href, onClick: handleClick }, props);
30
30
  const finalChildren = isPending || isLoading ? (jsxs(Fragment, { children: [loadingText, jsx(LoadingIcon, {})] })) : (children);
31
31
  return React.createElement(element, Object.assign({}, componentProps), finalChildren);
32
32
  };
@@ -11,6 +11,7 @@ function getCardLinkElement(as, href) {
11
11
  return {
12
12
  element,
13
13
  props: {
14
+ className: "coop-card--link",
14
15
  href,
15
16
  },
16
17
  };
@@ -22,7 +23,7 @@ const Card = (_a) => {
22
23
  var { as, background, badge, badgePosition = "inset", chevron = false, children, heading, headingLevel = "h3", href, image, imagePosition = "left", label = "", labelBackground, layout = "vertical" } = _a, props = __rest(_a, ["as", "background", "badge", "badgePosition", "chevron", "children", "heading", "headingLevel", "href", "image", "imagePosition", "label", "labelBackground", "layout"]);
23
24
  const linkElement = getCardLinkElement(as, href);
24
25
  const imageProps = Object.assign({ crop: "wide" }, image);
25
- const componentProps = Object.assign({ className: "coop-card", "data-badge-pos": badgePosition, "data-bg": background, "data-image-pos": imagePosition, "data-label-bg": labelBackground, "data-layout": layout }, props);
26
+ const componentProps = Object.assign({ className: "coop-card", "data-badge-pos": badgePosition, "data-bg": background, "data-image-pos": imagePosition, "data-label-bg": labelBackground, "data-layout": layout !== "vertical" ? layout : undefined }, props);
26
27
  return (jsxs("article", Object.assign({}, componentProps, { children: [image && jsx(Image, Object.assign({}, imageProps)), badge && jsx("div", { className: "coop-card--badge", children: badge }), jsxs("div", { className: "coop-card--inner", children: [jsxs("div", { className: "coop-card--content", children: [label && jsx("span", { className: "coop-card--label", children: label }), React.createElement(linkElement.element, linkElement.props, React.createElement(headingLevel, { className: "coop-card--heading" }, heading)), children] }), chevron && (jsx("span", { "aria-hidden": "true", className: "coop-card--icon", role: "presentation", children: jsx("svg", { viewBox: "0 0 16 29", children: jsx("path", { d: "M2 28.1a1.6 1.6 0 0 1-1.2-2.7l11-10.9-11-11A1.6 1.6 0 1 1 3 1.5l12 12a1.6 1.6 0 0 1 0 2.2l-12 12c-.3.4-.7.5-1 .5z" }) }) }))] })] })));
27
28
  };
28
29
 
@@ -0,0 +1,15 @@
1
+ import type { DetailsHTMLAttributes, JSX } from "react";
2
+ export interface ExpandableProps extends DetailsHTMLAttributes<HTMLDetailsElement> {
3
+ /** **(Optional)** Specifies the Expandable background color from the available options. */
4
+ background?: "grey" | "purple" | "pink" | "green" | "orange" | "red" | "yellow" | "lilac" | "blue";
5
+ /** Represents the content inside the Expandable component, only visible when expanded. It can be any valid JSX or string. */
6
+ children: React.ReactNode;
7
+ /** Specifies summary for this component. It can be any valid JSX or string. */
8
+ summary: React.ReactNode;
9
+ }
10
+ /**
11
+ * The Expandable component wraps content in an expandable block using the details/summary HTML elements.
12
+ * It can be used to reveal more context for a specific issue or action.
13
+ */
14
+ export declare const Expandable: ({ background, children, className, summary, ...props }: ExpandableProps) => JSX.Element;
15
+ export default Expandable;
@@ -0,0 +1,14 @@
1
+ import { __rest } from '../../node_modules/tslib/tslib.es6.js';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+
4
+ /**
5
+ * The Expandable component wraps content in an expandable block using the details/summary HTML elements.
6
+ * It can be used to reveal more context for a specific issue or action.
7
+ */
8
+ const Expandable = (_a) => {
9
+ var { background, children, className, summary } = _a, props = __rest(_a, ["background", "children", "className", "summary"]);
10
+ const componentProps = Object.assign({ className: `coop-expandable ${className}`, "data-bg": background }, props);
11
+ return (jsxs("details", Object.assign({}, componentProps, { children: [jsxs("summary", { children: [summary, jsx("svg", { fill: "none", height: "24", width: "24", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "m20.25 9.75-6.22 6.22a.75.75 0 0 1-1.06 0L6.75 9.75", stroke: "black", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "1.5" }) })] }), jsx("div", { className: "coop-expandable--content", children: children })] })));
12
+ };
13
+
14
+ export { Expandable, Expandable as default };
@@ -0,0 +1,4 @@
1
+ import Expandable from "./Expandable";
2
+ export default Expandable;
3
+ export { Expandable };
4
+ export * from "./Expandable";
@@ -10,7 +10,7 @@ const Pill = (_a) => {
10
10
  if (as) {
11
11
  element = as;
12
12
  }
13
- const componentProps = Object.assign({ "aria-label": ariaLabel, className: `coop-pill ${className}`, "data-badge": (badge === null || badge === void 0 ? void 0 : badge.length) ? badge : undefined, "data-badge-color": badgeColor, "data-pill-color": pillColor, "data-size": size.length && size != "md" ? size : undefined, href }, props);
13
+ const componentProps = Object.assign({ "aria-label": ariaLabel, className: `coop-pill ${className}`, "data-badge": (badge === null || badge === void 0 ? void 0 : badge.length) ? badge : undefined, "data-badge-color": badgeColor, "data-pill-color": pillColor, "data-size": size.length && size !== "md" ? size : undefined, href }, props);
14
14
  return React.createElement(element, Object.assign({}, componentProps), children);
15
15
  };
16
16
 
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./components/AlertBanner";
2
2
  export * from "./components/Author";
3
3
  export * from "./components/Button";
4
4
  export * from "./components/Card";
5
+ export * from "./components/Expandable";
5
6
  export * from "./components/Image";
6
7
  export * from "./components/Pill";
7
8
  export * from "./components/RootSVG";
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ export { AlertBanner } from './components/AlertBanner/AlertBanner.js';
2
2
  export { Author } from './components/Author/Author.js';
3
3
  export { Button } from './components/Button/Button.js';
4
4
  export { Card } from './components/Card/Card.js';
5
+ export { Expandable } from './components/Expandable/Expandable.js';
5
6
  export { Image } from './components/Image/Image.js';
6
7
  export { Pill } from './components/Pill/Pill.js';
7
8
  export { default as RootSVG } from './components/RootSVG/RootSVG.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coopdigital/react",
3
3
  "type": "module",
4
- "version": "0.13.1",
4
+ "version": "0.15.0",
5
5
  "private": false,
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -44,7 +44,7 @@
44
44
  "description": "",
45
45
  "devDependencies": {
46
46
  "@axe-core/playwright": "^4.10.1",
47
- "@coopdigital/styles": "^0.12.1",
47
+ "@coopdigital/styles": "^0.14.0",
48
48
  "@playwright/test": "^1.51.1",
49
49
  "@storybook/addon-a11y": "^8.6.12",
50
50
  "@storybook/addon-essentials": "^8.6.12",
@@ -66,5 +66,5 @@
66
66
  "react": "^19.0.0",
67
67
  "react-dom": "^19.0.0"
68
68
  },
69
- "gitHead": "6de4fec609f8afd7048d63152394a25392d50212"
69
+ "gitHead": "86b6861deb12d0f826dfd719fb28a754fda81cbd"
70
70
  }
@@ -101,7 +101,7 @@ export const Button = ({
101
101
  "aria-live": "assertive" as keyof ButtonHTMLAttributes<HTMLButtonElement>["aria-live"],
102
102
  className: `${variant == "text" ? "coop-link" : "coop-button"} ${className}`,
103
103
  "data-loading": isLoading || isPending ? true : undefined,
104
- "data-size": size.length && size != "md" ? size : undefined,
104
+ "data-size": size.length && size !== "md" ? size : undefined,
105
105
  "data-variant": variant !== "text" ? variant : undefined,
106
106
  "data-width": isFullWidth ? "full" : undefined,
107
107
  href,
@@ -47,6 +47,7 @@ function getCardLinkElement(as: CardProps["as"], href?: string) {
47
47
  return {
48
48
  element,
49
49
  props: {
50
+ className: "coop-card--link",
50
51
  href,
51
52
  },
52
53
  }
@@ -85,7 +86,7 @@ export const Card = ({
85
86
  "data-bg": background,
86
87
  "data-image-pos": imagePosition,
87
88
  "data-label-bg": labelBackground,
88
- "data-layout": layout,
89
+ "data-layout": layout !== "vertical" ? layout : undefined,
89
90
  ...props,
90
91
  }
91
92
 
@@ -0,0 +1,48 @@
1
+ import type { DetailsHTMLAttributes, JSX } from "react"
2
+
3
+ export interface ExpandableProps extends DetailsHTMLAttributes<HTMLDetailsElement> {
4
+ /** **(Optional)** Specifies the Expandable background color from the available options. */
5
+ background?: "grey" | "purple" | "pink" | "green" | "orange" | "red" | "yellow" | "lilac" | "blue"
6
+ /** Represents the content inside the Expandable component, only visible when expanded. It can be any valid JSX or string. */
7
+ children: React.ReactNode
8
+ /** Specifies summary for this component. It can be any valid JSX or string. */
9
+ summary: React.ReactNode
10
+ }
11
+
12
+ /**
13
+ * The Expandable component wraps content in an expandable block using the details/summary HTML elements.
14
+ * It can be used to reveal more context for a specific issue or action.
15
+ */
16
+
17
+ export const Expandable = ({
18
+ background,
19
+ children,
20
+ className,
21
+ summary,
22
+ ...props
23
+ }: ExpandableProps): JSX.Element => {
24
+ const componentProps = {
25
+ className: `coop-expandable ${className}`,
26
+ "data-bg": background,
27
+ ...props,
28
+ }
29
+ return (
30
+ <details {...componentProps}>
31
+ <summary>
32
+ {summary}
33
+ <svg fill="none" height="24" width="24" xmlns="http://www.w3.org/2000/svg">
34
+ <path
35
+ d="m20.25 9.75-6.22 6.22a.75.75 0 0 1-1.06 0L6.75 9.75"
36
+ stroke="black"
37
+ strokeLinecap="round"
38
+ strokeLinejoin="round"
39
+ strokeWidth="1.5"
40
+ />
41
+ </svg>
42
+ </summary>
43
+ <div className="coop-expandable--content">{children}</div>
44
+ </details>
45
+ )
46
+ }
47
+
48
+ export default Expandable
@@ -0,0 +1,5 @@
1
+ import Expandable from "./Expandable"
2
+
3
+ export default Expandable
4
+ export { Expandable }
5
+ export * from "./Expandable"
@@ -51,7 +51,7 @@ export const Pill = ({
51
51
  "data-badge": badge?.length ? badge : undefined,
52
52
  "data-badge-color": badgeColor,
53
53
  "data-pill-color": pillColor,
54
- "data-size": size.length && size != "md" ? size : undefined,
54
+ "data-size": size.length && size !== "md" ? size : undefined,
55
55
  href,
56
56
  ...props,
57
57
  }
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./components/AlertBanner"
2
2
  export * from "./components/Author"
3
3
  export * from "./components/Button"
4
4
  export * from "./components/Card"
5
+ export * from "./components/Expandable"
5
6
  export * from "./components/Image"
6
7
  export * from "./components/Pill"
7
8
  export * from "./components/RootSVG"