@sb1/ffe-cards-react 15.2.5 → 16.0.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/es/CardBase.js +18 -15
- package/es/IconCard/IconCard.js +18 -11
- package/es/ImageCard/ImageCard.js +20 -13
- package/es/StippledCard/StippledCard.js +20 -13
- package/es/TextCard/TextCard.js +10 -9
- package/es/components/CardAction.js +29 -0
- package/es/components/WithCardAction.js +48 -0
- package/es/components/index.js +2 -0
- package/es/mergeRefs.js +13 -0
- package/lib/CardBase.js +19 -15
- package/lib/IconCard/IconCard.js +18 -10
- package/lib/ImageCard/ImageCard.js +20 -12
- package/lib/StippledCard/StippledCard.js +20 -12
- package/lib/TextCard/TextCard.js +10 -8
- package/lib/components/CardAction.js +35 -0
- package/lib/components/WithCardAction.js +78 -0
- package/lib/components/index.js +5 -1
- package/lib/mergeRefs.js +17 -0
- package/package.json +5 -5
- package/types/CardBase.d.ts +6 -18
- package/types/IconCard/IconCard.d.ts +5 -11
- package/types/ImageCard/ImageCard.d.ts +5 -11
- package/types/StippledCard/StippledCard.d.ts +5 -14
- package/types/TextCard/TextCard.d.ts +5 -10
- package/types/components/CardAction.d.ts +8 -0
- package/types/components/WithCardAction.d.ts +8 -0
- package/types/components/index.d.ts +2 -0
- package/types/mergeRefs.d.ts +2 -0
- package/types/types.d.ts +7 -6
package/es/CardBase.js
CHANGED
|
@@ -21,19 +21,22 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import React from 'react';
|
|
24
|
-
import { fixedForwardRef } from './fixedForwardRef';
|
|
25
24
|
import classNames from 'classnames';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var _b
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
import { WithCardAction } from './components';
|
|
26
|
+
export var CardBase = function (_a) {
|
|
27
|
+
var _b;
|
|
28
|
+
var className = _a.className, shadow = _a.shadow, noMargin = _a.noMargin, textCenter = _a.textCenter, bgColor = _a.bgColor, bgDarkmodeColor = _a.bgDarkmodeColor, noPadding = _a.noPadding, children = _a.children, rest = __rest(_a, ["className", "shadow", "noMargin", "textCenter", "bgColor", "bgDarkmodeColor", "noPadding", "children"]);
|
|
29
|
+
return (React.createElement(WithCardAction, __assign({ className: classNames('ffe-card-base', className, (_b = {},
|
|
30
|
+
_b["ffe-card-base--bg-".concat(bgColor)] = bgColor,
|
|
31
|
+
_b["ffe-card-base--dm-bg-".concat(bgDarkmodeColor)] = bgDarkmodeColor,
|
|
32
|
+
_b['ffe-card-base--box-shadow'] = shadow,
|
|
33
|
+
_b['ffe-card-base--no-margin'] = noMargin,
|
|
34
|
+
_b['ffe-card-base--text-center'] = textCenter,
|
|
35
|
+
_b['ffe-card-base--no-padding'] = noPadding,
|
|
36
|
+
_b)) }, rest), function (_a) {
|
|
37
|
+
var CardAction = _a.CardAction;
|
|
38
|
+
return typeof children === 'function'
|
|
39
|
+
? children({ CardAction: CardAction })
|
|
40
|
+
: children;
|
|
41
|
+
}));
|
|
42
|
+
};
|
package/es/IconCard/IconCard.js
CHANGED
|
@@ -21,15 +21,22 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import React from 'react';
|
|
24
|
-
import { fixedForwardRef } from '../fixedForwardRef';
|
|
25
24
|
import classNames from 'classnames';
|
|
26
|
-
import { Text, Subtext, Title, CardName } from '../components';
|
|
27
|
-
function
|
|
28
|
-
var
|
|
29
|
-
return (React.createElement(
|
|
30
|
-
|
|
31
|
-
React.createElement(
|
|
32
|
-
|
|
33
|
-
: children
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
import { WithCardAction, Text, Subtext, Title, CardName } from '../components';
|
|
26
|
+
export var IconCard = function (_a) {
|
|
27
|
+
var className = _a.className, condensed = _a.condensed, icon = _a.icon, children = _a.children, rest = __rest(_a, ["className", "condensed", "icon", "children"]);
|
|
28
|
+
return (React.createElement(WithCardAction, __assign({ className: classNames('ffe-icon-card', { 'ffe-icon-card--condensed': condensed }, className) }, rest), function (_a) {
|
|
29
|
+
var CardAction = _a.CardAction;
|
|
30
|
+
return (React.createElement(React.Fragment, null,
|
|
31
|
+
React.cloneElement(icon, __assign(__assign({}, icon.props), { className: classNames('ffe-icon-card__icon', icon.props.className) })),
|
|
32
|
+
React.createElement("div", { className: "ffe-icon-card__body" }, typeof children === 'function'
|
|
33
|
+
? children({
|
|
34
|
+
Text: Text,
|
|
35
|
+
Subtext: Subtext,
|
|
36
|
+
Title: Title,
|
|
37
|
+
CardName: CardName,
|
|
38
|
+
CardAction: CardAction,
|
|
39
|
+
})
|
|
40
|
+
: children)));
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
@@ -21,17 +21,24 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import React from 'react';
|
|
24
|
-
import { fixedForwardRef } from '../fixedForwardRef';
|
|
25
24
|
import classNames from 'classnames';
|
|
26
|
-
import {
|
|
27
|
-
function
|
|
28
|
-
var
|
|
29
|
-
return (React.createElement(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
React.createElement("
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
: children
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
import { CardName, Subtext, Text, Title, WithCardAction } from '../components';
|
|
26
|
+
export var ImageCard = function (_a) {
|
|
27
|
+
var className = _a.className, imageSrc = _a.imageSrc, imageAltText = _a.imageAltText, children = _a.children, rest = __rest(_a, ["className", "imageSrc", "imageAltText", "children"]);
|
|
28
|
+
return (React.createElement(WithCardAction, __assign({ className: classNames('ffe-image-card', className) }, rest), function (_a) {
|
|
29
|
+
var CardAction = _a.CardAction;
|
|
30
|
+
return (React.createElement(React.Fragment, null,
|
|
31
|
+
React.createElement("div", { className: "ffe-image-card__image-container" },
|
|
32
|
+
React.createElement("div", { className: "ffe-image-card__image-overlay" }),
|
|
33
|
+
React.createElement("img", { src: imageSrc, alt: imageAltText, className: "ffe-image-card__image" })),
|
|
34
|
+
React.createElement("div", { className: "ffe-image-card__body" }, typeof children === 'function'
|
|
35
|
+
? children({
|
|
36
|
+
Text: Text,
|
|
37
|
+
Subtext: Subtext,
|
|
38
|
+
Title: Title,
|
|
39
|
+
CardName: CardName,
|
|
40
|
+
CardAction: CardAction,
|
|
41
|
+
})
|
|
42
|
+
: children)));
|
|
43
|
+
}));
|
|
44
|
+
};
|
|
@@ -21,17 +21,24 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import React from 'react';
|
|
24
|
-
import { fixedForwardRef } from '../fixedForwardRef';
|
|
25
24
|
import classNames from 'classnames';
|
|
26
|
-
import {
|
|
27
|
-
function
|
|
28
|
-
var
|
|
29
|
-
return (React.createElement(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
import { CardName, Subtext, Text, Title, WithCardAction } from '../components';
|
|
26
|
+
export var StippledCard = function (_a) {
|
|
27
|
+
var className = _a.className, condensed = _a.condensed, img = _a.img, children = _a.children, rest = __rest(_a, ["className", "condensed", "img", "children"]);
|
|
28
|
+
return (React.createElement(WithCardAction, __assign({ className: classNames('ffe-stippled-card', { 'ffe-stippled-card--condensed': condensed }, className) }, rest), function (_a) {
|
|
29
|
+
var CardAction = _a.CardAction;
|
|
30
|
+
return (React.createElement(React.Fragment, null,
|
|
31
|
+
React.createElement("div", { className: classNames('ffe-stippled-card__img', {
|
|
32
|
+
'ffe-stippled-card__img--icon': (img === null || img === void 0 ? void 0 : img.type) === 'icon',
|
|
33
|
+
}), "aria-hidden": (img === null || img === void 0 ? void 0 : img.type) === 'icon' }, img === null || img === void 0 ? void 0 : img.element),
|
|
34
|
+
React.createElement("div", null, typeof children === 'function'
|
|
35
|
+
? children({
|
|
36
|
+
CardName: CardName,
|
|
37
|
+
Title: Title,
|
|
38
|
+
Text: Text,
|
|
39
|
+
Subtext: Subtext,
|
|
40
|
+
CardAction: CardAction,
|
|
41
|
+
})
|
|
42
|
+
: children)));
|
|
43
|
+
}));
|
|
44
|
+
};
|
package/es/TextCard/TextCard.js
CHANGED
|
@@ -21,13 +21,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import React from 'react';
|
|
24
|
-
import { fixedForwardRef } from '../fixedForwardRef';
|
|
25
24
|
import classNames from 'classnames';
|
|
26
|
-
import {
|
|
27
|
-
function
|
|
28
|
-
var
|
|
29
|
-
return (React.createElement(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
25
|
+
import { CardName, Subtext, Text, Title, WithCardAction } from '../components';
|
|
26
|
+
export var TextCard = function (_a) {
|
|
27
|
+
var className = _a.className, leftAlign = _a.leftAlign, children = _a.children, rest = __rest(_a, ["className", "leftAlign", "children"]);
|
|
28
|
+
return (React.createElement(WithCardAction, __assign({ className: classNames('ffe-text-card', { 'ffe-text-card--left-align': leftAlign }, className) }, rest), function (_a) {
|
|
29
|
+
var CardAction = _a.CardAction;
|
|
30
|
+
return typeof children === 'function'
|
|
31
|
+
? children({ Text: Text, Subtext: Subtext, Title: Title, CardName: CardName, CardAction: CardAction })
|
|
32
|
+
: children;
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import React from 'react';
|
|
24
|
+
import { fixedForwardRef } from '../fixedForwardRef';
|
|
25
|
+
function CardActionWithRef(props, ref) {
|
|
26
|
+
var _a = props.as, Comp = _a === void 0 ? 'a' : _a, rest = __rest(props, ["as"]);
|
|
27
|
+
return React.createElement(Comp, __assign({}, rest, { ref: ref }));
|
|
28
|
+
}
|
|
29
|
+
export var CardAction = fixedForwardRef(CardActionWithRef);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import React, { useCallback, useRef } from 'react';
|
|
24
|
+
import classNames from 'classnames';
|
|
25
|
+
import { mergeRefs } from '../mergeRefs';
|
|
26
|
+
import { CardAction } from './CardAction';
|
|
27
|
+
import { fixedForwardRef } from '../fixedForwardRef';
|
|
28
|
+
export var WithCardAction = function (_a) {
|
|
29
|
+
var children = _a.children, onClick = _a.onClick, rest = __rest(_a, ["children", "onClick"]);
|
|
30
|
+
var actionRef = useRef(null);
|
|
31
|
+
var PartialAppliedCardAction = useCallback(function (_a, ref) {
|
|
32
|
+
var className = _a.className, restCardAction = __rest(_a, ["className"]);
|
|
33
|
+
return (React.createElement(CardAction, __assign({ className: classNames(className, 'ffe-card__action', {
|
|
34
|
+
'ffe-card__action--raw': !className,
|
|
35
|
+
}), ref: ref ? mergeRefs([ref, actionRef]) : actionRef }, restCardAction)));
|
|
36
|
+
}, []);
|
|
37
|
+
return (
|
|
38
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
39
|
+
React.createElement("div", __assign({}, rest, { onClick: function (e) {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
if (!((_a = actionRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
|
|
42
|
+
(_b = actionRef.current) === null || _b === void 0 ? void 0 : _b.click();
|
|
43
|
+
}
|
|
44
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
45
|
+
} }), children({
|
|
46
|
+
CardAction: fixedForwardRef(PartialAppliedCardAction),
|
|
47
|
+
})));
|
|
48
|
+
};
|
package/es/components/index.js
CHANGED
package/es/mergeRefs.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function mergeRefs(refs) {
|
|
2
|
+
return function (value) {
|
|
3
|
+
refs.forEach(function (ref) {
|
|
4
|
+
if (typeof ref === 'function') {
|
|
5
|
+
ref(value);
|
|
6
|
+
}
|
|
7
|
+
else if (ref != null) {
|
|
8
|
+
// eslint-disable-next-line no-param-reassign
|
|
9
|
+
ref.current = value;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
}
|
package/lib/CardBase.js
CHANGED
|
@@ -27,19 +27,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
exports.CardBase = void 0;
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
|
-
var fixedForwardRef_1 = require("./fixedForwardRef");
|
|
31
30
|
var classnames_1 = __importDefault(require("classnames"));
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var _b
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
var components_1 = require("./components");
|
|
32
|
+
var CardBase = function (_a) {
|
|
33
|
+
var _b;
|
|
34
|
+
var className = _a.className, shadow = _a.shadow, noMargin = _a.noMargin, textCenter = _a.textCenter, bgColor = _a.bgColor, bgDarkmodeColor = _a.bgDarkmodeColor, noPadding = _a.noPadding, children = _a.children, rest = __rest(_a, ["className", "shadow", "noMargin", "textCenter", "bgColor", "bgDarkmodeColor", "noPadding", "children"]);
|
|
35
|
+
return (react_1.default.createElement(components_1.WithCardAction, __assign({ className: (0, classnames_1.default)('ffe-card-base', className, (_b = {},
|
|
36
|
+
_b["ffe-card-base--bg-".concat(bgColor)] = bgColor,
|
|
37
|
+
_b["ffe-card-base--dm-bg-".concat(bgDarkmodeColor)] = bgDarkmodeColor,
|
|
38
|
+
_b['ffe-card-base--box-shadow'] = shadow,
|
|
39
|
+
_b['ffe-card-base--no-margin'] = noMargin,
|
|
40
|
+
_b['ffe-card-base--text-center'] = textCenter,
|
|
41
|
+
_b['ffe-card-base--no-padding'] = noPadding,
|
|
42
|
+
_b)) }, rest), function (_a) {
|
|
43
|
+
var CardAction = _a.CardAction;
|
|
44
|
+
return typeof children === 'function'
|
|
45
|
+
? children({ CardAction: CardAction })
|
|
46
|
+
: children;
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
49
|
+
exports.CardBase = CardBase;
|
package/lib/IconCard/IconCard.js
CHANGED
|
@@ -27,15 +27,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
exports.IconCard = void 0;
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
|
-
var fixedForwardRef_1 = require("../fixedForwardRef");
|
|
31
30
|
var classnames_1 = __importDefault(require("classnames"));
|
|
32
31
|
var components_1 = require("../components");
|
|
33
|
-
function
|
|
34
|
-
var
|
|
35
|
-
return (react_1.default.createElement(
|
|
36
|
-
|
|
37
|
-
react_1.default.createElement(
|
|
38
|
-
|
|
39
|
-
: children
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
var IconCard = function (_a) {
|
|
33
|
+
var className = _a.className, condensed = _a.condensed, icon = _a.icon, children = _a.children, rest = __rest(_a, ["className", "condensed", "icon", "children"]);
|
|
34
|
+
return (react_1.default.createElement(components_1.WithCardAction, __assign({ className: (0, classnames_1.default)('ffe-icon-card', { 'ffe-icon-card--condensed': condensed }, className) }, rest), function (_a) {
|
|
35
|
+
var CardAction = _a.CardAction;
|
|
36
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
37
|
+
react_1.default.cloneElement(icon, __assign(__assign({}, icon.props), { className: (0, classnames_1.default)('ffe-icon-card__icon', icon.props.className) })),
|
|
38
|
+
react_1.default.createElement("div", { className: "ffe-icon-card__body" }, typeof children === 'function'
|
|
39
|
+
? children({
|
|
40
|
+
Text: components_1.Text,
|
|
41
|
+
Subtext: components_1.Subtext,
|
|
42
|
+
Title: components_1.Title,
|
|
43
|
+
CardName: components_1.CardName,
|
|
44
|
+
CardAction: CardAction,
|
|
45
|
+
})
|
|
46
|
+
: children)));
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
49
|
+
exports.IconCard = IconCard;
|
|
@@ -27,17 +27,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
exports.ImageCard = void 0;
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
|
-
var fixedForwardRef_1 = require("../fixedForwardRef");
|
|
31
30
|
var classnames_1 = __importDefault(require("classnames"));
|
|
32
31
|
var components_1 = require("../components");
|
|
33
|
-
function
|
|
34
|
-
var
|
|
35
|
-
return (react_1.default.createElement(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
react_1.default.createElement("
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
: children
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
var ImageCard = function (_a) {
|
|
33
|
+
var className = _a.className, imageSrc = _a.imageSrc, imageAltText = _a.imageAltText, children = _a.children, rest = __rest(_a, ["className", "imageSrc", "imageAltText", "children"]);
|
|
34
|
+
return (react_1.default.createElement(components_1.WithCardAction, __assign({ className: (0, classnames_1.default)('ffe-image-card', className) }, rest), function (_a) {
|
|
35
|
+
var CardAction = _a.CardAction;
|
|
36
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
37
|
+
react_1.default.createElement("div", { className: "ffe-image-card__image-container" },
|
|
38
|
+
react_1.default.createElement("div", { className: "ffe-image-card__image-overlay" }),
|
|
39
|
+
react_1.default.createElement("img", { src: imageSrc, alt: imageAltText, className: "ffe-image-card__image" })),
|
|
40
|
+
react_1.default.createElement("div", { className: "ffe-image-card__body" }, typeof children === 'function'
|
|
41
|
+
? children({
|
|
42
|
+
Text: components_1.Text,
|
|
43
|
+
Subtext: components_1.Subtext,
|
|
44
|
+
Title: components_1.Title,
|
|
45
|
+
CardName: components_1.CardName,
|
|
46
|
+
CardAction: CardAction,
|
|
47
|
+
})
|
|
48
|
+
: children)));
|
|
49
|
+
}));
|
|
50
|
+
};
|
|
51
|
+
exports.ImageCard = ImageCard;
|
|
@@ -27,17 +27,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
exports.StippledCard = void 0;
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
|
-
var fixedForwardRef_1 = require("../fixedForwardRef");
|
|
31
30
|
var classnames_1 = __importDefault(require("classnames"));
|
|
32
31
|
var components_1 = require("../components");
|
|
33
|
-
function
|
|
34
|
-
var
|
|
35
|
-
return (react_1.default.createElement(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
var StippledCard = function (_a) {
|
|
33
|
+
var className = _a.className, condensed = _a.condensed, img = _a.img, children = _a.children, rest = __rest(_a, ["className", "condensed", "img", "children"]);
|
|
34
|
+
return (react_1.default.createElement(components_1.WithCardAction, __assign({ className: (0, classnames_1.default)('ffe-stippled-card', { 'ffe-stippled-card--condensed': condensed }, className) }, rest), function (_a) {
|
|
35
|
+
var CardAction = _a.CardAction;
|
|
36
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
37
|
+
react_1.default.createElement("div", { className: (0, classnames_1.default)('ffe-stippled-card__img', {
|
|
38
|
+
'ffe-stippled-card__img--icon': (img === null || img === void 0 ? void 0 : img.type) === 'icon',
|
|
39
|
+
}), "aria-hidden": (img === null || img === void 0 ? void 0 : img.type) === 'icon' }, img === null || img === void 0 ? void 0 : img.element),
|
|
40
|
+
react_1.default.createElement("div", null, typeof children === 'function'
|
|
41
|
+
? children({
|
|
42
|
+
CardName: components_1.CardName,
|
|
43
|
+
Title: components_1.Title,
|
|
44
|
+
Text: components_1.Text,
|
|
45
|
+
Subtext: components_1.Subtext,
|
|
46
|
+
CardAction: CardAction,
|
|
47
|
+
})
|
|
48
|
+
: children)));
|
|
49
|
+
}));
|
|
50
|
+
};
|
|
51
|
+
exports.StippledCard = StippledCard;
|
package/lib/TextCard/TextCard.js
CHANGED
|
@@ -27,13 +27,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
exports.TextCard = void 0;
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
|
-
var fixedForwardRef_1 = require("../fixedForwardRef");
|
|
31
30
|
var classnames_1 = __importDefault(require("classnames"));
|
|
32
31
|
var components_1 = require("../components");
|
|
33
|
-
function
|
|
34
|
-
var
|
|
35
|
-
return (react_1.default.createElement(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
32
|
+
var TextCard = function (_a) {
|
|
33
|
+
var className = _a.className, leftAlign = _a.leftAlign, children = _a.children, rest = __rest(_a, ["className", "leftAlign", "children"]);
|
|
34
|
+
return (react_1.default.createElement(components_1.WithCardAction, __assign({ className: (0, classnames_1.default)('ffe-text-card', { 'ffe-text-card--left-align': leftAlign }, className) }, rest), function (_a) {
|
|
35
|
+
var CardAction = _a.CardAction;
|
|
36
|
+
return typeof children === 'function'
|
|
37
|
+
? children({ Text: components_1.Text, Subtext: components_1.Subtext, Title: components_1.Title, CardName: components_1.CardName, CardAction: CardAction })
|
|
38
|
+
: children;
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
41
|
+
exports.TextCard = TextCard;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.CardAction = void 0;
|
|
29
|
+
var react_1 = __importDefault(require("react"));
|
|
30
|
+
var fixedForwardRef_1 = require("../fixedForwardRef");
|
|
31
|
+
function CardActionWithRef(props, ref) {
|
|
32
|
+
var _a = props.as, Comp = _a === void 0 ? 'a' : _a, rest = __rest(props, ["as"]);
|
|
33
|
+
return react_1.default.createElement(Comp, __assign({}, rest, { ref: ref }));
|
|
34
|
+
}
|
|
35
|
+
exports.CardAction = (0, fixedForwardRef_1.fixedForwardRef)(CardActionWithRef);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
37
|
+
var t = {};
|
|
38
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
39
|
+
t[p] = s[p];
|
|
40
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
41
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
42
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
43
|
+
t[p[i]] = s[p[i]];
|
|
44
|
+
}
|
|
45
|
+
return t;
|
|
46
|
+
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.WithCardAction = void 0;
|
|
52
|
+
var react_1 = __importStar(require("react"));
|
|
53
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
54
|
+
var mergeRefs_1 = require("../mergeRefs");
|
|
55
|
+
var CardAction_1 = require("./CardAction");
|
|
56
|
+
var fixedForwardRef_1 = require("../fixedForwardRef");
|
|
57
|
+
var WithCardAction = function (_a) {
|
|
58
|
+
var children = _a.children, onClick = _a.onClick, rest = __rest(_a, ["children", "onClick"]);
|
|
59
|
+
var actionRef = (0, react_1.useRef)(null);
|
|
60
|
+
var PartialAppliedCardAction = (0, react_1.useCallback)(function (_a, ref) {
|
|
61
|
+
var className = _a.className, restCardAction = __rest(_a, ["className"]);
|
|
62
|
+
return (react_1.default.createElement(CardAction_1.CardAction, __assign({ className: (0, classnames_1.default)(className, 'ffe-card__action', {
|
|
63
|
+
'ffe-card__action--raw': !className,
|
|
64
|
+
}), ref: ref ? (0, mergeRefs_1.mergeRefs)([ref, actionRef]) : actionRef }, restCardAction)));
|
|
65
|
+
}, []);
|
|
66
|
+
return (
|
|
67
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
68
|
+
react_1.default.createElement("div", __assign({}, rest, { onClick: function (e) {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
if (!((_a = actionRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
|
|
71
|
+
(_b = actionRef.current) === null || _b === void 0 ? void 0 : _b.click();
|
|
72
|
+
}
|
|
73
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
74
|
+
} }), children({
|
|
75
|
+
CardAction: (0, fixedForwardRef_1.fixedForwardRef)(PartialAppliedCardAction),
|
|
76
|
+
})));
|
|
77
|
+
};
|
|
78
|
+
exports.WithCardAction = WithCardAction;
|
package/lib/components/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Title = exports.Text = exports.Subtext = exports.CardName = void 0;
|
|
3
|
+
exports.CardAction = exports.WithCardAction = exports.Title = exports.Text = exports.Subtext = exports.CardName = void 0;
|
|
4
4
|
var CardName_1 = require("./CardName");
|
|
5
5
|
Object.defineProperty(exports, "CardName", { enumerable: true, get: function () { return CardName_1.CardName; } });
|
|
6
6
|
var Subtext_1 = require("./Subtext");
|
|
@@ -9,3 +9,7 @@ var Text_1 = require("./Text");
|
|
|
9
9
|
Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return Text_1.Text; } });
|
|
10
10
|
var Title_1 = require("./Title");
|
|
11
11
|
Object.defineProperty(exports, "Title", { enumerable: true, get: function () { return Title_1.Title; } });
|
|
12
|
+
var WithCardAction_1 = require("./WithCardAction");
|
|
13
|
+
Object.defineProperty(exports, "WithCardAction", { enumerable: true, get: function () { return WithCardAction_1.WithCardAction; } });
|
|
14
|
+
var CardAction_1 = require("./CardAction");
|
|
15
|
+
Object.defineProperty(exports, "CardAction", { enumerable: true, get: function () { return CardAction_1.CardAction; } });
|
package/lib/mergeRefs.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeRefs = void 0;
|
|
4
|
+
function mergeRefs(refs) {
|
|
5
|
+
return function (value) {
|
|
6
|
+
refs.forEach(function (ref) {
|
|
7
|
+
if (typeof ref === 'function') {
|
|
8
|
+
ref(value);
|
|
9
|
+
}
|
|
10
|
+
else if (ref != null) {
|
|
11
|
+
// eslint-disable-next-line no-param-reassign
|
|
12
|
+
ref.current = value;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.mergeRefs = mergeRefs;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sb1/ffe-cards-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0",
|
|
4
4
|
"description": "React implementation of ffe-react",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SpareBank 1",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"test:watch": "ffe-buildtool jest --watch"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@sb1/ffe-cards": "^
|
|
29
|
+
"@sb1/ffe-cards": "^19.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@sb1/ffe-buildtool": "^0.6.
|
|
33
|
-
"@sb1/ffe-icons-react": "^10.0.
|
|
32
|
+
"@sb1/ffe-buildtool": "^0.6.4",
|
|
33
|
+
"@sb1/ffe-icons-react": "^10.0.5",
|
|
34
34
|
"react": "^16.9.0",
|
|
35
35
|
"react-dom": "^16.9.0"
|
|
36
36
|
},
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "1a06e8ffb30f92e91b7825ccebada746d7f60abc"
|
|
44
44
|
}
|
package/types/CardBase.d.ts
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WithCardActionProps } from './components';
|
|
3
3
|
type BgColor = 'sand-30' | 'sand-70' | 'frost-30' | 'syrin-30' | 'syrin-70';
|
|
4
4
|
type BgColorDarkmode = 'natt' | 'svart' | 'koksgraa';
|
|
5
|
-
export
|
|
5
|
+
export interface CardBaseProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
6
6
|
shadow?: boolean;
|
|
7
7
|
noMargin?: boolean;
|
|
8
8
|
textCenter?: boolean;
|
|
9
|
-
clickable?: boolean;
|
|
10
9
|
bgColor?: BgColor;
|
|
11
10
|
bgDarkmodeColor?: BgColorDarkmode;
|
|
12
11
|
noPadding?: boolean;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} & import("./types").DistributiveOmit<React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As>, "as" & {
|
|
17
|
-
ref: React.ForwardedRef<any>;
|
|
18
|
-
}> & {
|
|
19
|
-
shadow?: boolean | undefined;
|
|
20
|
-
noMargin?: boolean | undefined;
|
|
21
|
-
textCenter?: boolean | undefined;
|
|
22
|
-
clickable?: boolean | undefined;
|
|
23
|
-
bgColor?: BgColor | undefined;
|
|
24
|
-
bgDarkmodeColor?: BgColorDarkmode | undefined;
|
|
25
|
-
noPadding?: boolean | undefined;
|
|
26
|
-
} & React.RefAttributes<any>) => React.JSX.Element;
|
|
12
|
+
children: WithCardActionProps['children'] | React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare const CardBase: React.FC<CardBaseProps>;
|
|
27
15
|
export {};
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
import { CardRenderProps } from '../types';
|
|
3
|
+
export interface IconCardProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
4
4
|
/** Element of icon */
|
|
5
5
|
icon: ReactElement;
|
|
6
6
|
/** Smaller icon and less space */
|
|
7
7
|
condensed?: boolean;
|
|
8
8
|
children: React.ReactNode | ((cardRenderProps: CardRenderProps) => React.ReactNode);
|
|
9
|
-
}
|
|
10
|
-
export declare const IconCard:
|
|
11
|
-
/** Element of icon */
|
|
12
|
-
icon: ReactElement;
|
|
13
|
-
/** Smaller icon and less space */
|
|
14
|
-
condensed?: boolean | undefined;
|
|
15
|
-
children: React.ReactNode | ((cardRenderProps: CardRenderProps) => React.ReactNode);
|
|
16
|
-
} & React.RefAttributes<any>) => React.JSX.Element;
|
|
9
|
+
}
|
|
10
|
+
export declare const IconCard: React.FC<IconCardProps>;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CardRenderProps } from '../types';
|
|
3
|
+
export interface ImageCardProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
4
4
|
/** The src for the image */
|
|
5
5
|
imageSrc: string;
|
|
6
6
|
/** The alt text for the image */
|
|
7
7
|
imageAltText: string;
|
|
8
8
|
children: React.ReactNode | ((cardRenderProps: CardRenderProps) => React.ReactNode);
|
|
9
|
-
}
|
|
10
|
-
export declare const ImageCard:
|
|
11
|
-
/** The src for the image */
|
|
12
|
-
imageSrc: string;
|
|
13
|
-
/** The alt text for the image */
|
|
14
|
-
imageAltText: string;
|
|
15
|
-
children: React.ReactNode | ((cardRenderProps: CardRenderProps) => React.ReactNode);
|
|
16
|
-
} & React.RefAttributes<any>) => React.JSX.Element;
|
|
9
|
+
}
|
|
10
|
+
export declare const ImageCard: React.FC<ImageCardProps>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { CardRenderProps } from '../types';
|
|
3
|
+
export interface StippledCardProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
4
4
|
/** Smaller icon and less space */
|
|
5
5
|
condensed?: boolean;
|
|
6
6
|
/** Image to be rendered*/
|
|
@@ -9,14 +9,5 @@ export type StippledCardProps<As extends ElementType = 'a'> = Omit<ComponentAsPr
|
|
|
9
9
|
type: 'icon' | 'custom';
|
|
10
10
|
};
|
|
11
11
|
children: React.ReactNode | ((cardRenderProps: CardRenderProps) => React.ReactNode);
|
|
12
|
-
}
|
|
13
|
-
export declare const StippledCard:
|
|
14
|
-
/** Smaller icon and less space */
|
|
15
|
-
condensed?: boolean | undefined;
|
|
16
|
-
/** Image to be rendered*/
|
|
17
|
-
img?: {
|
|
18
|
-
element: ReactNode;
|
|
19
|
-
type: 'icon' | 'custom';
|
|
20
|
-
} | undefined;
|
|
21
|
-
children: React.ReactNode | ((cardRenderProps: CardRenderProps) => React.ReactNode);
|
|
22
|
-
} & React.RefAttributes<any>) => React.JSX.Element;
|
|
12
|
+
}
|
|
13
|
+
export declare const StippledCard: React.FC<StippledCardProps>;
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CardRenderProps } from '../types';
|
|
3
|
+
export interface TextCardProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
4
4
|
/** Left-aligned text on the card */
|
|
5
5
|
leftAlign?: boolean;
|
|
6
6
|
/** Function that's passed available sub-components as arguments, or regular children */
|
|
7
7
|
children: React.ReactNode | ((cardRenderProps: CardRenderProps) => React.ReactNode);
|
|
8
|
-
}
|
|
9
|
-
export declare const TextCard:
|
|
10
|
-
/** Left-aligned text on the card */
|
|
11
|
-
leftAlign?: boolean | undefined;
|
|
12
|
-
/** Function that's passed available sub-components as arguments, or regular children */
|
|
13
|
-
children: React.ReactNode | ((cardRenderProps: CardRenderProps) => React.ReactNode);
|
|
14
|
-
} & React.RefAttributes<any>) => React.JSX.Element;
|
|
8
|
+
}
|
|
9
|
+
export declare const TextCard: React.FC<TextCardProps>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { ElementType } from 'react';
|
|
2
|
+
import { ComponentAsPropParams } from '../types';
|
|
3
|
+
export type CardActionProps<As extends ElementType = 'a'> = ComponentAsPropParams<As>;
|
|
4
|
+
export declare const CardAction: <As extends React.ElementType>(props: {
|
|
5
|
+
as?: As | undefined;
|
|
6
|
+
} & import("../types").DistributiveOmit<React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As>, "as" & {
|
|
7
|
+
ref: React.ForwardedRef<any>;
|
|
8
|
+
}> & React.RefAttributes<any>) => React.JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CardAction } from './CardAction';
|
|
3
|
+
export interface WithCardActionProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
4
|
+
children: (props: {
|
|
5
|
+
CardAction: typeof CardAction;
|
|
6
|
+
}) => React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const WithCardAction: React.FC<WithCardActionProps>;
|
|
@@ -2,3 +2,5 @@ export { CardName, CardNameProps } from './CardName';
|
|
|
2
2
|
export { Subtext, SubtextProps } from './Subtext';
|
|
3
3
|
export { Text, TextProps } from './Text';
|
|
4
4
|
export { Title, TitleProps } from './Title';
|
|
5
|
+
export { WithCardAction, WithCardActionProps } from './WithCardAction';
|
|
6
|
+
export { CardAction, CardActionProps } from './CardAction';
|
package/types/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { ComponentPropsWithRef, ElementType, ForwardedRef } from 'react';
|
|
2
|
+
import { CardName, Subtext, Text, Title, CardAction } from './components';
|
|
3
3
|
export type DistributiveOmit<T, Omitted extends PropertyKey> = T extends any ? Omit<T, Omitted> : never;
|
|
4
4
|
export type ComponentAsPropParams<As extends ElementType> = {
|
|
5
5
|
as?: As;
|
|
@@ -8,8 +8,9 @@ export type ComponentAsPropParams<As extends ElementType> = {
|
|
|
8
8
|
}>;
|
|
9
9
|
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
10
10
|
export interface CardRenderProps {
|
|
11
|
-
CardName:
|
|
12
|
-
Title:
|
|
13
|
-
Subtext:
|
|
14
|
-
Text:
|
|
11
|
+
CardName: typeof CardName;
|
|
12
|
+
Title: typeof Title;
|
|
13
|
+
Subtext: typeof Subtext;
|
|
14
|
+
Text: typeof Text;
|
|
15
|
+
CardAction: typeof CardAction;
|
|
15
16
|
}
|