@sb1/ffe-cards-react 16.0.0 → 16.1.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 CHANGED
@@ -23,20 +23,23 @@ 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
- 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) {
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
+ var withCardActionProps = __assign({}, rest);
31
+ return (React.createElement(WithCardAction, __assign({ className: classNames('ffe-card-base', className, (_a = {},
32
+ _a["ffe-card-base--bg-".concat(bgColor)] = bgColor,
33
+ _a["ffe-card-base--dm-bg-".concat(bgDarkmodeColor)] = bgDarkmodeColor,
34
+ _a['ffe-card-base--box-shadow'] = shadow,
35
+ _a['ffe-card-base--no-margin'] = noMargin,
36
+ _a['ffe-card-base--text-center'] = textCenter,
37
+ _a['ffe-card-base--no-padding'] = noPadding,
38
+ _a)) }, withCardActionProps, { ref: ref }), function (_a) {
37
39
  var CardAction = _a.CardAction;
38
40
  return typeof children === 'function'
39
41
  ? children({ CardAction: CardAction })
40
42
  : children;
41
43
  }));
42
- };
44
+ }
45
+ export var CardBase = fixedForwardRef(CardBaseWithForwardRef);
@@ -23,9 +23,11 @@ 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
- 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) {
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
+ var withCardActionProps = __assign({}, rest);
30
+ return (React.createElement(WithCardAction, __assign({ className: classNames('ffe-icon-card', { 'ffe-icon-card--condensed': condensed }, className) }, withCardActionProps, { ref: ref }), function (_a) {
29
31
  var CardAction = _a.CardAction;
30
32
  return (React.createElement(React.Fragment, null,
31
33
  React.cloneElement(icon, __assign(__assign({}, icon.props), { className: classNames('ffe-icon-card__icon', icon.props.className) })),
@@ -39,4 +41,5 @@ export var IconCard = function (_a) {
39
41
  })
40
42
  : children)));
41
43
  }));
42
- };
44
+ }
45
+ export var IconCard = fixedForwardRef(IconCardWithForwardRef);
@@ -23,9 +23,11 @@ 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
- 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) {
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
+ var withCardActionProps = __assign({}, rest);
30
+ return (React.createElement(WithCardAction, __assign({ className: classNames('ffe-image-card', className) }, withCardActionProps, { ref: ref }), function (_a) {
29
31
  var CardAction = _a.CardAction;
30
32
  return (React.createElement(React.Fragment, null,
31
33
  React.createElement("div", { className: "ffe-image-card__image-container" },
@@ -41,4 +43,5 @@ export var ImageCard = function (_a) {
41
43
  })
42
44
  : children)));
43
45
  }));
