@sb1/ffe-cards-react 17.6.7 → 18.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.
@@ -20,13 +20,13 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  }
21
21
  return t;
22
22
  };
23
- import React from 'react';
24
23
  import classNames from 'classnames';
25
- import { WithCardAction, Text, Subtext, Title, CardName } from '../components';
24
+ import React from 'react';
25
+ import { CardName, Subtext, Text, Title, WithCardAction } from '../components';
26
26
  import { fixedForwardRef } from '../fixedForwardRef';
27
27
  function IconCardWithForwardRef(props, ref) {
28
- var className = props.className, condensed = props.condensed, icon = props.icon, noMargin = props.noMargin, children = props.children, iconPosition = props.iconPosition, rest = __rest(props, ["className", "condensed", "icon", "noMargin", "children", "iconPosition"]);
29
- return (React.createElement(WithCardAction, __assign({ baseClassName: "ffe-icon-card", className: classNames('ffe-icon-card', { 'ffe-icon-card--condensed': condensed }, { 'ffe-icon-card--no-margin': noMargin }, { 'ffe-icon-card--right': iconPosition === 'right' }, className) }, rest, { ref: ref }), function (_a) {
28
+ var className = props.className, condensed = props.condensed, icon = props.icon, rightIcon = props.rightIcon, noMargin = props.noMargin, children = props.children, rest = __rest(props, ["className", "condensed", "icon", "rightIcon", "noMargin", "children"]);
29
+ return (React.createElement(WithCardAction, __assign({ baseClassName: "ffe-icon-card", className: classNames('ffe-icon-card', { 'ffe-icon-card--condensed': condensed }, { 'ffe-icon-card--no-margin': noMargin }, className) }, rest, { ref: ref }), function (_a) {
30
30
  var CardAction = _a.CardAction;
31
31
  var bodyElement = (React.createElement("div", { className: "ffe-icon-card__body" }, typeof children === 'function'
32
32
  ? children({
@@ -37,12 +37,14 @@ function IconCardWithForwardRef(props, ref) {
37
37
  CardAction: CardAction,
38
38
  })
39
39
  : children));
40
- var iconElement = React.cloneElement(icon, __assign(__assign({}, icon.props), { className: classNames('ffe-icon-card__icon', icon.props.className) }));
41
- return iconPosition === 'right' ? (React.createElement(React.Fragment, null,
42
- bodyElement,
43
- iconElement)) : (React.createElement(React.Fragment, null,
40
+ var iconElement = icon &&
41
+ React.cloneElement(icon, __assign(__assign({}, icon.props), { className: classNames('ffe-icon-card__icon', icon.props.className) }));
42
+ var rightIconElement = rightIcon &&
43
+ React.cloneElement(rightIcon, __assign(__assign({}, rightIcon.props), { className: classNames('ffe-icon-card__icon', rightIcon.props.className) }));
44
+ return (React.createElement(React.Fragment, null,
44
45
  iconElement,
45
- bodyElement));
46
+ bodyElement,
47
+ rightIconElement));
46
48
  }));
47
49
  }
48
50
  export var IconCard = fixedForwardRef(IconCardWithForwardRef);
@@ -26,13 +26,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
28
  exports.IconCard = void 0;
29
- var react_1 = __importDefault(require("react"));
30
29
  var classnames_1 = __importDefault(require("classnames"));
30
+ var react_1 = __importDefault(require("react"));
31
31
  var components_1 = require("../components");
32
32
  var fixedForwardRef_1 = require("../fixedForwardRef");
33
33
  function IconCardWithForwardRef(props, ref) {
34
- var className = props.className, condensed = props.condensed, icon = props.icon, noMargin = props.noMargin, children = props.children, iconPosition = props.iconPosition, rest = __rest(props, ["className", "condensed", "icon", "noMargin", "children", "iconPosition"]);
35
- return (react_1.default.createElement(components_1.WithCardAction, __assign({ baseClassName: "ffe-icon-card", className: (0, classnames_1.default)('ffe-icon-card', { 'ffe-icon-card--condensed': condensed }, { 'ffe-icon-card--no-margin': noMargin }, { 'ffe-icon-card--right': iconPosition === 'right' }, className) }, rest, { ref: ref }), function (_a) {
34
+ var className = props.className, condensed = props.condensed, icon = props.icon, rightIcon = props.rightIcon, noMargin = props.noMargin, children = props.children, rest = __rest(props, ["className", "condensed", "icon", "rightIcon", "noMargin", "children"]);
35
+ return (react_1.default.createElement(components_1.WithCardAction, __assign({ baseClassName: "ffe-icon-card", className: (0, classnames_1.default)('ffe-icon-card', { 'ffe-icon-card--condensed': condensed }, { 'ffe-icon-card--no-margin': noMargin }, className) }, rest, { ref: ref }), function (_a) {
36
36
  var CardAction = _a.CardAction;
37
37
  var bodyElement = (react_1.default.createElement("div", { className: "ffe-icon-card__body" }, typeof children === 'function'
38
38
  ? children({
@@ -43,12 +43,14 @@ function IconCardWithForwardRef(props, ref) {
43
43
  CardAction: CardAction,
44
44
  })
45
45
  : children));
46
- var iconElement = react_1.default.cloneElement(icon, __assign(__assign({}, icon.props), { className: (0, classnames_1.default)('ffe-icon-card__icon', icon.props.className) }));
47
- return iconPosition === 'right' ? (react_1.default.createElement(react_1.default.Fragment, null,
48
- bodyElement,
49
- iconElement)) : (react_1.default.createElement(react_1.default.Fragment, null,
46
+ var iconElement = icon &&
47
+ react_1.default.cloneElement(icon, __assign(__assign({}, icon.props), { className: (0, classnames_1.default)('ffe-icon-card__icon', icon.props.className) }));
48
+ var rightIconElement = rightIcon &&
49
+ react_1.default.cloneElement(rightIcon, __assign(__assign({}, rightIcon.props), { className: (0, classnames_1.default)('ffe-icon-card__icon', rightIcon.props.className) }));
50
+ return (react_1.default.createElement(react_1.default.Fragment, null,
50
51
  iconElement,
51
- bodyElement));
52
+ bodyElement,
53
+ rightIconElement));
52
54
  }));
53
55
  }
54
56
  exports.IconCard = (0, fixedForwardRef_1.fixedForwardRef)(IconCardWithForwardRef);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sb1/ffe-cards-react",
3
- "version": "17.6.7",
3
+ "version": "18.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": "^20.4.4"
29
+ "@sb1/ffe-cards": "^21.0.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@sb1/ffe-buildtool": "^0.9.0",
33
- "@sb1/ffe-icons-react": "^11.0.16",
32
+ "@sb1/ffe-buildtool": "^0.9.1",
33
+ "@sb1/ffe-icons-react": "^11.0.17",
34
34
  "react": "^18.2.0",
35
35
  "react-dom": "^18.2.0"
36
36
  },
@@ -40,5 +40,5 @@
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "92f6e9180ae0070960e6900eec4e2dfdd56726ed"
43
+ "gitHead": "7b652097b54e99c0993ffb58b147805a54472a91"
44
44
  }
@@ -2,22 +2,20 @@ import React, { ElementType, ReactElement } from 'react';
2
2
  import { CardRenderProps, ComponentAsPropParams } from '../types';
3
3
  export type IconCardProps<As extends ElementType = 'div'> = Omit<ComponentAsPropParams<As>, 'children'> & {
4
4
  /** Element of icon */
5
- icon: ReactElement;
5
+ icon?: ReactElement;
6
+ rightIcon?: ReactElement;
6
7
  /** Smaller icon and less space */
7
8
  condensed?: boolean;
8
- /** Position icon at left (default) or right of the card content */
9
- iconPosition?: 'right' | 'left';
10
9
  /** No margin on card */
11
10
  noMargin?: boolean;
12
11
  children: React.ReactNode | ((cardRenderProps: CardRenderProps) => React.ReactNode);
13
12
  };
14
13
  export declare const IconCard: <As extends ElementType>(props: Omit<ComponentAsPropParams<As>, "children"> & {
15
14
  /** Element of icon */
16
- icon: ReactElement;
15
+ icon?: ReactElement;
16
+ rightIcon?: ReactElement;
17
17
  /** Smaller icon and less space */
18
18
  condensed?: boolean;
19
- /** Position icon at left (default) or right of the card content */
20
- iconPosition?: "right" | "left";
21
19
  /** No margin on card */
22
20
  noMargin?: boolean;
23
21
  children: React.ReactNode | ((cardRenderProps: CardRenderProps) => React.ReactNode);