@activecollab/components 1.0.155 → 1.0.156

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.
@@ -1,19 +1,25 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.EntityCard = void 0;
7
9
 
8
- var _react = _interopRequireDefault(require("react"));
10
+ var _react = _interopRequireWildcard(require("react"));
9
11
 
10
12
  var _Styles = require("./Styles");
11
13
 
12
14
  var _EntityProperty = require("./EntityProperty");
13
15
 
14
- var _excluded = ["children", "actions", "renderAs", "isCollection", "background", "className"];
16
+ var _ConditionWrapper = require("../../helpers/ConditionWrapper/ConditionWrapper");
17
+
18
+ var _excluded = ["children", "actions", "renderAs", "isCollection", "background", "className", "component"];
15
19
 
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
23
 
18
24
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
25
 
@@ -29,10 +35,17 @@ var EntityCard = function EntityCard(_ref) {
29
35
  isCollection = _ref.isCollection,
30
36
  background = _ref.background,
31
37
  className = _ref.className,
38
+ component = _ref.component,
32
39
  rest = _objectWithoutProperties(_ref, _excluded);
33
40
 
34
41
  var paperType = renderAs === "grid" ? "paper-1" : "paper-2";
35
- return /*#__PURE__*/_react.default.createElement(_Styles.StyledEntityCard, _extends({
42
+ var WrapperElement = component ? component : _react.Fragment;
43
+ return /*#__PURE__*/_react.default.createElement(_ConditionWrapper.ConditionalWrapper, {
44
+ condition: typeof component !== "undefined",
45
+ wrap: function wrap(children) {
46
+ return /*#__PURE__*/_react.default.createElement(WrapperElement, rest, children);
47
+ }
48
+ }, /*#__PURE__*/_react.default.createElement(_Styles.StyledEntityCard, _extends({
36
49
  $renderAs: renderAs,
37
50
  $background: background,
38
51
  paperType: paperType,
@@ -48,7 +61,7 @@ var EntityCard = function EntityCard(_ref) {
48
61
  return null;
49
62
  }), actions && /*#__PURE__*/_react.default.createElement(_Styles.StyledEntityActions, {
50
63
  $renderAs: renderAs
51
- }, actions));
64
+ }, actions)));
52
65
  };
53
66
 
54
67
  exports.EntityCard = EntityCard;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Entity/EntityCard.tsx"],"names":["EntityCard","children","actions","renderAs","isCollection","background","className","rest","paperType","React","Children","map","child","isValidElement","type","EntityProperty","cloneElement","$renderAs","displayName"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;;;;;;;;;AAYO,IAAMA,UAAsC,GAAG,SAAzCA,UAAyC,OAQhD;AAAA,MAPJC,QAOI,QAPJA,QAOI;AAAA,MANJC,OAMI,QANJA,OAMI;AAAA,2BALJC,QAKI;AAAA,MALJA,QAKI,8BALO,MAKP;AAAA,MAJJC,YAII,QAJJA,YAII;AAAA,MAHJC,UAGI,QAHJA,UAGI;AAAA,MAFJC,SAEI,QAFJA,SAEI;AAAA,MADDC,IACC;;AACJ,MAAMC,SAAS,GAAGL,QAAQ,KAAK,MAAb,GAAsB,SAAtB,GAAkC,SAApD;AAEA,sBACE,6BAAC,wBAAD;AACE,IAAA,SAAS,EAAEA,QADb;AAEE,IAAA,WAAW,EAAEE,UAFf;AAGE,IAAA,SAAS,EAAEG,SAHb;AAIE,IAAA,SAAS,EAAEF,SAJb;AAKE,IAAA,aAAa,EAAEF;AALjB,KAMMG,IANN,GAQGE,eAAMC,QAAN,CAAeC,GAAf,CAAmBV,QAAnB,EAA6B,UAACW,KAAD,EAAW;AACvC,QAAI,6BAAMC,cAAN,CAAqBD,KAArB,KAA+BA,KAAK,CAACE,IAAN,KAAeC,8BAAlD,EAAkE;AAChE,0BAAON,eAAMO,YAAN,CAAmBJ,KAAnB,EAA0B;AAC/BK,QAAAA,SAAS,EAAEd;AADoB,OAA1B,CAAP;AAGD;;AACD,WAAO,IAAP;AACD,GAPA,CARH,EAgBGD,OAAO,iBACN,6BAAC,2BAAD;AAAqB,IAAA,SAAS,EAAEC;AAAhC,KACGD,OADH,CAjBJ,CADF;AAwBD,CAnCM;;;AAqCPF,UAAU,CAACkB,WAAX,GAAyB,YAAzB","sourcesContent":["import React, { CSSProperties, ReactNode } from \"react\";\nimport { StyledEntityActions, StyledEntityCard } from \"./Styles\";\n\nimport { EntityProperty } from \"./EntityProperty\";\nimport { ICardProps } from \"../Card\";\n\nexport interface IEntityCardProps extends ICardProps {\n renderAs?: \"grid\" | \"list\";\n actions?: ReactNode;\n className?: string;\n isCollection?: boolean;\n background?: string;\n style?: CSSProperties;\n}\n\nexport const EntityCard: React.FC<IEntityCardProps> = ({\n children,\n actions,\n renderAs = \"grid\",\n isCollection,\n background,\n className,\n ...rest\n}) => {\n const paperType = renderAs === \"grid\" ? \"paper-1\" : \"paper-2\";\n\n return (\n <StyledEntityCard\n $renderAs={renderAs}\n $background={background}\n paperType={paperType}\n className={className}\n $isCollection={isCollection}\n {...rest}\n >\n {React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child.type === EntityProperty) {\n return React.cloneElement(child, {\n $renderAs: renderAs,\n });\n }\n return null;\n })}\n {actions && (\n <StyledEntityActions $renderAs={renderAs}>\n {actions}\n </StyledEntityActions>\n )}\n </StyledEntityCard>\n );\n};\n\nEntityCard.displayName = \"EntityCard\";\n"],"file":"EntityCard.js"}