44
- };
46
+ }
47
+ export var ImageCard = fixedForwardRef(ImageCardWithForwardRef);
@@ -23,9 +23,11 @@ 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
- 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) {
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
+ var withCardActionProps = __assign({}, rest);
30
+ return (React.createElement(WithCardAction, __assign({ className: classNames('ffe-stippled-card', { 'ffe-stippled-card--condensed': condensed }, className) }, withCardActionProps, { ref: ref }), function (_a) {
29
31
  var CardAction = _a.CardAction;
30
32
  return (React.createElement(React.Fragment, null,
31
33
  React.createElement("div", { className: classNames('ffe-stippled-card__img', {
@@ -41,4 +43,5 @@ export var StippledCard = function (_a) {
41
43
  })
42
44
  : children)));
43
45
  }));
44
- };
46
+ }
47
+ export var StippledCard = fixedForwardRef(StippledCardWithForwardRef);
@@ -23,12 +23,15 @@ 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
- 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) {
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
+ var withCardActionProps = __assign({}, rest);
30
+ return (React.createElement(WithCardAction, __assign({ className: classNames('ffe-text-card', { 'ffe-text-card--left-align': leftAlign }, className) }, withCardActionProps, { ref: ref }), function (_a) {
29
31
  var CardAction = _a.CardAction;
30
32
  return typeof children === 'function'
31
33
  ? children({ Text: Text, Subtext: Subtext, Title: Title, CardName: CardName, CardAction: CardAction })
32
34
  : children;
33
35
  }));
34
- };
36
+ }
37
+ 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
- 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) {
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: ref ? mergeRefs([ref, actionRef]) : actionRef }, restCardAction)));
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 = actionRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
42
- (_b = actionRef.current) === null || _b === void 0 ? void 0 : _b.click();
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,23 @@ 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 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) {
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
+ var withCardActionProps = __assign({}, rest);
37
+ return (react_1.default.createElement(components_1.WithCardAction, __assign({ className: (0, classnames_1.default)('ffe-card-base', className, (_a = {},
38
+ _a["ffe-card-base--bg-".concat(bgColor)] = bgColor,
39
+ _a["ffe-card-base--dm-bg-".concat(bgDarkmodeColor)] = bgDarkmodeColor,
40
+ _a['ffe-card-base--box-shadow'] = shadow,
41
+ _a['ffe-card-base--no-margin'] = noMargin,
42
+ _a['ffe-card-base--text-center'] = textCenter,
43
+ _a['ffe-card-base--no-padding'] = noPadding,
44
+ _a)) }, withCardActionProps, { ref: ref }), function (_a) {
43
45
  var CardAction = _a.CardAction;
44
46
  return typeof children === 'function'
45
47
  ? children({ CardAction: CardAction })
46
48
  : children;
47
49
  }));
48
- };
49
- exports.CardBase = CardBase;
50
+ }
51
+ exports.CardBase = (0, fixedForwardRef_1.fixedForwardRef)(CardBaseWithForwardRef);
@@ -29,9 +29,11 @@ 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 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) {
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
+ var withCardActionProps = __assign({}, rest);
36
+ return (react_1.default.createElement(components_1.WithCardAction, __assign({ className: (0, classnames_1.default)('ffe-icon-card', { 'ffe-icon-card--condensed': condensed }, className) }, withCardActionProps, { ref: ref }), function (_a) {
35
37
  var CardAction = _a.CardAction;
36
38
  return (react_1.default.createElement(react_1.default.Fragment, null,
37
39
  react_1.default.cloneElement(icon, __assign(__assign({}, icon.props), { className: (0, classnames_1.default)('ffe-icon-card__icon', icon.props.className) })),
@@ -45,5 +47,5 @@ var IconCard = function (_a) {
45
47
  })
46
48
  : children)));
47
49
  }));
48
- };
49
- exports.IconCard = IconCard;
50
+ }
51
+ exports.IconCard = (0, fixedForwardRef_1.fixedForwardRef)(IconCardWithForwardRef);
@@ -29,9 +29,11 @@ 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 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) {
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
+ var withCardActionProps = __assign({}, rest);
36
+ return (react_1.default.createElement(components_1.WithCardAction, __assign({ className: (0, classnames_1.default)('ffe-image-card', className) }, withCardActionProps, { ref: ref }), function (_a) {
35
37
  var CardAction = _a.CardAction;
36
38
  return (react_1.default.createElement(react_1.default.Fragment, null,
37
39
  react_1.default.createElement("div", { className: "ffe-image-card__image-container" },
@@ -47,5 +49,5 @@ var ImageCard = function (_a) {
47
49
  })
48
50
  : children)));
49
51
  }));
