@jobber/components 6.89.0 → 6.90.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.
- package/dist/Card/CardClickable.d.ts +3 -1
- package/dist/Card/CardHeader.d.ts +1 -1
- package/dist/Card/types.d.ts +19 -1
- package/dist/Card-cjs.js +14 -13
- package/dist/Card-es.js +14 -13
- package/package.json +2 -2
|
@@ -4,10 +4,12 @@ interface ClickableCardProps {
|
|
|
4
4
|
onClick(event: React.MouseEvent<HTMLElement>): void;
|
|
5
5
|
readonly className: string;
|
|
6
6
|
readonly children: ReactNode | ReactNode[];
|
|
7
|
+
readonly UNSAFE_className?: string;
|
|
8
|
+
readonly UNSAFE_style?: React.CSSProperties;
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* This is only intended to be used in the Card component.
|
|
10
12
|
* Please use `<Card onClick={onClick} />` component instead.
|
|
11
13
|
*/
|
|
12
|
-
export declare function CardClickable({ className, onClick, children, }: ClickableCardProps): React.JSX.Element;
|
|
14
|
+
export declare function CardClickable({ className, onClick, children, UNSAFE_style, }: ClickableCardProps): React.JSX.Element;
|
|
13
15
|
export {};
|
|
@@ -4,4 +4,4 @@ import type { CardProps } from "./types";
|
|
|
4
4
|
* Intended to be used in the Card component.
|
|
5
5
|
* Use `<Card header={header} />` component instead.
|
|
6
6
|
*/
|
|
7
|
-
export declare function CardHeader({ title, header, }: Pick<CardProps, "title" | "header">): React.JSX.Element;
|
|
7
|
+
export declare function CardHeader({ title, header, UNSAFE_className, UNSAFE_style, }: Pick<CardProps, "title" | "header" | "UNSAFE_className" | "UNSAFE_style">): React.JSX.Element;
|
package/dist/Card/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReactElement, ReactNode } from "react";
|
|
1
|
+
import type { CSSProperties, ReactElement, ReactNode } from "react";
|
|
2
2
|
import type colors from "./cardcolors.module.css";
|
|
3
3
|
import { type ButtonProps } from "../Button";
|
|
4
4
|
import { type MenuProps } from "../Menu";
|
|
@@ -31,6 +31,24 @@ export interface CardProps {
|
|
|
31
31
|
*/
|
|
32
32
|
readonly header?: string | HeaderActionProps | ReactElement;
|
|
33
33
|
readonly elevation?: elevationProp;
|
|
34
|
+
/**
|
|
35
|
+
* **Use at your own risk:** Custom class names for specific elements. This should only be used as a
|
|
36
|
+
* **last resort**. Using this may result in unexpected side effects.
|
|
37
|
+
* More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components).
|
|
38
|
+
*/
|
|
39
|
+
readonly UNSAFE_className?: {
|
|
40
|
+
container?: string;
|
|
41
|
+
header?: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* **Use at your own risk:** Custom style for specific elements. This should only be used as a
|
|
45
|
+
* **last resort**. Using this may result in unexpected side effects.
|
|
46
|
+
* More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components).
|
|
47
|
+
*/
|
|
48
|
+
readonly UNSAFE_style?: {
|
|
49
|
+
container?: CSSProperties;
|
|
50
|
+
header?: CSSProperties;
|
|
51
|
+
};
|
|
34
52
|
}
|
|
35
53
|
export interface CardHeaderProps {
|
|
36
54
|
readonly children: ReactNode;
|
package/dist/Card-cjs.js
CHANGED
|
@@ -18,9 +18,9 @@ const SPACEBAR_KEY = " ";
|
|
|
18
18
|
* This is only intended to be used in the Card component.
|
|
19
19
|
* Please use `<Card onClick={onClick} />` component instead.
|
|
20
20
|
*/
|
|
21
|
-
function CardClickable({ className, onClick, children, }) {
|
|
21
|
+
function CardClickable({ className, onClick, children, UNSAFE_style = {}, }) {
|
|
22
22
|
const cardRef = React.useRef();
|
|
23
|
-
return (React.createElement("div", { ref: cardRef, "data-testid": "clickable-card", className: className, onClick: onClick, onKeyUp: handleKeyup, onKeyDown: handleKeyDown, role: "button", tabIndex: 0 }, children));
|
|
23
|
+
return (React.createElement("div", { ref: cardRef, "data-testid": "clickable-card", className: className, style: UNSAFE_style, onClick: onClick, onKeyUp: handleKeyup, onKeyDown: handleKeyDown, role: "button", tabIndex: 0 }, children));
|
|
24
24
|
function isCardFocused() {
|
|
25
25
|
return document.activeElement === cardRef.current;
|
|
26
26
|
}
|
|
@@ -43,7 +43,7 @@ function CardClickable({ className, onClick, children, }) {
|
|
|
43
43
|
* Intended to be used in the Card component.
|
|
44
44
|
* Use `<Card header={header} />` component instead.
|
|
45
45
|
*/
|
|
46
|
-
function CardHeader({ title, header, }) {
|
|
46
|
+
function CardHeader({ title, header, UNSAFE_className = {}, UNSAFE_style = {}, }) {
|
|
47
47
|
const heading = title || header;
|
|
48
48
|
if (React.isValidElement(heading))
|
|
49
49
|
return React.createElement(React.Fragment, null, heading);
|
|
@@ -51,7 +51,7 @@ function CardHeader({ title, header, }) {
|
|
|
51
51
|
const titleString = typeof heading === "string"
|
|
52
52
|
? heading
|
|
53
53
|
: heading.title;
|
|
54
|
-
return (React.createElement("div", { className: styles.header },
|
|
54
|
+
return (React.createElement("div", { className: classnames(styles.header, UNSAFE_className.header), style: UNSAFE_style.header },
|
|
55
55
|
titleString && React.createElement(Heading.Heading, { level: 2 }, titleString),
|
|
56
56
|
typeof heading === "object" &&
|
|
57
57
|
renderHeaderAction(heading === null || heading === void 0 ? void 0 : heading.action)));
|
|
@@ -107,30 +107,31 @@ function CardHeaderCompoundComponent({ children }) {
|
|
|
107
107
|
function CardBodyCompoundComponent({ children }) {
|
|
108
108
|
return React.createElement(React.Fragment, null, children);
|
|
109
109
|
}
|
|
110
|
-
function renderCardContent(children, title, header) {
|
|
110
|
+
function renderCardContent(children, title, header, UNSAFE_className, UNSAFE_style) {
|
|
111
111
|
return (React.createElement(React.Fragment, null,
|
|
112
|
-
React.createElement(CardHeader, { title: title, header: header }),
|
|
112
|
+
React.createElement(CardHeader, { title: title, header: header, UNSAFE_className: { header: UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.header }, UNSAFE_style: { header: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.header } }),
|
|
113
113
|
children));
|
|
114
114
|
}
|
|
115
|
-
function renderCardWrapper(className, content, onClick, url, external) {
|
|
115
|
+
function renderCardWrapper(className, content, onClick, url, external, UNSAFE_className, UNSAFE_style) {
|
|
116
|
+
const combinedClassName = classnames(className, UNSAFE_className);
|
|
116
117
|
if (onClick) {
|
|
117
|
-
return (React.createElement(CardClickable, { className:
|
|
118
|
+
return (React.createElement(CardClickable, { className: combinedClassName, onClick: onClick, UNSAFE_className: UNSAFE_className, UNSAFE_style: UNSAFE_style }, content));
|
|
118
119
|
}
|
|
119
120
|
if (url) {
|
|
120
|
-
return (React.createElement("a", Object.assign({ className:
|
|
121
|
+
return (React.createElement("a", Object.assign({ className: combinedClassName, href: url, style: UNSAFE_style }, (external && { target: "_blank", rel: "noopener noreferrer" })), content));
|
|
121
122
|
}
|
|
122
|
-
return React.createElement("div", { className:
|
|
123
|
+
return (React.createElement("div", { className: combinedClassName, style: UNSAFE_style }, content));
|
|
123
124
|
}
|
|
124
125
|
function Card(props) {
|
|
125
|
-
const { accent, header, children, title, elevation = "none", onClick, url, external, } = props;
|
|
126
|
+
const { accent, header, children, title, elevation = "none", onClick, url, external, UNSAFE_className = {}, UNSAFE_style = {}, } = props;
|
|
126
127
|
const className = classnames(styles.card, accent && styles.accent, (url || onClick) && styles.clickable, accent && colors[accent], elevation !== "none" && elevations[`${elevation}Elevation`]);
|
|
127
128
|
const isUsingCompoundPattern = React.Children.toArray(children).some(child => React.isValidElement(child) &&
|
|
128
129
|
(child.type === CardHeaderCompoundComponent ||
|
|
129
130
|
child.type === CardBodyCompoundComponent));
|
|
130
131
|
const content = isUsingCompoundPattern
|
|
131
132
|
? children
|
|
132
|
-
: renderCardContent(children, title, header);
|
|
133
|
-
return renderCardWrapper(className, content, onClick, url, external);
|
|
133
|
+
: renderCardContent(children, title, header, UNSAFE_className, UNSAFE_style);
|
|
134
|
+
return renderCardWrapper(className, content, onClick, url, external, UNSAFE_className.container, UNSAFE_style.container);
|
|
134
135
|
}
|
|
135
136
|
Card.Header = CardHeaderCompoundComponent;
|
|
136
137
|
Card.Body = CardBodyCompoundComponent;
|
package/dist/Card-es.js
CHANGED
|
@@ -16,9 +16,9 @@ const SPACEBAR_KEY = " ";
|
|
|
16
16
|
* This is only intended to be used in the Card component.
|
|
17
17
|
* Please use `<Card onClick={onClick} />` component instead.
|
|
18
18
|
*/
|
|
19
|
-
function CardClickable({ className, onClick, children, }) {
|
|
19
|
+
function CardClickable({ className, onClick, children, UNSAFE_style = {}, }) {
|
|
20
20
|
const cardRef = useRef();
|
|
21
|
-
return (React__default.createElement("div", { ref: cardRef, "data-testid": "clickable-card", className: className, onClick: onClick, onKeyUp: handleKeyup, onKeyDown: handleKeyDown, role: "button", tabIndex: 0 }, children));
|
|
21
|
+
return (React__default.createElement("div", { ref: cardRef, "data-testid": "clickable-card", className: className, style: UNSAFE_style, onClick: onClick, onKeyUp: handleKeyup, onKeyDown: handleKeyDown, role: "button", tabIndex: 0 }, children));
|
|
22
22
|
function isCardFocused() {
|
|
23
23
|
return document.activeElement === cardRef.current;
|
|
24
24
|
}
|
|
@@ -41,7 +41,7 @@ function CardClickable({ className, onClick, children, }) {
|
|
|
41
41
|
* Intended to be used in the Card component.
|
|
42
42
|
* Use `<Card header={header} />` component instead.
|
|
43
43
|
*/
|
|
44
|
-
function CardHeader({ title, header, }) {
|
|
44
|
+
function CardHeader({ title, header, UNSAFE_className = {}, UNSAFE_style = {}, }) {
|
|
45
45
|
const heading = title || header;
|
|
46
46
|
if (React__default.isValidElement(heading))
|
|
47
47
|
return React__default.createElement(React__default.Fragment, null, heading);
|
|
@@ -49,7 +49,7 @@ function CardHeader({ title, header, }) {
|
|
|
49
49
|
const titleString = typeof heading === "string"
|
|
50
50
|
? heading
|
|
51
51
|
: heading.title;
|
|
52
|
-
return (React__default.createElement("div", { className: styles.header },
|
|
52
|
+
return (React__default.createElement("div", { className: classnames(styles.header, UNSAFE_className.header), style: UNSAFE_style.header },
|
|
53
53
|
titleString && React__default.createElement(Heading, { level: 2 }, titleString),
|
|
54
54
|
typeof heading === "object" &&
|
|
55
55
|
renderHeaderAction(heading === null || heading === void 0 ? void 0 : heading.action)));
|
|
@@ -105,30 +105,31 @@ function CardHeaderCompoundComponent({ children }) {
|
|
|
105
105
|
function CardBodyCompoundComponent({ children }) {
|
|
106
106
|
return React__default.createElement(React__default.Fragment, null, children);
|
|
107
107
|
}
|
|
108
|
-
function renderCardContent(children, title, header) {
|
|
108
|
+
function renderCardContent(children, title, header, UNSAFE_className, UNSAFE_style) {
|
|
109
109
|
return (React__default.createElement(React__default.Fragment, null,
|
|
110
|
-
React__default.createElement(CardHeader, { title: title, header: header }),
|
|
110
|
+
React__default.createElement(CardHeader, { title: title, header: header, UNSAFE_className: { header: UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.header }, UNSAFE_style: { header: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.header } }),
|
|
111
111
|
children));
|
|
112
112
|
}
|
|
113
|
-
function renderCardWrapper(className, content, onClick, url, external) {
|
|
113
|
+
function renderCardWrapper(className, content, onClick, url, external, UNSAFE_className, UNSAFE_style) {
|
|
114
|
+
const combinedClassName = classnames(className, UNSAFE_className);
|
|
114
115
|
if (onClick) {
|
|
115
|
-
return (React__default.createElement(CardClickable, { className:
|
|
116
|
+
return (React__default.createElement(CardClickable, { className: combinedClassName, onClick: onClick, UNSAFE_className: UNSAFE_className, UNSAFE_style: UNSAFE_style }, content));
|
|
116
117
|
}
|
|
117
118
|
if (url) {
|
|
118
|
-
return (React__default.createElement("a", Object.assign({ className:
|
|
119
|
+
return (React__default.createElement("a", Object.assign({ className: combinedClassName, href: url, style: UNSAFE_style }, (external && { target: "_blank", rel: "noopener noreferrer" })), content));
|
|
119
120
|
}
|
|
120
|
-
return React__default.createElement("div", { className:
|
|
121
|
+
return (React__default.createElement("div", { className: combinedClassName, style: UNSAFE_style }, content));
|
|
121
122
|
}
|
|
122
123
|
function Card(props) {
|
|
123
|
-
const { accent, header, children, title, elevation = "none", onClick, url, external, } = props;
|
|
124
|
+
const { accent, header, children, title, elevation = "none", onClick, url, external, UNSAFE_className = {}, UNSAFE_style = {}, } = props;
|
|
124
125
|
const className = classnames(styles.card, accent && styles.accent, (url || onClick) && styles.clickable, accent && colors[accent], elevation !== "none" && elevations[`${elevation}Elevation`]);
|
|
125
126
|
const isUsingCompoundPattern = React__default.Children.toArray(children).some(child => React__default.isValidElement(child) &&
|
|
126
127
|
(child.type === CardHeaderCompoundComponent ||
|
|
127
128
|
child.type === CardBodyCompoundComponent));
|
|
128
129
|
const content = isUsingCompoundPattern
|
|
129
130
|
? children
|
|
130
|
-
: renderCardContent(children, title, header);
|
|
131
|
-
return renderCardWrapper(className, content, onClick, url, external);
|
|
131
|
+
: renderCardContent(children, title, header, UNSAFE_className, UNSAFE_style);
|
|
132
|
+
return renderCardWrapper(className, content, onClick, url, external, UNSAFE_className.container, UNSAFE_style.container);
|
|
132
133
|
}
|
|
133
134
|
Card.Header = CardHeaderCompoundComponent;
|
|
134
135
|
Card.Body = CardBodyCompoundComponent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.90.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -543,5 +543,5 @@
|
|
|
543
543
|
"> 1%",
|
|
544
544
|
"IE 10"
|
|
545
545
|
],
|
|
546
|
-
"gitHead": "
|
|
546
|
+
"gitHead": "829339495fcb97802380dc109df4c67106963812"
|
|
547
547
|
}
|