1
+ {"version":3,"sources":["../../../../src/components/Entity/EntityCard.tsx"],"names":["EntityCard","children","actions","renderAs","isCollection","background","className","component","rest","paperType","WrapperElement","Fragment","React","Children","map","child","isValidElement","type","EntityProperty","cloneElement","$renderAs","displayName"],"mappings":";;;;;;;;;AAAA;;AAOA;;AAEA;;AAEA;;;;;;;;;;;;;;AAuBO,IAAMA,UAAsC,GAAG,SAAzCA,UAAyC,OAShD;AAAA,MARJC,QAQI,QARJA,QAQI;AAAA,MAPJC,OAOI,QAPJA,OAOI;AAAA,2BANJC,QAMI;AAAA,MANJA,QAMI,8BANO,MAMP;AAAA,MALJC,YAKI,QALJA,YAKI;AAAA,MAJJC,UAII,QAJJA,UAII;AAAA,MAHJC,SAGI,QAHJA,SAGI;AAAA,MAFJC,SAEI,QAFJA,SAEI;AAAA,MADDC,IACC;;AACJ,MAAMC,SAAS,GAAGN,QAAQ,KAAK,MAAb,GAAsB,SAAtB,GAAkC,SAApD;AAEA,MAAMO,cAAc,GAAGH,SAAS,GAAGA,SAAH,GAAeI,eAA/C;AACA,sBACE,6BAAC,oCAAD;AACE,IAAA,SAAS,EAAE,OAAOJ,SAAP,KAAqB,WADlC;AAEE,IAAA,IAAI,EAAE,cAACN,QAAD;AAAA,0BAAc,6BAAC,cAAD,EAAoBO,IAApB,EAA2BP,QAA3B,CAAd;AAAA;AAFR,kBAIE,6BAAC,wBAAD;AACE,IAAA,SAAS,EAAEE,QADb;AAEE,IAAA,WAAW,EAAEE,UAFf;AAGE,IAAA,SAAS,EAAEI,SAHb;AAIE,IAAA,SAAS,EAAEH,SAJb;AAKE,IAAA,aAAa,EAAEF;AALjB,KAMMI,IANN,GAQGI,eAAMC,QAAN,CAAeC,GAAf,CAAmBb,QAAnB,EAA6B,UAACc,KAAD,EAAW;AACvC,QAAI,6BAAMC,cAAN,CAAqBD,KAArB,KAA+BA,KAAK,CAACE,IAAN,KAAeC,8BAAlD,EAAkE;AAChE,0BAAON,eAAMO,YAAN,CAAmBJ,KAAnB,EAA0B;AAC/BK,QAAAA,SAAS,EAAEjB;AADoB,OAA1B,CAAP;AAGD;;AACD,WAAO,IAAP;AACD,GAPA,CARH,EAgBGD,OAAO,iBACN,6BAAC,2BAAD;AAAqB,IAAA,SAAS,EAAEC;AAAhC,KACGD,OADH,CAjBJ,CAJF,CADF;AA6BD,CA1CM;;;AA4CPF,UAAU,CAACqB,WAAX,GAAyB,YAAzB","sourcesContent":["import React, {\n BaseHTMLAttributes,\n ComponentType,\n CSSProperties,\n Fragment,\n ReactNode,\n} from \"react\";\nimport { StyledEntityActions, StyledEntityCard } from \"./Styles\";\n\nimport { EntityProperty } from \"./EntityProperty\";\nimport { ICardProps } from \"../Card\";\nimport { ConditionalWrapper } from \"../../helpers/ConditionWrapper/ConditionWrapper\";\n\nexport interface IEntityCardProps\n extends ICardProps,\n BaseHTMLAttributes<HTMLElement> {\n /** Render as grid or list item */\n renderAs?: \"grid\" | \"list\";\n /** action to show on right */\n actions?: ReactNode;\n /** ClassName to add on Card */\n className?: string;\n /** Show as group of Cards on grid */\n isCollection?: boolean;\n /** Background color to override for Card */\n background?: string;\n /** CSSProperties to override for Card */\n style?: CSSProperties;\n /** optional for Link react-router-dom */\n to?: string;\n /** You can pass any component as wrapper for card */\n component?: ComponentType<{ children: ReactNode }>;\n}\n\nexport const EntityCard: React.FC<IEntityCardProps> = ({\n children,\n actions,\n renderAs = \"grid\",\n isCollection,\n background,\n className,\n component,\n ...rest\n}) => {\n const paperType = renderAs === \"grid\" ? \"paper-1\" : \"paper-2\";\n\n const WrapperElement = component ? component : Fragment;\n return (\n <ConditionalWrapper\n condition={typeof component !== \"undefined\"}\n wrap={(children) => <WrapperElement {...rest}>{children}</WrapperElement>}\n >\n <StyledEntityCard\n $renderAs={renderAs}\n $background={background}\n paperType={paperType}\n className={className}\n $isCollection={isCollection}\n {...rest}\n >\n {React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child.type === EntityProperty) {\n return React.cloneElement(child, {\n $renderAs: renderAs,\n });\n }\n return null;\n })}\n {actions && (\n <StyledEntityActions $renderAs={renderAs}>\n {actions}\n </StyledEntityActions>\n )}\n </StyledEntityCard>\n </ConditionalWrapper>\n );\n};\n\nEntityCard.displayName = \"EntityCard\";\n"],"file":"EntityCard.js"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Entity/index.ts"],"names":["Entity","Group","EntityGroup","Card","EntityCard","Property","EntityProperty"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEO,IAAMA,MAAM,GAAG;AACpBC,EAAAA,KAAK,EAAEC,wBADa;AAEpBC,EAAAA,IAAI,EAAEC,sBAFc;AAGpBC,EAAAA,QAAQ,EAAEC;AAHU,CAAf","sourcesContent":["import { EntityGroup } from \"./EntityGroup\";\nimport { EntityCard } from \"./EntityCard\";\nimport { EntityProperty } from \"./EntityProperty\";\n\nexport const Entity = {\n Group: EntityGroup,\n Card: EntityCard,\n Property: EntityProperty,\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../../src/components/Entity/index.ts"],"names":["Entity","Group","EntityGroup","Card","EntityCard","Property","EntityProperty"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AAQO,IAAMA,MAAe,GAAG;AAC7BC,EAAAA,KAAK,EAAEC,wBADsB;AAE7BC,EAAAA,IAAI,EAAEC,sBAFuB;AAG7BC,EAAAA,QAAQ,EAAEC;AAHmB,CAAxB","sourcesContent":["import { ComponentType } from \"react\";\nimport { EntityGroup, IEntityGroupProps } from \"./EntityGroup\";\nimport { EntityCard, IEntityCardProps } from \"./EntityCard\";\nimport { EntityProperty, IEntityCardPropertyProps } from \"./EntityProperty\";\n\nexport interface IEntity {\n Group: ComponentType<IEntityGroupProps>;\n Card: ComponentType<IEntityCardProps>;\n Property: ComponentType<IEntityCardPropertyProps>;\n}\n\nexport const Entity: IEntity = {\n Group: EntityGroup,\n Card: EntityCard,\n Property: EntityProperty,\n};\n"],"file":"index.js"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ConditionalWrapper = void 0;
7
+
8
+ var ConditionalWrapper = function ConditionalWrapper(_ref) {
9
+ var condition = _ref.condition,
10
+ wrap = _ref.wrap,
11
+ children = _ref.children;
12
+ return condition ? wrap(children) : children;
13
+ };
14
+
15
+ exports.ConditionalWrapper = ConditionalWrapper;
16
+ //# sourceMappingURL=ConditionWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/helpers/ConditionWrapper/ConditionWrapper.tsx"],"names":["ConditionalWrapper","condition","wrap","children"],"mappings":";;;;;;;AAAO,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB;AAAA,MAAGC,SAAH,QAAGA,SAAH;AAAA,MAAcC,IAAd,QAAcA,IAAd;AAAA,MAAoBC,QAApB,QAAoBA,QAApB;AAAA,SAChCF,SAAS,GAAGC,IAAI,CAACC,QAAD,CAAP,GAAoBA,QADG;AAAA,CAA3B","sourcesContent":["export const ConditionalWrapper = ({ condition, wrap, children }) =>\n condition ? wrap(children) : children;\n"],"file":"ConditionWrapper.js"}
@@ -1,12 +1,16 @@
1
- import React, { CSSProperties, ReactNode } from "react";
1
+ import React, { BaseHTMLAttributes, ComponentType, CSSProperties, ReactNode } from "react";
2
2
  import { ICardProps } from "../Card";
3
- export interface IEntityCardProps extends ICardProps {
3
+ export interface IEntityCardProps extends ICardProps, BaseHTMLAttributes<HTMLElement> {
4
4
  renderAs?: "grid" | "list";
5
5
  actions?: ReactNode;
6
6
  className?: string;
7
7
  isCollection?: boolean;
8
8
  background?: string;
9
9
  style?: CSSProperties;
10
+ to?: string;
11
+ component?: ComponentType<{
12
+ children: ReactNode;
13
+ }>;
10
14
  }
11
15
  export declare const EntityCard: React.FC<IEntityCardProps>;
12
16
  //# sourceMappingURL=EntityCard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EntityCard.d.ts","sourceRoot":"","sources":["../../../../src/components/Entity/EntityCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIxD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAmCjD,CAAC"}
1
+ {"version":3,"file":"EntityCard.d.ts","sourceRoot":"","sources":["../../../../src/components/Entity/EntityCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,kBAAkB,EAClB,aAAa,EACb,aAAa,EAEb,SAAS,EACV,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC,MAAM,WAAW,gBACf,SAAQ,UAAU,EAChB,kBAAkB,CAAC,WAAW,CAAC;IAEjC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE3B,OAAO,CAAC,EAAE,SAAS,CAAC;IAEpB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,KAAK,CAAC,EAAE,aAAa,CAAC;IAEtB,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ,SAAS,CAAC,EAAE,aAAa,CAAC;QAAE,QAAQ,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;CACpD;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA0CjD,CAAC"}
@@ -1,9 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- var _excluded = ["children", "actions", "renderAs", "isCollection", "background", "className"];
4
- import React from "react";
3
+ var _excluded = ["children", "actions", "renderAs", "isCollection", "background", "className", "component"];
4
+ import React, { Fragment } from "react";
5
5
  import { StyledEntityActions, StyledEntityCard } from "./Styles";
6
6
  import { EntityProperty } from "./EntityProperty";
7
+ import { ConditionalWrapper } from "../../helpers/ConditionWrapper/ConditionWrapper";
7
8
  export var EntityCard = function EntityCard(_ref) {
8
9
  var children = _ref.children,
9
10
  actions = _ref.actions,
@@ -12,10 +13,17 @@ export var EntityCard = function EntityCard(_ref) {
12
13
  isCollection = _ref.isCollection,
13
14
  background = _ref.background,
14
15
  className = _ref.className,
16
+ component = _ref.component,
15
17
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
16
18
 
17
19
  var paperType = renderAs === "grid" ? "paper-1" : "paper-2";
18
- return /*#__PURE__*/React.createElement(StyledEntityCard, _extends({
20
+ var WrapperElement = component ? component : Fragment;
21
+ return /*#__PURE__*/React.createElement(ConditionalWrapper, {
22
+ condition: typeof component !== "undefined",
23
+ wrap: function wrap(children) {
24
+ return /*#__PURE__*/React.createElement(WrapperElement, rest, children);
25
+ }
26
+ }, /*#__PURE__*/React.createElement(StyledEntityCard, _extends({
19
27
  $renderAs: renderAs,
20
28
  $background: background,
21
29
  paperType: paperType,
@@ -31,7 +39,7 @@ export var EntityCard = function EntityCard(_ref) {
31
39
  return null;
32
40
  }), actions && /*#__PURE__*/React.createElement(StyledEntityActions, {
33
41
  $renderAs: renderAs
34
- }, actions));
42
+ }, actions)));
35
43
  };
36
44
  EntityCard.displayName = "EntityCard";
37
45
  //# sourceMappingURL=EntityCard.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Entity/EntityCard.tsx"],"names":["React","StyledEntityActions","StyledEntityCard","EntityProperty","EntityCard","children","actions","renderAs","isCollection","background","className","rest","paperType","Children","map","child","isValidElement","type","cloneElement","$renderAs","displayName"],"mappings":";;;AAAA,OAAOA,KAAP,MAAgD,OAAhD;AACA,SAASC,mBAAT,EAA8BC,gBAA9B,QAAsD,UAAtD;AAEA,SAASC,cAAT,QAA+B,kBAA/B;AAYA,OAAO,IAAMC,UAAsC,GAAG,SAAzCA,UAAyC,OAQhD;AAAA,MAPJC,QAOI,QAPJA,QAOI;AAAA,MANJC,OAMI,QANJA,OAMI;AAAA,2BALJC,QAKI;AAAA,MALJA,QAKI,8BALO,MAKP;AAAA,MAJJC,YAII,QAJJA,YAII;AAAA,MAHJC,UAGI,QAHJA,UAGI;AAAA,MAFJC,SAEI,QAFJA,SAEI;AAAA,MADDC,IACC;;AACJ,MAAMC,SAAS,GAAGL,QAAQ,KAAK,MAAb,GAAsB,SAAtB,GAAkC,SAApD;AAEA,sBACE,oBAAC,gBAAD;AACE,IAAA,SAAS,EAAEA,QADb;AAEE,IAAA,WAAW,EAAEE,UAFf;AAGE,IAAA,SAAS,EAAEG,SAHb;AAIE,IAAA,SAAS,EAAEF,SAJb;AAKE,IAAA,aAAa,EAAEF;AALjB,KAMMG,IANN,GAQGX,KAAK,CAACa,QAAN,CAAeC,GAAf,CAAmBT,QAAnB,EAA6B,UAACU,KAAD,EAAW;AACvC,QAAI,cAAAf,KAAK,CAACgB,cAAN,CAAqBD,KAArB,KAA+BA,KAAK,CAACE,IAAN,KAAed,cAAlD,EAAkE;AAChE,0BAAOH,KAAK,CAACkB,YAAN,CAAmBH,KAAnB,EAA0B;AAC/BI,QAAAA,SAAS,EAAEZ;AADoB,OAA1B,CAAP;AAGD;;AACD,WAAO,IAAP;AACD,GAPA,CARH,EAgBGD,OAAO,iBACN,oBAAC,mBAAD;AAAqB,IAAA,SAAS,EAAEC;AAAhC,KACGD,OADH,CAjBJ,CADF;AAwBD,CAnCM;AAqCPF,UAAU,CAACgB,WAAX,GAAyB,YAAzB","sourcesContent":["import React, { CSSProperties, ReactNode } from \"react\";\nimport { StyledEntityActions, StyledEntityCard } from \"./Styles\";\n\nimport { EntityProperty } from \"./EntityProperty\";\nimport { ICardProps } from \"../Card\";\n\nexport interface IEntityCardProps extends ICardProps {\n renderAs?: \"grid\" | \"list\";\n actions?: ReactNode;\n className?: string;\n isCollection?: boolean;\n background?: string;\n style?: CSSProperties;\n}\n\nexport const EntityCard: React.FC<IEntityCardProps> = ({\n children,\n actions,\n renderAs = \"grid\",\n isCollection,\n background,\n className,\n ...rest\n}) => {\n const paperType = renderAs === \"grid\" ? \"paper-1\" : \"paper-2\";\n\n return (\n <StyledEntityCard\n $renderAs={renderAs}\n $background={background}\n paperType={paperType}\n className={className}\n $isCollection={isCollection}\n {...rest}\n >\n {React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child.type === EntityProperty) {\n return React.cloneElement(child, {\n $renderAs: renderAs,\n });\n }\n return null;\n })}\n {actions && (\n <StyledEntityActions $renderAs={renderAs}>\n {actions}\n </StyledEntityActions>\n )}\n </StyledEntityCard>\n );\n};\n\nEntityCard.displayName = \"EntityCard\";\n"],"file":"EntityCard.js"}
1
+ {"version":3,"sources":["../../../../src/components/Entity/EntityCard.tsx"],"names":["React","Fragment","StyledEntityActions","StyledEntityCard","EntityProperty","ConditionalWrapper","EntityCard","children","actions","renderAs","isCollection","background","className","component","rest","paperType","WrapperElement","Children","map","child","isValidElement","type","cloneElement","$renderAs","displayName"],"mappings":";;;AAAA,OAAOA,KAAP,IAIEC,QAJF,QAMO,OANP;AAOA,SAASC,mBAAT,EAA8BC,gBAA9B,QAAsD,UAAtD;AAEA,SAASC,cAAT,QAA+B,kBAA/B;AAEA,SAASC,kBAAT,QAAmC,iDAAnC;AAuBA,OAAO,IAAMC,UAAsC,GAAG,SAAzCA,UAAyC,OAShD;AAAA,MARJC,QAQI,QARJA,QAQI;AAAA,MAPJC,OAOI,QAPJA,OAOI;AAAA,2BANJC,QAMI;AAAA,MANJA,QAMI,8BANO,MAMP;AAAA,MALJC,YAKI,QALJA,YAKI;AAAA,MAJJC,UAII,QAJJA,UAII;AAAA,MAHJC,SAGI,QAHJA,SAGI;AAAA,MAFJC,SAEI,QAFJA,SAEI;AAAA,MADDC,IACC;;AACJ,MAAMC,SAAS,GAAGN,QAAQ,KAAK,MAAb,GAAsB,SAAtB,GAAkC,SAApD;AAEA,MAAMO,cAAc,GAAGH,SAAS,GAAGA,SAAH,GAAeZ,QAA/C;AACA,sBACE,oBAAC,kBAAD;AACE,IAAA,SAAS,EAAE,OAAOY,SAAP,KAAqB,WADlC;AAEE,IAAA,IAAI,EAAE,cAACN,QAAD;AAAA,0BAAc,oBAAC,cAAD,EAAoBO,IAApB,EAA2BP,QAA3B,CAAd;AAAA;AAFR,kBAIE,oBAAC,gBAAD;AACE,IAAA,SAAS,EAAEE,QADb;AAEE,IAAA,WAAW,EAAEE,UAFf;AAGE,IAAA,SAAS,EAAEI,SAHb;AAIE,IAAA,SAAS,EAAEH,SAJb;AAKE,IAAA,aAAa,EAAEF;AALjB,KAMMI,IANN,GAQGd,KAAK,CAACiB,QAAN,CAAeC,GAAf,CAAmBX,QAAnB,EAA6B,UAACY,KAAD,EAAW;AACvC,QAAI,cAAAnB,KAAK,CAACoB,cAAN,CAAqBD,KAArB,KAA+BA,KAAK,CAACE,IAAN,KAAejB,cAAlD,EAAkE;AAChE,0BAAOJ,KAAK,CAACsB,YAAN,CAAmBH,KAAnB,EAA0B;AAC/BI,QAAAA,SAAS,EAAEd;AADoB,OAA1B,CAAP;AAGD;;AACD,WAAO,IAAP;AACD,GAPA,CARH,EAgBGD,OAAO,iBACN,oBAAC,mBAAD;AAAqB,IAAA,SAAS,EAAEC;AAAhC,KACGD,OADH,CAjBJ,CAJF,CADF;AA6BD,CA1CM;AA4CPF,UAAU,CAACkB,WAAX,GAAyB,YAAzB","sourcesContent":["import React, {\n BaseHTMLAttributes,\n ComponentType,\n CSSProperties,\n Fragment,\n ReactNode,\n} from \"react\";\nimport { StyledEntityActions, StyledEntityCard } from \"./Styles\";\n\nimport { EntityProperty } from \"./EntityProperty\";\nimport { ICardProps } from \"../Card\";\nimport { ConditionalWrapper } from \"../../helpers/ConditionWrapper/ConditionWrapper\";\n\nexport interface IEntityCardProps\n extends ICardProps,\n BaseHTMLAttributes<HTMLElement> {\n /** Render as grid or list item */\n renderAs?: \"grid\" | \"list\";\n /** action to show on right */\n actions?: ReactNode;\n /** ClassName to add on Card */\n className?: string;\n /** Show as group of Cards on grid */\n isCollection?: boolean;\n /** Background color to override for Card */\n background?: string;\n /** CSSProperties to override for Card */\n style?: CSSProperties;\n /** optional for Link react-router-dom */\n to?: string;\n /** You can pass any component as wrapper for card */\n component?: ComponentType<{ children: ReactNode }>;\n}\n\nexport const EntityCard: React.FC<IEntityCardProps> = ({\n children,\n actions,\n renderAs = \"grid\",\n isCollection,\n background,\n className,\n component,\n ...rest\n}) => {\n const paperType = renderAs === \"grid\" ? \"paper-1\" : \"paper-2\";\n\n const WrapperElement = component ? component : Fragment;\n return (\n <ConditionalWrapper\n condition={typeof component !== \"undefined\"}\n wrap={(children) => <WrapperElement {...rest}>{children}</WrapperElement>}\n >\n <StyledEntityCard\n $renderAs={renderAs}\n $background={background}\n paperType={paperType}\n className={className}\n $isCollection={isCollection}\n {...rest}\n >\n {React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child.type === EntityProperty) {\n return React.cloneElement(child, {\n $renderAs: renderAs,\n });\n }\n return null;\n })}\n {actions && (\n <StyledEntityActions $renderAs={renderAs}>\n {actions}\n </StyledEntityActions>\n )}\n </StyledEntityCard>\n </ConditionalWrapper>\n );\n};\n\nEntityCard.displayName = \"EntityCard\";\n"],"file":"EntityCard.js"}
@@ -1,7 +1,11 @@
1
- /// <reference types="react" />
2
- export declare const Entity: {
3
- Group: import("react").FC<import("./EntityGroup").IEntityGroupProps>;
4
- Card: import("react").FC<import("./EntityCard").IEntityCardProps>;
5
- Property: import("react").FC<import("./EntityProperty").IEntityCardPropertyProps>;
6
- };
1
+ import { ComponentType } from "react";
2
+ import { IEntityGroupProps } from "./EntityGroup";
3
+ import { IEntityCardProps } from "./EntityCard";
4
+ import { IEntityCardPropertyProps } from "./EntityProperty";
5
+ export interface IEntity {
6
+ Group: ComponentType<IEntityGroupProps>;
7
+ Card: ComponentType<IEntityCardProps>;
8
+ Property: ComponentType<IEntityCardPropertyProps>;
9
+ }
10
+ export declare const Entity: IEntity;
7
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Entity/index.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,MAAM;;;;CAIlB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Entity/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAe,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAc,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAkB,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAE5E,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IACxC,IAAI,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACtC,QAAQ,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC;CACnD;AAED,eAAO,MAAM,MAAM,EAAE,OAIpB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Entity/index.ts"],"names":["EntityGroup","EntityCard","EntityProperty","Entity","Group","Card","Property"],"mappings":"AAAA,SAASA,WAAT,QAA4B,eAA5B;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,cAAT,QAA+B,kBAA/B;AAEA,OAAO,IAAMC,MAAM,GAAG;AACpBC,EAAAA,KAAK,EAAEJ,WADa;AAEpBK,EAAAA,IAAI,EAAEJ,UAFc;AAGpBK,EAAAA,QAAQ,EAAEJ;AAHU,CAAf","sourcesContent":["import { EntityGroup } from \"./EntityGroup\";\nimport { EntityCard } from \"./EntityCard\";\nimport { EntityProperty } from \"./EntityProperty\";\n\nexport const Entity = {\n Group: EntityGroup,\n Card: EntityCard,\n Property: EntityProperty,\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../../src/components/Entity/index.ts"],"names":["EntityGroup","EntityCard","EntityProperty","Entity","Group","Card","Property"],"mappings":"AACA,SAASA,WAAT,QAA+C,eAA/C;AACA,SAASC,UAAT,QAA6C,cAA7C;AACA,SAASC,cAAT,QAAyD,kBAAzD;AAQA,OAAO,IAAMC,MAAe,GAAG;AAC7BC,EAAAA,KAAK,EAAEJ,WADsB;AAE7BK,EAAAA,IAAI,EAAEJ,UAFuB;AAG7BK,EAAAA,QAAQ,EAAEJ;AAHmB,CAAxB","sourcesContent":["import { ComponentType } from \"react\";\nimport { EntityGroup, IEntityGroupProps } from \"./EntityGroup\";\nimport { EntityCard, IEntityCardProps } from \"./EntityCard\";\nimport { EntityProperty, IEntityCardPropertyProps } from \"./EntityProperty\";\n\nexport interface IEntity {\n Group: ComponentType<IEntityGroupProps>;\n Card: ComponentType<IEntityCardProps>;\n Property: ComponentType<IEntityCardPropertyProps>;\n}\n\nexport const Entity: IEntity = {\n Group: EntityGroup,\n Card: EntityCard,\n Property: EntityProperty,\n};\n"],"file":"index.js"}
@@ -0,0 +1,6 @@
1
+ export declare const ConditionalWrapper: ({ condition, wrap, children }: {
2
+ condition: any;
3
+ wrap: any;
4
+ children: any;
5
+ }) => any;
6
+ //# sourceMappingURL=ConditionWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConditionWrapper.d.ts","sourceRoot":"","sources":["../../../../src/helpers/ConditionWrapper/ConditionWrapper.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB;;;;SACQ,CAAC"}
@@ -0,0 +1,7 @@
1
+ export var ConditionalWrapper = function ConditionalWrapper(_ref) {
2
+ var condition = _ref.condition,
3
+ wrap = _ref.wrap,
4
+ children = _ref.children;
5
+ return condition ? wrap(children) : children;
6
+ };
7
+ //# sourceMappingURL=ConditionWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/helpers/ConditionWrapper/ConditionWrapper.tsx"],"names":["ConditionalWrapper","condition","wrap","children"],"mappings":"AAAA,OAAO,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB;AAAA,MAAGC,SAAH,QAAGA,SAAH;AAAA,MAAcC,IAAd,QAAcA,IAAd;AAAA,MAAoBC,QAApB,QAAoBA,QAApB;AAAA,SAChCF,SAAS,GAAGC,IAAI,CAACC,QAAD,CAAP,GAAoBA,QADG;AAAA,CAA3B","sourcesContent":["export const ConditionalWrapper = ({ condition, wrap, children }) =>\n condition ? wrap(children) : children;\n"],"file":"ConditionWrapper.js"}
package/dist/index.js CHANGED
@@ -11792,7 +11792,14 @@
11792
11792
  };
11793
11793
  EntityProperty.displayName = "EntityProperty";
11794
11794
 
11795
- var _excluded$1 = ["children", "actions", "renderAs", "isCollection", "background", "className"];
11795
+ var ConditionalWrapper = function ConditionalWrapper(_ref) {
11796
+ var condition = _ref.condition,
11797
+ wrap = _ref.wrap,
11798
+ children = _ref.children;
11799
+ return condition ? wrap(children) : children;
11800
+ };
11801
+
11802
+ var _excluded$1 = ["children", "actions", "renderAs", "isCollection", "background", "className", "component"];
11796
11803
  var EntityCard = function EntityCard(_ref) {
11797
11804
  var children = _ref.children,
11798
11805
  actions = _ref.actions,
@@ -11801,10 +11808,17 @@
11801
11808
  isCollection = _ref.isCollection,
11802
11809
  background = _ref.background,
11803
11810
  className = _ref.className,
11811
+ component = _ref.component,
11804
11812
  rest = _objectWithoutProperties(_ref, _excluded$1);
11805
11813
 
11806
11814
  var paperType = renderAs === "grid" ? "paper-1" : "paper-2";
11807
- return /*#__PURE__*/React__default["default"].createElement(StyledEntityCard, _extends({
11815
+ var WrapperElement = component ? component : React.Fragment;
11816
+ return /*#__PURE__*/React__default["default"].createElement(ConditionalWrapper, {
11817
+ condition: typeof component !== "undefined",
11818
+ wrap: function wrap(children) {
11819
+ return /*#__PURE__*/React__default["default"].createElement(WrapperElement, rest, children);
11820
+ }
11821
+ }, /*#__PURE__*/React__default["default"].createElement(StyledEntityCard, _extends({
11808
11822
  $renderAs: renderAs,
11809
11823
  $background: background,
11810
11824
  paperType: paperType,
@@ -11820,7 +11834,7 @@
11820
11834
  return null;
11821
11835
  }), actions && /*#__PURE__*/React__default["default"].createElement(StyledEntityActions, {
11822
11836
  $renderAs: renderAs
11823
- }, actions));
11837
+ }, actions)));
11824
11838
  };
11825
11839
  EntityCard.displayName = "EntityCard";
11826
11840