@sb1/ffe-cards-react 16.0.0 → 16.1.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/es/CardBase.js +14 -12
- package/es/IconCard/IconCard.js +6 -4
- package/es/ImageCard/ImageCard.js +6 -4
- package/es/StippledCard/StippledCard.js +6 -4
- package/es/TextCard/TextCard.js +6 -4
- package/es/components/WithCardAction.js +13 -12
- package/lib/CardBase.js +14 -13
- package/lib/IconCard/IconCard.js +6 -5
- package/lib/ImageCard/ImageCard.js +6 -5
- package/lib/StippledCard/StippledCard.js +6 -5
- package/lib/TextCard/TextCard.js +6 -5
- package/lib/components/CardName.js +1 -2
- package/lib/components/ComponentBase.js +1 -2
- package/lib/components/Subtext.js +1 -2
- package/lib/components/Text.js +1 -2
- package/lib/components/Title.js +1 -2
- package/lib/components/WithCardAction.js +13 -13
- package/lib/mergeRefs.js +1 -2
- package/package.json +2 -2
- package/types/CardBase.d.ts +13 -4
- package/types/IconCard/IconCard.d.ts +11 -5
- package/types/ImageCard/ImageCard.d.ts +11 -5
- package/types/StippledCard/StippledCard.d.ts +14 -5
- package/types/TextCard/TextCard.d.ts +11 -6
- package/types/components/CardAction.d.ts +1 -1
- package/types/components/WithCardAction.d.ts +9 -4
package/es/CardBase.js
CHANGED
|
@@ -23,20 +23,22 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
23
|
import React from 'react';
|
|
24
24
|
import classNames from 'classnames';
|
|
25
25
|
import { WithCardAction } from './components';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
import { fixedForwardRef } from './fixedForwardRef';
|
|
27
|
+
function CardBaseWithForwardRef(props, ref) {
|
|
28
|
+
var _a;
|
|
29
|
+
var className = props.className, shadow = props.shadow, noMargin = props.noMargin, textCenter = props.textCenter, bgColor = props.bgColor, bgDarkmodeColor = props.bgDarkmodeColor, noPadding = props.noPadding, children = props.children, rest = __rest(props, ["className", "shadow", "noMargin", "textCenter", "bgColor", "bgDarkmodeColor", "noPadding", "children"]);
|
|
30
|
+
return (React.createElement(WithCardAction, __assign({ className: classNames('ffe-card-base', className, (_a = {},
|
|
31
|
+
_a["ffe-card-base--bg-".concat(bgColor)] = bgColor,
|
|
32
|
+
_a["ffe-card-base--dm-bg-".concat(bgDarkmodeColor)] = bgDarkmodeColor,
|
|
33
|
+
_a['ffe-card-base--box-shadow'] = shadow,
|
|
34
|
+
_a['ffe-card-base--no-margin'] = noMargin,
|
|
35
|
+
_a['ffe-card-base--text-center'] = textCenter,
|
|
36
|
+
_a['ffe-card-base--no-padding'] = noPadding,
|
|
37
|
+
_a)) }, rest, { ref: ref }), function (_a) {
|
|
37
38
|
var CardAction = _a.CardAction;
|
|
38
39
|
return typeof children === 'function'
|
|
39
40
|
? children({ CardAction: CardAction })
|
|
40
41
|
: children;
|
|
41
42
|
}));
|
|
42
|
-
}
|
|
43
|
+
}
|
|
44
|
+
export var CardBase = fixedForwardRef(CardBaseWithForwardRef);
|
package/es/IconCard/IconCard.js
CHANGED
|
@@ -23,9 +23,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
23
|
import React from 'react';
|
|
24
24
|
import classNames from 'classnames';
|
|
25
25
|
import { WithCardAction, Text, Subtext, Title, CardName } from '../components';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
import { fixedForwardRef } from '../fixedForwardRef';
|
|
27
|
+
function IconCardWithForwardRef(props, ref) {
|
|
28
|
+
var className = props.className, condensed = props.condensed, icon = props.icon, children = props.children, rest = __rest(props, ["className", "condensed", "icon", "children"]);
|
|
29
|
+
return (React.createElement(WithCardAction, __assign({ className: classNames('ffe-icon-card', { 'ffe-icon-card--condensed': condensed }, className) }, rest, { ref: ref }), function (_a) {
|
|
29
30
|
var CardAction = _a.CardAction;
|
|
30
31
|
return (React.createElement(React.Fragment, null,
|
|
31
32
|
React.cloneElement(icon, __assign(__assign({}, icon.props), { className: classNames('ffe-icon-card__icon', icon.props.className) })),
|
|
@@ -39,4 +40,5 @@ export var IconCard = function (_a) {
|
|
|
39
40
|
})
|
|
40
41
|
: children)));
|
|
41
42
|
}));
|
|
42
|
-
}
|
|
43
|
+
}
|
|
44
|
+
export var IconCard = fixedForwardRef(IconCardWithForwardRef);
|
|
@@ -23,9 +23,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
23
|
import React from 'react';
|
|
24
24
|
import classNames from 'classnames';
|
|
25
25
|
import { CardName, Subtext, Text, Title, WithCardAction } from '../components';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
import { fixedForwardRef } from '../fixedForwardRef';
|
|
27
|
+
function ImageCardWithForwardRef(props, ref) {
|
|
28
|
+
var className = props.className, imageSrc = props.imageSrc, imageAltText = props.imageAltText, children = props.children, rest = __rest(props, ["className", "imageSrc", "imageAltText", "children"]);
|
|
29
|
+
return (React.createElement(WithCardAction, __assign({ className: classNames('ffe-image-card', className) }, rest, { ref: ref }), function (_a) {
|
|
29
30
|
var CardAction = _a.CardAction;
|
|
30
31
|
return (React.createElement(React.Fragment, null,
|
|
31
32
|
React.createElement("div", { className: "ffe-image-card__image-container" },
|
|
@@ -41,4 +42,5 @@ export var ImageCard = function (_a) {
|
|
|
41
42
|
})
|
|
42
43
|
: children)));
|
|
43
44
|
}));
|
|
44
|
-
}
|
|
45
|
+
}
|
|
46
|
+
export var ImageCard = fixedForwardRef(ImageCardWithForwardRef);
|
|
@@ -23,9 +23,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
23
|
import React from 'react';
|
|
24
24
|
import classNames from 'classnames';
|
|
25
25
|
import { CardName, Subtext, Text, Title, WithCardAction } from '../components';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
import { fixedForwardRef } from '../fixedForwardRef';
|
|
27
|
+
function StippledCardWithForwardRef(props, ref) {
|
|
28
|
+
var className = props.className, condensed = props.condensed, img = props.img, children = props.children, rest = __rest(props, ["className", "condensed", "img", "children"]);
|
|
29
|
+
return (React.createElement(WithCardAction, __assign({ className: classNames('ffe-stippled-card', { 'ffe-stippled-card--condensed': condensed }, className) }, rest, { ref: ref }), function (_a) {
|
|
29
30
|
var CardAction = _a.CardAction;
|
|
30
31
|
return (React.createElement(React.Fragment, null,
|
|
31
32
|
React.createElement("div", { className: classNames('ffe-stippled-card__img', {
|
|
@@ -41,4 +42,5 @@ export var StippledCard = function (_a) {
|
|
|
41
42
|
})
|
|
42
43
|
: children)));
|
|
43
44
|
}));
|
|
44
|
-
}
|
|
45
|
+
}
|
|
46
|
+
export var StippledCard = fixedForwardRef(StippledCardWithForwardRef);
|
package/es/TextCard/TextCard.js
CHANGED
|
@@ -23,12 +23,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
23
|
import React from 'react';
|
|
24
24
|
import classNames from 'classnames';
|
|
25
25
|
import { CardName, Subtext, Text, Title, WithCardAction } from '../components';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
import { fixedForwardRef } from '../fixedForwardRef';
|
|
27
|
+
function TextCardWithForwardRef(props, ref) {
|
|
28
|
+
var className = props.className, leftAlign = props.leftAlign, children = props.children, rest = __rest(props, ["className", "leftAlign", "children"]);
|
|
29
|
+
return (React.createElement(WithCardAction, __assign({ className: classNames('ffe-text-card', { 'ffe-text-card--left-align': leftAlign }, className) }, rest, { ref: ref }), function (_a) {
|
|
29
30
|
var CardAction = _a.CardAction;
|
|
30
31
|
return typeof children === 'function'
|
|
31
32
|
? children({ Text: Text, Subtext: Subtext, Title: Title, CardName: CardName, CardAction: CardAction })
|
|
32
33
|
: children;
|
|
33
34
|
}));
|
|
34
|
-
}
|
|
35
|
+
}
|
|
36
|
+
export var TextCard = fixedForwardRef(TextCardWithForwardRef);
|
|
@@ -25,24 +25,25 @@ import classNames from 'classnames';
|
|
|
25
25
|
import { mergeRefs } from '../mergeRefs';
|
|
26
26
|
import { CardAction } from './CardAction';
|
|
27
27
|
import { fixedForwardRef } from '../fixedForwardRef';
|
|
28
|
-
|
|
29
|
-
var children =
|
|
30
|
-
var
|
|
31
|
-
var PartialAppliedCardAction = useCallback(function (_a,
|
|
28
|
+
function WithCardActionForwardRef(props, ref) {
|
|
29
|
+
var children = props.children, _a = props.as, Comp = _a === void 0 ? 'div' : _a, onClick = props.onClick, rest = __rest(props, ["children", "as", "onClick"]);
|
|
30
|
+
var actionInnerRef = useRef(null);
|
|
31
|
+
var PartialAppliedCardAction = useCallback(function (_a, actionRef) {
|
|
32
32
|
var className = _a.className, restCardAction = __rest(_a, ["className"]);
|
|
33
33
|
return (React.createElement(CardAction, __assign({ className: classNames(className, 'ffe-card__action', {
|
|
34
34
|
'ffe-card__action--raw': !className,
|
|
35
|
-
}), ref:
|
|
35
|
+
}), ref: actionRef
|
|
36
|
+
? mergeRefs([actionRef, actionInnerRef])
|
|
37
|
+
: actionInnerRef }, restCardAction)));
|
|
36
38
|
}, []);
|
|
37
|
-
return (
|
|
38
|
-
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
39
|
-
React.createElement("div", __assign({}, rest, { onClick: function (e) {
|
|
39
|
+
return (React.createElement(Comp, __assign({}, rest, { onClick: function (e) {
|
|
40
40
|
var _a, _b;
|
|
41
|
-
if (!((_a =
|
|
42
|
-
(_b =
|
|
41
|
+
if (!((_a = actionInnerRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
|
|
42
|
+
(_b = actionInnerRef.current) === null || _b === void 0 ? void 0 : _b.click();
|
|
43
43
|
}
|
|
44
44
|
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
45
|
-
} }), children({
|
|
45
|
+
}, ref: ref }), children({
|
|
46
46
|
CardAction: fixedForwardRef(PartialAppliedCardAction),
|
|
47
47
|
})));
|
|
48
|
-
}
|
|
48
|
+
}
|
|
49
|
+
export var WithCardAction = fixedForwardRef(WithCardActionForwardRef);
|
package/lib/CardBase.js
CHANGED
|
@@ -29,21 +29,22 @@ exports.CardBase = void 0;
|
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
30
|
var classnames_1 = __importDefault(require("classnames"));
|
|
31
31
|
var components_1 = require("./components");
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
var fixedForwardRef_1 = require("./fixedForwardRef");
|
|
33
|
+
function CardBaseWithForwardRef(props, ref) {
|
|
34
|
+
var _a;
|
|
35
|
+
var className = props.className, shadow = props.shadow, noMargin = props.noMargin, textCenter = props.textCenter, bgColor = props.bgColor, bgDarkmodeColor = props.bgDarkmodeColor, noPadding = props.noPadding, children = props.children, rest = __rest(props, ["className", "shadow", "noMargin", "textCenter", "bgColor", "bgDarkmodeColor", "noPadding", "children"]);
|
|
36
|
+
return (react_1.default.createElement(components_1.WithCardAction, __assign({ className: (0, classnames_1.default)('ffe-card-base', className, (_a = {},
|
|
37
|
+
_a["ffe-card-base--bg-".concat(bgColor)] = bgColor,
|
|
38
|
+
_a["ffe-card-base--dm-bg-".concat(bgDarkmodeColor)] = bgDarkmodeColor,
|
|
39
|
+
_a['ffe-card-base--box-shadow'] = shadow,
|
|
40
|
+
_a['ffe-card-base--no-margin'] = noMargin,
|
|
41
|
+
_a['ffe-card-base--text-center'] = textCenter,
|
|
42
|
+
_a['ffe-card-base--no-padding'] = noPadding,
|
|
43
|
+
_a)) }, rest, { ref: ref }), function (_a) {
|
|
43
44
|
var CardAction = _a.CardAction;
|
|
44
45
|
return typeof children === 'function'
|
|
45
46
|
? children({ CardAction: CardAction })
|
|
46
47
|
: children;
|
|
47
48
|
}));
|
|
48
|
-
}
|
|
49
|
-
exports.CardBase =
|
|
49
|
+
}
|
|
50
|
+
exports.CardBase = (0, fixedForwardRef_1.fixedForwardRef)(CardBaseWithForwardRef);
|
package/lib/IconCard/IconCard.js
CHANGED
|
@@ -29,9 +29,10 @@ exports.IconCard = void 0;
|
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
30
|
var classnames_1 = __importDefault(require("classnames"));
|
|
31
31
|
var components_1 = require("../components");
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
var fixedForwardRef_1 = require("../fixedForwardRef");
|
|
33
|
+
function IconCardWithForwardRef(props, ref) {
|
|
34
|
+
var className = props.className, condensed = props.condensed, icon = props.icon, children = props.children, rest = __rest(props, ["className", "condensed", "icon", "children"]);
|
|
35
|
+
return (react_1.default.createElement(components_1.WithCardAction, __assign({ className: (0, classnames_1.default)('ffe-icon-card', { 'ffe-icon-card--condensed': condensed }, className) }, rest, { ref: ref }), function (_a) {
|
|
35
36
|
var CardAction = _a.CardAction;
|
|
36
37
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
37
38
|
react_1.default.cloneElement(icon, __assign(__assign({}, icon.props), { className: (0, classnames_1.default)('ffe-icon-card__icon', icon.props.className) })),
|
|
@@ -45,5 +46,5 @@ var IconCard = function (_a) {
|
|
|
45
46
|
})
|
|
46
47
|
: children)));
|
|
47
48
|
}));
|
|
48
|
-
}
|
|
49
|
-
exports.IconCard =
|
|
49
|
+
}
|
|
50
|
+
exports.IconCard = (0, fixedForwardRef_1.fixedForwardRef)(IconCardWithForwardRef);
|
|
@@ -29,9 +29,10 @@ exports.ImageCard = void 0;
|
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
30
|
var classnames_1 = __importDefault(require("classnames"));
|
|
31
31
|
var components_1 = require("../components");
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
var fixedForwardRef_1 = require("../fixedForwardRef");
|
|
33
|
+
function ImageCardWithForwardRef(props, ref) {
|
|
34
|
+
var className = props.className, imageSrc = props.imageSrc, imageAltText = props.imageAltText, children = props.children, rest = __rest(props, ["className", "imageSrc", "imageAltText", "children"]);
|
|
35
|
+
return (react_1.default.createElement(components_1.WithCardAction, __assign({ className: (0, classnames_1.default)('ffe-image-card', className) }, rest, { ref: ref }), function (_a) {
|
|
35
36
|
var CardAction = _a.CardAction;
|
|
36
37
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
37
38
|
react_1.default.createElement("div", { className: "ffe-image-card__image-container" },
|
|
@@ -47,5 +48,5 @@ var ImageCard = function (_a) {
|
|
|
47
48
|
})
|
|
48
49
|
: children)));
|
|
49
50
|
}));
|
|
50
|
-
}
|
|
51
|
-
exports.ImageCard =
|
|
51
|
+
}
|
|
52
|
+
exports.ImageCard = (0, fixedForwardRef_1.fixedForwardRef)(ImageCardWithForwardRef);
|
|
@@ -29,9 +29,10 @@ exports.StippledCard = void 0;
|
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
30
|
var classnames_1 = __importDefault(require("classnames"));
|
|
31
31
|
var components_1 = require("../components");
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
var fixedForwardRef_1 = require("../fixedForwardRef");
|
|
33
|
+
function StippledCardWithForwardRef(props, ref) {
|
|
34
|
+
var className = props.className, condensed = props.condensed, img = props.img, children = props.children, rest = __rest(props, ["className", "condensed", "img", "children"]);
|
|
35
|
+
return (react_1.default.createElement(components_1.WithCardAction, __assign({ className: (0, classnames_1.default)('ffe-stippled-card', { 'ffe-stippled-card--condensed': condensed }, className) }, rest, { ref: ref }), function (_a) {
|
|
35
36
|
var CardAction = _a.CardAction;
|
|
36
37
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
37
38
|
react_1.default.createElement("div", { className: (0, classnames_1.default)('ffe-stippled-card__img', {
|
|
@@ -47,5 +48,5 @@ var StippledCard = function (_a) {
|
|
|
47
48
|
})
|
|
48
49
|
: children)));
|
|
49
50
|
}));
|
|
50
|
-
}
|
|
51
|
-
exports.StippledCard =
|
|
51
|
+
}
|
|
52
|
+
exports.StippledCard = (0, fixedForwardRef_1.fixedForwardRef)(StippledCardWithForwardRef);
|
package/lib/TextCard/TextCard.js
CHANGED
|
@@ -29,13 +29,14 @@ exports.TextCard = void 0;
|
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
30
|
var classnames_1 = __importDefault(require("classnames"));
|
|
31
31
|
var components_1 = require("../components");
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
var fixedForwardRef_1 = require("../fixedForwardRef");
|
|
33
|
+
function TextCardWithForwardRef(props, ref) {
|
|
34
|
+
var className = props.className, leftAlign = props.leftAlign, children = props.children, rest = __rest(props, ["className", "leftAlign", "children"]);
|
|
35
|
+
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, { ref: ref }), function (_a) {
|
|
35
36
|
var CardAction = _a.CardAction;
|
|
36
37
|
return typeof children === 'function'
|
|
37
38
|
? children({ Text: components_1.Text, Subtext: components_1.Subtext, Title: components_1.Title, CardName: components_1.CardName, CardAction: CardAction })
|
|
38
39
|
: children;
|
|
39
40
|
}));
|
|
40
|
-
}
|
|
41
|
-
exports.TextCard =
|
|
41
|
+
}
|
|
42
|
+
exports.TextCard = (0, fixedForwardRef_1.fixedForwardRef)(TextCardWithForwardRef);
|
|
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.CardName =
|
|
28
|
+
exports.CardName = CardName;
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
30
|
var classnames_1 = __importDefault(require("classnames"));
|
|
31
31
|
var ComponentBase_1 = require("./ComponentBase");
|
|
@@ -33,4 +33,3 @@ function CardName(props) {
|
|
|
33
33
|
var className = props.className, rest = __rest(props, ["className"]);
|
|
34
34
|
return (react_1.default.createElement(ComponentBase_1.ComponentBase, __assign({ className: (0, classnames_1.default)('ffe-card-body__card-name', className) }, rest)));
|
|
35
35
|
}
|
|
36
|
-
exports.CardName = CardName;
|
|
@@ -25,10 +25,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.ComponentBase =
|
|
28
|
+
exports.ComponentBase = ComponentBase;
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
30
|
function ComponentBase(props) {
|
|
31
31
|
var _a = props.as, Comp = _a === void 0 ? 'p' : _a, rest = __rest(props, ["as"]);
|
|
32
32
|
return react_1.default.createElement(Comp, __assign({}, rest));
|
|
33
33
|
}
|
|
34
|
-
exports.ComponentBase = ComponentBase;
|
|
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.Subtext =
|
|
28
|
+
exports.Subtext = Subtext;
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
30
|
var classnames_1 = __importDefault(require("classnames"));
|
|
31
31
|
var ComponentBase_1 = require("./ComponentBase");
|
|
@@ -33,4 +33,3 @@ function Subtext(props) {
|
|
|
33
33
|
var className = props.className, rest = __rest(props, ["className"]);
|
|
34
34
|
return (react_1.default.createElement(ComponentBase_1.ComponentBase, __assign({ className: (0, classnames_1.default)('ffe-card-body__subtext', className) }, rest)));
|
|
35
35
|
}
|
|
36
|
-
exports.Subtext = Subtext;
|
package/lib/components/Text.js
CHANGED
|
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.Text =
|
|
28
|
+
exports.Text = Text;
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
30
|
var classnames_1 = __importDefault(require("classnames"));
|
|
31
31
|
var ComponentBase_1 = require("./ComponentBase");
|
|
@@ -33,4 +33,3 @@ function Text(props) {
|
|
|
33
33
|
var className = props.className, rest = __rest(props, ["className"]);
|
|
34
34
|
return (react_1.default.createElement(ComponentBase_1.ComponentBase, __assign({ className: (0, classnames_1.default)('ffe-card-body__text', className) }, rest)));
|
|
35
35
|
}
|
|
36
|
-
exports.Text = Text;
|
package/lib/components/Title.js
CHANGED
|
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.Title =
|
|
28
|
+
exports.Title = Title;
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
30
|
var classnames_1 = __importDefault(require("classnames"));
|
|
31
31
|
var ComponentBase_1 = require("./ComponentBase");
|
|
@@ -35,4 +35,3 @@ function Title(props) {
|
|
|
35
35
|
'ffe-card-body__title--overflow-ellipsis': overflowEllipsis,
|
|
36
36
|
}, className) }, rest)));
|
|
37
37
|
}
|
|
38
|
-
exports.Title = Title;
|
|
@@ -54,25 +54,25 @@ var classnames_1 = __importDefault(require("classnames"));
|
|
|
54
54
|
var mergeRefs_1 = require("../mergeRefs");
|
|
55
55
|
var CardAction_1 = require("./CardAction");
|
|
56
56
|
var fixedForwardRef_1 = require("../fixedForwardRef");
|
|
57
|
-
|
|
58
|
-
var children =
|
|
59
|
-
var
|
|
60
|
-
var PartialAppliedCardAction = (0, react_1.useCallback)(function (_a,
|
|
57
|
+
function WithCardActionForwardRef(props, ref) {
|
|
58
|
+
var children = props.children, _a = props.as, Comp = _a === void 0 ? 'div' : _a, onClick = props.onClick, rest = __rest(props, ["children", "as", "onClick"]);
|
|
59
|
+
var actionInnerRef = (0, react_1.useRef)(null);
|
|
60
|
+
var PartialAppliedCardAction = (0, react_1.useCallback)(function (_a, actionRef) {
|
|
61
61
|
var className = _a.className, restCardAction = __rest(_a, ["className"]);
|
|
62
62
|
return (react_1.default.createElement(CardAction_1.CardAction, __assign({ className: (0, classnames_1.default)(className, 'ffe-card__action', {
|
|
63
63
|
'ffe-card__action--raw': !className,
|
|
64
|
-
}), ref:
|
|
64
|
+
}), ref: actionRef
|
|
65
|
+
? (0, mergeRefs_1.mergeRefs)([actionRef, actionInnerRef])
|
|
66
|
+
: actionInnerRef }, restCardAction)));
|
|
65
67
|
}, []);
|
|
66
|
-
return (
|
|
67
|
-
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
68
|
-
react_1.default.createElement("div", __assign({}, rest, { onClick: function (e) {
|
|
68
|
+
return (react_1.default.createElement(Comp, __assign({}, rest, { onClick: function (e) {
|
|
69
69
|
var _a, _b;
|
|
70
|
-
if (!((_a =
|
|
71
|
-
(_b =
|
|
70
|
+
if (!((_a = actionInnerRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
|
|
71
|
+
(_b = actionInnerRef.current) === null || _b === void 0 ? void 0 : _b.click();
|
|
72
72
|
}
|
|
73
73
|
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
74
|
-
} }), children({
|
|
74
|
+
}, ref: ref }), children({
|
|
75
75
|
CardAction: (0, fixedForwardRef_1.fixedForwardRef)(PartialAppliedCardAction),
|
|
76
76
|
})));
|
|
77
|
-
}
|
|
78
|
-
exports.WithCardAction =
|
|
77
|
+
}
|
|
78
|
+
exports.WithCardAction = (0, fixedForwardRef_1.fixedForwardRef)(WithCardActionForwardRef);
|
package/lib/mergeRefs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeRefs =
|
|
3
|
+
exports.mergeRefs = mergeRefs;
|
|
4
4
|
function mergeRefs(refs) {
|
|
5
5
|
return function (value) {
|
|
6
6
|
refs.forEach(function (ref) {
|
|
@@ -14,4 +14,3 @@ function mergeRefs(refs) {
|
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
exports.mergeRefs = mergeRefs;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sb1/ffe-cards-react",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.1.1",
|
|
4
4
|
"description": "React implementation of ffe-react",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SpareBank 1",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "93dd227b3321cf54c3a3acf4144c50dad248033f"
|
|
44
44
|
}
|
package/types/CardBase.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ElementType } from 'react';
|
|
2
2
|
import { WithCardActionProps } from './components';
|
|
3
|
+
import { ComponentAsPropParams } from './types';
|
|
3
4
|
type BgColor = 'sand-30' | 'sand-70' | 'frost-30' | 'syrin-30' | 'syrin-70';
|
|
4
5
|
type BgColorDarkmode = 'natt' | 'svart' | 'koksgraa';
|
|
5
|
-
export
|
|
6
|
+
export type CardBaseProps<As extends ElementType = 'div'> = Omit<ComponentAsPropParams<As>, 'children'> & {
|
|
6
7
|
shadow?: boolean;
|
|
7
8
|
noMargin?: boolean;
|
|
8
9
|
textCenter?: boolean;
|
|
@@ -10,6 +11,14 @@ export interface CardBaseProps extends Omit<React.ComponentPropsWithoutRef<'div'
|
|
|
10
11
|
bgDarkmodeColor?: BgColorDarkmode;
|
|
11
12
|
noPadding?: boolean;
|
|
12
13
|
children: WithCardActionProps['children'] | React.ReactNode;
|
|
13
|
-
}
|
|
14
|
-
export declare const CardBase:
|
|
14
|
+
};
|
|
15
|
+
export declare const CardBase: <As extends ElementType>(props: Omit<ComponentAsPropParams<As>, "children"> & {
|
|
16
|
+
shadow?: boolean;
|
|
17
|
+
noMargin?: boolean;
|
|
18
|
+
textCenter?: boolean;
|
|
19
|
+
bgColor?: BgColor;
|
|
20
|
+
bgDarkmodeColor?: BgColorDarkmode;
|
|
21
|
+
noPadding?: boolean;
|
|
22
|
+
children: WithCardActionProps["children"] | React.ReactNode;
|
|
23
|
+
} & React.RefAttributes<any>) => React.JSX.Element;
|
|
15
24
|
export {};
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import React, { ReactElement } from 'react';
|
|
2
|
-
import { CardRenderProps } from '../types';
|
|
3
|
-
export
|
|
1
|
+
import React, { ElementType, ReactElement } from 'react';
|
|
2
|
+
import { CardRenderProps, ComponentAsPropParams } from '../types';
|
|
3
|
+
export type IconCardProps<As extends ElementType = 'div'> = Omit<ComponentAsPropParams<As>, '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:
|
|
9
|
+
};
|
|
10
|
+
export declare const IconCard: <As extends ElementType>(props: Omit<ComponentAsPropParams<As>, "children"> & {
|
|
11
|
+
/** Element of icon */
|
|
12
|
+
icon: ReactElement;
|
|
13
|
+
/** Smaller icon and less space */
|
|
14
|
+
condensed?: boolean;
|
|
15
|
+
children: React.ReactNode | ((cardRenderProps: CardRenderProps) => React.ReactNode);
|
|
16
|
+
} & React.RefAttributes<any>) => React.JSX.Element;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { CardRenderProps } from '../types';
|
|
3
|
-
export
|
|
1
|
+
import React, { ElementType } from 'react';
|
|
2
|
+
import { CardRenderProps, ComponentAsPropParams } from '../types';
|
|
3
|
+
export type ImageCardProps<As extends ElementType = 'div'> = Omit<ComponentAsPropParams<As>, '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:
|
|
9
|
+
};
|
|
10
|
+
export declare const ImageCard: <As extends ElementType>(props: Omit<ComponentAsPropParams<As>, "children"> & {
|
|
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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
import { CardRenderProps } from '../types';
|
|
3
|
-
export
|
|
1
|
+
import React, { ElementType, ReactNode } from 'react';
|
|
2
|
+
import { CardRenderProps, ComponentAsPropParams } from '../types';
|
|
3
|
+
export type StippledCardProps<As extends ElementType = 'div'> = Omit<ComponentAsPropParams<As>, 'children'> & {
|
|
4
4
|
/** Smaller icon and less space */
|
|
5
5
|
condensed?: boolean;
|
|
6
6
|
/** Image to be rendered*/
|
|
@@ -9,5 +9,14 @@ export interface StippledCardProps extends Omit<React.ComponentPropsWithoutRef<'
|
|
|
9
9
|
type: 'icon' | 'custom';
|
|
10
10
|
};
|
|
11
11
|
children: React.ReactNode | ((cardRenderProps: CardRenderProps) => React.ReactNode);
|
|
12
|
-
}
|
|
13
|
-
export declare const StippledCard:
|
|
12
|
+
};
|
|
13
|
+
export declare const StippledCard: <As extends ElementType>(props: Omit<ComponentAsPropParams<As>, "children"> & {
|
|
14
|
+
/** Smaller icon and less space */
|
|
15
|
+
condensed?: boolean;
|
|
16
|
+
/** Image to be rendered*/
|
|
17
|
+
img?: {
|
|
18
|
+
element: ReactNode;
|
|
19
|
+
type: "icon" | "custom";
|
|
20
|
+
};
|
|
21
|
+
children: React.ReactNode | ((cardRenderProps: CardRenderProps) => React.ReactNode);
|
|
22
|
+
} & React.RefAttributes<any>) => React.JSX.Element;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { CardRenderProps } from '../types';
|
|
3
|
-
export
|
|
1
|
+
import React, { ElementType } from 'react';
|
|
2
|
+
import { CardRenderProps, ComponentAsPropParams } from '../types';
|
|
3
|
+
export type TextCardProps<As extends ElementType = 'div'> = Omit<ComponentAsPropParams<As>, 'children'> & {
|
|
4
4
|
/** Left-aligned text on the card */
|
|
5
5
|
leftAlign?: boolean;
|
|
6
|
-
/** Function that's passed available
|
|
6
|
+
/** Function that's passed available subcomponents as arguments, or regular children */
|
|
7
7
|
children: React.ReactNode | ((cardRenderProps: CardRenderProps) => React.ReactNode);
|
|
8
|
-
}
|
|
9
|
-
export declare const TextCard:
|
|
8
|
+
};
|
|
9
|
+
export declare const TextCard: <As extends ElementType>(props: Omit<ComponentAsPropParams<As>, "children"> & {
|
|
10
|
+
/** Left-aligned text on the card */
|
|
11
|
+
leftAlign?: boolean;
|
|
12
|
+
/** Function that's passed available subcomponents as arguments, or regular children */
|
|
13
|
+
children: React.ReactNode | ((cardRenderProps: CardRenderProps) => React.ReactNode);
|
|
14
|
+
} & React.RefAttributes<any>) => React.JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ElementType } from 'react';
|
|
2
2
|
import { ComponentAsPropParams } from '../types';
|
|
3
3
|
export type CardActionProps<As extends ElementType = 'a'> = ComponentAsPropParams<As>;
|
|
4
|
-
export declare const CardAction: <As extends
|
|
4
|
+
export declare const CardAction: <As extends ElementType>(props: {
|
|
5
5
|
as?: As | undefined;
|
|
6
6
|
} & import("../types").DistributiveOmit<React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As>, "as" & {
|
|
7
7
|
ref: React.ForwardedRef<any>;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ElementType } from 'react';
|
|
2
2
|
import { CardAction } from './CardAction';
|
|
3
|
-
|
|
3
|
+
import { ComponentAsPropParams } from '../types';
|
|
4
|
+
export type WithCardActionProps<As extends ElementType = 'div'> = Omit<ComponentAsPropParams<As>, 'children'> & {
|
|
4
5
|
children: (props: {
|
|
5
6
|
CardAction: typeof CardAction;
|
|
6
7
|
}) => React.ReactNode;
|
|
7
|
-
}
|
|
8
|
-
export declare const WithCardAction:
|
|
8
|
+
};
|
|
9
|
+
export declare const WithCardAction: <As extends ElementType>(props: Omit<ComponentAsPropParams<As>, "children"> & {
|
|
10
|
+
children: (props: {
|
|
11
|
+
CardAction: typeof CardAction;
|
|
12
|
+
}) => React.ReactNode;
|
|
13
|
+
} & React.RefAttributes<any>) => React.JSX.Element;
|