50
- };
51
- exports.ImageCard = ImageCard;
52
+ }
53
+ exports.ImageCard = (0, fixedForwardRef_1.fixedForwardRef)(ImageCardWithForwardRef);
@@ -29,9 +29,11 @@ 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 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) {
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
+ var withCardActionProps = __assign({}, rest);
36
+ return (react_1.default.createElement(components_1.WithCardAction, __assign({ className: (0, classnames_1.default)('ffe-stippled-card', { 'ffe-stippled-card--condensed': condensed }, className) }, withCardActionProps, { ref: ref }), function (_a) {
35
37
  var CardAction = _a.CardAction;
36
38
  return (react_1.default.createElement(react_1.default.Fragment, null,
37
39
  react_1.default.createElement("div", { className: (0, classnames_1.default)('ffe-stippled-card__img', {
@@ -47,5 +49,5 @@ var StippledCard = function (_a) {
47
49
  })
48
50
  : children)));
49
51
  }));
50
- };
51
- exports.StippledCard = StippledCard;
52
+ }
53
+ exports.StippledCard = (0, fixedForwardRef_1.fixedForwardRef)(StippledCardWithForwardRef);
@@ -29,13 +29,15 @@ 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 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) {
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
+ var withCardActionProps = __assign({}, rest);
36
+ return (react_1.default.createElement(components_1.WithCardAction, __assign({ className: (0, classnames_1.default)('ffe-text-card', { 'ffe-text-card--left-align': leftAlign }, className) }, withCardActionProps, { ref: ref }), function (_a) {
35
37
  var CardAction = _a.CardAction;
36
38
  return typeof children === 'function'
37
39
  ? children({ Text: components_1.Text, Subtext: components_1.Subtext, Title: components_1.Title, CardName: components_1.CardName, CardAction: CardAction })
38
40
  : children;
39
41
  }));
40
- };
41
- exports.TextCard = TextCard;
42
+ }
43
+ exports.TextCard = (0, fixedForwardRef_1.fixedForwardRef)(TextCardWithForwardRef);
@@ -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
- 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) {
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: ref ? (0, mergeRefs_1.mergeRefs)([ref, actionRef]) : actionRef }, restCardAction)));
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 = actionRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
71
- (_b = actionRef.current) === null || _b === void 0 ? void 0 : _b.click();
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 = WithCardAction;
77
+ }
78
+ exports.WithCardAction = (0, fixedForwardRef_1.fixedForwardRef)(WithCardActionForwardRef);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sb1/ffe-cards-react",
3
- "version": "16.0.0",
3
+ "version": "16.1.0",
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": "1a06e8ffb30f92e91b7825ccebada746d7f60abc"
43
+ "gitHead": "05bff605c7ba31315c43502a94476248b5d1186d"
44
44
  }
@@ -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 interface CardBaseProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
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: React.FC<CardBaseProps>;
14
+ };
15
+ export declare const CardBase: <As extends React.ElementType>(props: Omit<ComponentAsPropParams<As>, "children"> & {
16
+ shadow?: boolean | undefined;
17
+ noMargin?: boolean | undefined;
18
+ textCenter?: boolean | undefined;
19
+ bgColor?: BgColor | undefined;
20
+ bgDarkmodeColor?: BgColorDarkmode | undefined;
21
+ noPadding?: boolean | undefined;
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 interface IconCardProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
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: React.FC<IconCardProps>;
9
+ };
10
+ export declare const IconCard: <As extends React.ElementType>(props: Omit<ComponentAsPropParams<As>, "children"> & {
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;
@@ -1,10 +1,16 @@
1
- import React from 'react';
2
- import { CardRenderProps } from '../types';
3
- export interface ImageCardProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
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: React.FC<ImageCardProps>;
9
+ };
10
+ export declare const ImageCard: <As extends React.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 interface StippledCardProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
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: React.FC<StippledCardProps>;
12
+ };
13
+ export declare const StippledCard: <As extends React.ElementType>(props: Omit<ComponentAsPropParams<As>, "children"> & {
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;
@@ -1,9 +1,14 @@
1
- import React from 'react';
2
- import { CardRenderProps } from '../types';
3
- export interface TextCardProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
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
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: React.FC<TextCardProps>;
8
+ };
9
+ export declare const TextCard: <As extends React.ElementType>(props: Omit<ComponentAsPropParams<As>, "children"> & {
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;
@@ -1,8 +1,13 @@
1
- import React from 'react';
1
+ import React, { ElementType } from 'react';
2
2
  import { CardAction } from './CardAction';
3
- export interface WithCardActionProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
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: React.FC<WithCardActionProps>;
8
+ };
9
+ export declare const WithCardAction: <As extends React.ElementType>(props: Omit<ComponentAsPropParams<As>, "children"> & {
10
+ children: (props: {
11
+ CardAction: typeof CardAction;
12
+ }) => React.ReactNode;
13
+ } & React.RefAttributes<any>) => React.JSX.Element;