@jobber/components 6.26.2 → 6.26.4
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/Button/ButtonProvider.d.ts +1 -1
- package/dist/Button/index.cjs +1 -1
- package/dist/Button/index.d.ts +1 -1
- package/dist/Button/index.mjs +1 -1
- package/dist/Button-cjs.js +5 -5
- package/dist/Button-es.js +5 -5
- package/dist/Card/Card.d.ts +66 -7
- package/dist/Card/types.d.ts +10 -1
- package/dist/Card-cjs.js +59 -9
- package/dist/Card-es.js +59 -9
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/utils/meta/meta.json +3 -1
- package/package.json +2 -2
|
@@ -6,5 +6,5 @@ interface ButtonContextProps {
|
|
|
6
6
|
export declare function ButtonProvider({ children, size, }: PropsWithChildren<{
|
|
7
7
|
readonly size?: ButtonSize;
|
|
8
8
|
}>): JSX.Element;
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function useButtonContext(): ButtonContextProps;
|
|
10
10
|
export {};
|
package/dist/Button/index.cjs
CHANGED
package/dist/Button/index.d.ts
CHANGED
package/dist/Button/index.mjs
CHANGED
package/dist/Button-cjs.js
CHANGED
|
@@ -15,12 +15,12 @@ const ButtonContext = React.createContext({
|
|
|
15
15
|
function ButtonProvider({ children, size = "base", }) {
|
|
16
16
|
return (React.createElement(ButtonContext.Provider, { value: { size } }, children));
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function useButtonContext() {
|
|
19
19
|
return React.useContext(ButtonContext);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
function useButtonStyles({ size: sizeProp, disabled, fullWidth, loading, variation = "work", type = "primary", }) {
|
|
23
|
-
const { size: contextSize } =
|
|
23
|
+
const { size: contextSize } = useButtonContext();
|
|
24
24
|
const size = sizeProp || contextSize;
|
|
25
25
|
const wrapper = classnames([styles.button, styles[size], styles[variation], styles[type]], {
|
|
26
26
|
[styles.disabled]: disabled,
|
|
@@ -57,13 +57,13 @@ function getTypeSizes(size) {
|
|
|
57
57
|
}
|
|
58
58
|
function ButtonIcon(_a) {
|
|
59
59
|
var { size: sizeProp } = _a, props = tslib_es6.__rest(_a, ["size"]);
|
|
60
|
-
const { size: contextSize } =
|
|
60
|
+
const { size: contextSize } = useButtonContext();
|
|
61
61
|
const size = sizeProp || contextSize;
|
|
62
62
|
return React.createElement(Icon.Icon, Object.assign({}, props, { size: size }));
|
|
63
63
|
}
|
|
64
64
|
function ButtonLabel(_a) {
|
|
65
65
|
var { element = "span", fontWeight = "semiBold", fontFamily = "base", size: sizeProp } = _a, props = tslib_es6.__rest(_a, ["element", "fontWeight", "fontFamily", "size"]);
|
|
66
|
-
const { size: contextSize } =
|
|
66
|
+
const { size: contextSize } = useButtonContext();
|
|
67
67
|
const size = sizeProp || contextSize;
|
|
68
68
|
return (React.createElement(Typography.Typography, Object.assign({ element: element, fontWeight: fontWeight, fontFamily: fontFamily, size: getTypeSizes(size) }, props)));
|
|
69
69
|
}
|
|
@@ -90,5 +90,5 @@ Button.Label = ButtonLabel;
|
|
|
90
90
|
Button.Icon = ButtonIcon;
|
|
91
91
|
|
|
92
92
|
exports.Button = Button;
|
|
93
|
-
exports.
|
|
93
|
+
exports.useButtonContext = useButtonContext;
|
|
94
94
|
exports.useButtonStyles = useButtonStyles;
|
package/dist/Button-es.js
CHANGED
|
@@ -13,12 +13,12 @@ const ButtonContext = createContext({
|
|
|
13
13
|
function ButtonProvider({ children, size = "base", }) {
|
|
14
14
|
return (React__default.createElement(ButtonContext.Provider, { value: { size } }, children));
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function useButtonContext() {
|
|
17
17
|
return useContext(ButtonContext);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function useButtonStyles({ size: sizeProp, disabled, fullWidth, loading, variation = "work", type = "primary", }) {
|
|
21
|
-
const { size: contextSize } =
|
|
21
|
+
const { size: contextSize } = useButtonContext();
|
|
22
22
|
const size = sizeProp || contextSize;
|
|
23
23
|
const wrapper = classnames([styles.button, styles[size], styles[variation], styles[type]], {
|
|
24
24
|
[styles.disabled]: disabled,
|
|
@@ -55,13 +55,13 @@ function getTypeSizes(size) {
|
|
|
55
55
|
}
|
|
56
56
|
function ButtonIcon(_a) {
|
|
57
57
|
var { size: sizeProp } = _a, props = __rest(_a, ["size"]);
|
|
58
|
-
const { size: contextSize } =
|
|
58
|
+
const { size: contextSize } = useButtonContext();
|
|
59
59
|
const size = sizeProp || contextSize;
|
|
60
60
|
return React__default.createElement(Icon, Object.assign({}, props, { size: size }));
|
|
61
61
|
}
|
|
62
62
|
function ButtonLabel(_a) {
|
|
63
63
|
var { element = "span", fontWeight = "semiBold", fontFamily = "base", size: sizeProp } = _a, props = __rest(_a, ["element", "fontWeight", "fontFamily", "size"]);
|
|
64
|
-
const { size: contextSize } =
|
|
64
|
+
const { size: contextSize } = useButtonContext();
|
|
65
65
|
const size = sizeProp || contextSize;
|
|
66
66
|
return (React__default.createElement(Typography, Object.assign({ element: element, fontWeight: fontWeight, fontFamily: fontFamily, size: getTypeSizes(size) }, props)));
|
|
67
67
|
}
|
|
@@ -87,4 +87,4 @@ function ButtonWrapper(props) {
|
|
|
87
87
|
Button.Label = ButtonLabel;
|
|
88
88
|
Button.Icon = ButtonIcon;
|
|
89
89
|
|
|
90
|
-
export { Button as B,
|
|
90
|
+
export { Button as B, useButtonContext as a, useButtonStyles as u };
|
package/dist/Card/Card.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { CardBodyProps, CardHeaderProps, CardProps } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Props for a card that acts as a link.
|
|
5
|
+
* When url is provided, the card becomes clickable and navigates to the specified URL.
|
|
6
|
+
*/
|
|
7
|
+
type LinkCardProps = CardProps & {
|
|
5
8
|
/**
|
|
6
9
|
* URL that the card would navigate to once clicked.
|
|
7
10
|
*/
|
|
@@ -10,10 +13,66 @@ interface LinkCardProps extends CardProps {
|
|
|
10
13
|
* Makes the URL open in new tab on click.
|
|
11
14
|
*/
|
|
12
15
|
external?: boolean;
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
onClick?: never;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Props for a card that has a click handler.
|
|
20
|
+
* When onClick is provided, the card becomes clickable and triggers the handler on click.
|
|
21
|
+
*/
|
|
22
|
+
type ClickableCardProps = CardProps & {
|
|
23
|
+
/**
|
|
24
|
+
* Event handler that gets called when the card is clicked.
|
|
25
|
+
*/
|
|
15
26
|
onClick(event: React.MouseEvent<HTMLAnchorElement | HTMLDivElement>): void;
|
|
27
|
+
url?: never;
|
|
28
|
+
readonly external?: never;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Props for a regular card without any click behavior.
|
|
32
|
+
*/
|
|
33
|
+
type RegularCardProps = CardProps & {
|
|
34
|
+
url?: never;
|
|
35
|
+
onClick?: never;
|
|
36
|
+
readonly external?: never;
|
|
37
|
+
};
|
|
38
|
+
type CardPropOptions = LinkCardProps | ClickableCardProps | RegularCardProps;
|
|
39
|
+
/**
|
|
40
|
+
* Header component for the Card.
|
|
41
|
+
* Used in the compound component pattern to provide a consistent header layout.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* <Card>
|
|
46
|
+
* <Card.Header>
|
|
47
|
+
* <Text>Header Content</Text>
|
|
48
|
+
* </Card.Header>
|
|
49
|
+
* <Card.Body>
|
|
50
|
+
* <p>Card content</p>
|
|
51
|
+
* </Card.Body>
|
|
52
|
+
* </Card>
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
declare function CardHeaderCompoundComponent({ children }: CardHeaderProps): JSX.Element;
|
|
56
|
+
/**
|
|
57
|
+
* Body component for the Card.
|
|
58
|
+
* Used in the compound component pattern to provide a consistent content layout.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```tsx
|
|
62
|
+
* <Card>
|
|
63
|
+
* <Card.Header>
|
|
64
|
+
* <Text>Header Content</Text>
|
|
65
|
+
* </Card.Header>
|
|
66
|
+
* <Card.Body>
|
|
67
|
+
* <p>Card content</p>
|
|
68
|
+
* </Card.Body>
|
|
69
|
+
* </Card>
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
declare function CardBodyCompoundComponent({ children }: CardBodyProps): JSX.Element;
|
|
73
|
+
export declare function Card(props: CardPropOptions): JSX.Element;
|
|
74
|
+
export declare namespace Card {
|
|
75
|
+
var Header: typeof CardHeaderCompoundComponent;
|
|
76
|
+
var Body: typeof CardBodyCompoundComponent;
|
|
16
77
|
}
|
|
17
|
-
type CardPropOptions = XOR<CardProps, XOR<LinkCardProps, ClickableCardProps>>;
|
|
18
|
-
export declare function Card({ accent, header, children, onClick, title, url, external, elevation, }: CardPropOptions): JSX.Element;
|
|
19
78
|
export {};
|
package/dist/Card/types.d.ts
CHANGED
|
@@ -24,7 +24,6 @@ export interface CardProps {
|
|
|
24
24
|
/**
|
|
25
25
|
* @deprecated
|
|
26
26
|
* Use header instead.
|
|
27
|
-
*
|
|
28
27
|
*/
|
|
29
28
|
readonly title?: string;
|
|
30
29
|
/**
|
|
@@ -33,3 +32,13 @@ export interface CardProps {
|
|
|
33
32
|
readonly header?: string | HeaderActionProps | ReactElement;
|
|
34
33
|
readonly elevation?: elevationProp;
|
|
35
34
|
}
|
|
35
|
+
export interface CardHeaderProps {
|
|
36
|
+
readonly children: ReactNode;
|
|
37
|
+
}
|
|
38
|
+
export interface CardBodyProps {
|
|
39
|
+
readonly children: ReactNode;
|
|
40
|
+
}
|
|
41
|
+
export interface CardCompositionProps {
|
|
42
|
+
Header: React.FC<CardHeaderProps>;
|
|
43
|
+
Body: React.FC<CardBodyProps>;
|
|
44
|
+
}
|
package/dist/Card-cjs.js
CHANGED
|
@@ -69,20 +69,70 @@ function renderHeaderAction(action) {
|
|
|
69
69
|
return React.createElement(React.Fragment, null);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Header component for the Card.
|
|
74
|
+
* Used in the compound component pattern to provide a consistent header layout.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx
|
|
78
|
+
* <Card>
|
|
79
|
+
* <Card.Header>
|
|
80
|
+
* <Text>Header Content</Text>
|
|
81
|
+
* </Card.Header>
|
|
82
|
+
* <Card.Body>
|
|
83
|
+
* <p>Card content</p>
|
|
84
|
+
* </Card.Body>
|
|
85
|
+
* </Card>
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
function CardHeaderCompoundComponent({ children }) {
|
|
89
|
+
return React.createElement(React.Fragment, null, children);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Body component for the Card.
|
|
93
|
+
* Used in the compound component pattern to provide a consistent content layout.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```tsx
|
|
97
|
+
* <Card>
|
|
98
|
+
* <Card.Header>
|
|
99
|
+
* <Text>Header Content</Text>
|
|
100
|
+
* </Card.Header>
|
|
101
|
+
* <Card.Body>
|
|
102
|
+
* <p>Card content</p>
|
|
103
|
+
* </Card.Body>
|
|
104
|
+
* </Card>
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
function CardBodyCompoundComponent({ children }) {
|
|
108
|
+
return React.createElement(React.Fragment, null, children);
|
|
109
|
+
}
|
|
110
|
+
function renderCardContent(children, title, header) {
|
|
111
|
+
return (React.createElement(React.Fragment, null,
|
|
75
112
|
React.createElement(CardHeader, { title: title, header: header }),
|
|
76
113
|
children));
|
|
114
|
+
}
|
|
115
|
+
function renderCardWrapper(className, content, onClick, url, external) {
|
|
77
116
|
if (onClick) {
|
|
78
|
-
return (React.createElement(CardClickable, { className: className, onClick: onClick },
|
|
79
|
-
}
|
|
80
|
-
else if (url) {
|
|
81
|
-
return (React.createElement("a", Object.assign({ className: className, href: url }, (external && { target: "_blank", rel: "noopener noreferrer" })), cardContent));
|
|
117
|
+
return (React.createElement(CardClickable, { className: className, onClick: onClick }, content));
|
|
82
118
|
}
|
|
83
|
-
|
|
84
|
-
return React.createElement("
|
|
119
|
+
if (url) {
|
|
120
|
+
return (React.createElement("a", Object.assign({ className: className, href: url }, (external && { target: "_blank", rel: "noopener noreferrer" })), content));
|
|
85
121
|
}
|
|
122
|
+
return React.createElement("div", { className: className }, content);
|
|
123
|
+
}
|
|
124
|
+
function Card(props) {
|
|
125
|
+
const { accent, header, children, title, elevation = "none", onClick, url, external, } = props;
|
|
126
|
+
const className = classnames(styles.card, accent && styles.accent, (url || onClick) && styles.clickable, accent && colors[accent], elevation !== "none" && elevations[`${elevation}Elevation`]);
|
|
127
|
+
const isUsingCompoundPattern = React.Children.toArray(children).some(child => React.isValidElement(child) &&
|
|
128
|
+
(child.type === CardHeaderCompoundComponent ||
|
|
129
|
+
child.type === CardBodyCompoundComponent));
|
|
130
|
+
const content = isUsingCompoundPattern
|
|
131
|
+
? children
|
|
132
|
+
: renderCardContent(children, title, header);
|
|
133
|
+
return renderCardWrapper(className, content, onClick, url, external);
|
|
86
134
|
}
|
|
135
|
+
Card.Header = CardHeaderCompoundComponent;
|
|
136
|
+
Card.Body = CardBodyCompoundComponent;
|
|
87
137
|
|
|
88
138
|
exports.Card = Card;
|
package/dist/Card-es.js
CHANGED
|
@@ -67,20 +67,70 @@ function renderHeaderAction(action) {
|
|
|
67
67
|
return React__default.createElement(React__default.Fragment, null);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Header component for the Card.
|
|
72
|
+
* Used in the compound component pattern to provide a consistent header layout.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```tsx
|
|
76
|
+
* <Card>
|
|
77
|
+
* <Card.Header>
|
|
78
|
+
* <Text>Header Content</Text>
|
|
79
|
+
* </Card.Header>
|
|
80
|
+
* <Card.Body>
|
|
81
|
+
* <p>Card content</p>
|
|
82
|
+
* </Card.Body>
|
|
83
|
+
* </Card>
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
function CardHeaderCompoundComponent({ children }) {
|
|
87
|
+
return React__default.createElement(React__default.Fragment, null, children);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Body component for the Card.
|
|
91
|
+
* Used in the compound component pattern to provide a consistent content layout.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```tsx
|
|
95
|
+
* <Card>
|
|
96
|
+
* <Card.Header>
|
|
97
|
+
* <Text>Header Content</Text>
|
|
98
|
+
* </Card.Header>
|
|
99
|
+
* <Card.Body>
|
|
100
|
+
* <p>Card content</p>
|
|
101
|
+
* </Card.Body>
|
|
102
|
+
* </Card>
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
function CardBodyCompoundComponent({ children }) {
|
|
106
|
+
return React__default.createElement(React__default.Fragment, null, children);
|
|
107
|
+
}
|
|
108
|
+
function renderCardContent(children, title, header) {
|
|
109
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
73
110
|
React__default.createElement(CardHeader, { title: title, header: header }),
|
|
74
111
|
children));
|
|
112
|
+
}
|
|
113
|
+
function renderCardWrapper(className, content, onClick, url, external) {
|
|
75
114
|
if (onClick) {
|
|
76
|
-
return (React__default.createElement(CardClickable, { className: className, onClick: onClick },
|
|
77
|
-
}
|
|
78
|
-
else if (url) {
|
|
79
|
-
return (React__default.createElement("a", Object.assign({ className: className, href: url }, (external && { target: "_blank", rel: "noopener noreferrer" })), cardContent));
|
|
115
|
+
return (React__default.createElement(CardClickable, { className: className, onClick: onClick }, content));
|
|
80
116
|
}
|
|
81
|
-
|
|
82
|
-
return React__default.createElement("
|
|
117
|
+
if (url) {
|
|
118
|
+
return (React__default.createElement("a", Object.assign({ className: className, href: url }, (external && { target: "_blank", rel: "noopener noreferrer" })), content));
|
|
83
119
|
}
|
|
120
|
+
return React__default.createElement("div", { className: className }, content);
|
|
121
|
+
}
|
|
122
|
+
function Card(props) {
|
|
123
|
+
const { accent, header, children, title, elevation = "none", onClick, url, external, } = props;
|
|
124
|
+
const className = classnames(styles.card, accent && styles.accent, (url || onClick) && styles.clickable, accent && colors[accent], elevation !== "none" && elevations[`${elevation}Elevation`]);
|
|
125
|
+
const isUsingCompoundPattern = React__default.Children.toArray(children).some(child => React__default.isValidElement(child) &&
|
|
126
|
+
(child.type === CardHeaderCompoundComponent ||
|
|
127
|
+
child.type === CardBodyCompoundComponent));
|
|
128
|
+
const content = isUsingCompoundPattern
|
|
129
|
+
? children
|
|
130
|
+
: renderCardContent(children, title, header);
|
|
131
|
+
return renderCardWrapper(className, content, onClick, url, external);
|
|
84
132
|
}
|
|
133
|
+
Card.Header = CardHeaderCompoundComponent;
|
|
134
|
+
Card.Body = CardBodyCompoundComponent;
|
|
85
135
|
|
|
86
136
|
export { Card as C };
|
package/dist/index.cjs
CHANGED
|
@@ -197,7 +197,7 @@ exports.Avatar = Avatar.Avatar;
|
|
|
197
197
|
exports.Banner = Banner.Banner;
|
|
198
198
|
exports.Box = Box.Box;
|
|
199
199
|
exports.Button = Button.Button;
|
|
200
|
-
exports.
|
|
200
|
+
exports.useButtonContext = Button.useButtonContext;
|
|
201
201
|
exports.useButtonStyles = Button.useButtonStyles;
|
|
202
202
|
exports.ButtonDismiss = ButtonDismiss.ButtonDismiss;
|
|
203
203
|
exports.Card = Card.Card;
|
package/dist/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import 'react-dom';
|
|
|
16
16
|
export { A as Avatar } from './Avatar-es.js';
|
|
17
17
|
export { B as Banner } from './Banner-es.js';
|
|
18
18
|
export { B as Box } from './Box-es.js';
|
|
19
|
-
export { B as Button, a as
|
|
19
|
+
export { B as Button, a as useButtonContext, u as useButtonStyles } from './Button-es.js';
|
|
20
20
|
export { B as ButtonDismiss } from './ButtonDismiss-es.js';
|
|
21
21
|
export { C as Card } from './Card-es.js';
|
|
22
22
|
export { Checkbox } from './Checkbox/index.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "6.26.
|
|
3
|
+
"version": "6.26.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -490,5 +490,5 @@
|
|
|
490
490
|
"> 1%",
|
|
491
491
|
"IE 10"
|
|
492
492
|
],
|
|
493
|
-
"gitHead": "
|
|
493
|
+
"gitHead": "f0c368fc049c59b408f725d0fad344453ffd3942"
|
|
494
494
|
}
|