@laerdal/life-react-components 1.5.1-dev.9 → 1.6.1-dev.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.
Files changed (108) hide show
  1. package/dist/Button/Iconbutton.cjs +12 -13
  2. package/dist/Button/Iconbutton.cjs.map +1 -1
  3. package/dist/Button/Iconbutton.js +12 -13
  4. package/dist/Button/Iconbutton.js.map +1 -1
  5. package/dist/Card/Card.cjs +101 -0
  6. package/dist/Card/Card.cjs.map +1 -0
  7. package/dist/Card/Card.d.ts +23 -0
  8. package/dist/Card/Card.js +74 -0
  9. package/dist/Card/Card.js.map +1 -0
  10. package/dist/Card/CardBottomSection.cjs +133 -0
  11. package/dist/Card/CardBottomSection.cjs.map +1 -0
  12. package/dist/Card/CardBottomSection.d.ts +22 -0
  13. package/dist/Card/CardBottomSection.js +105 -0
  14. package/dist/Card/CardBottomSection.js.map +1 -0
  15. package/dist/Card/CardMiddleSection.cjs +94 -0
  16. package/dist/Card/CardMiddleSection.cjs.map +1 -0
  17. package/dist/Card/CardMiddleSection.d.ts +14 -0
  18. package/dist/Card/CardMiddleSection.js +71 -0
  19. package/dist/Card/CardMiddleSection.js.map +1 -0
  20. package/dist/Card/CardTopSection.cjs +112 -0
  21. package/dist/Card/CardTopSection.cjs.map +1 -0
  22. package/dist/Card/CardTopSection.d.ts +19 -0
  23. package/dist/Card/CardTopSection.js +85 -0
  24. package/dist/Card/CardTopSection.js.map +1 -0
  25. package/dist/Card/index.cjs +52 -0
  26. package/dist/Card/index.cjs.map +1 -0
  27. package/dist/Card/index.d.ts +5 -0
  28. package/dist/Card/index.js +6 -0
  29. package/dist/Card/index.js.map +1 -0
  30. package/dist/Dropdown/BasicDropdown.cjs +38 -55
  31. package/dist/Dropdown/BasicDropdown.cjs.map +1 -1
  32. package/dist/Dropdown/BasicDropdown.js +36 -53
  33. package/dist/Dropdown/BasicDropdown.js.map +1 -1
  34. package/dist/Dropdown/CommonStyling.cjs +9 -17
  35. package/dist/Dropdown/CommonStyling.cjs.map +1 -1
  36. package/dist/Dropdown/CommonStyling.d.ts +0 -3
  37. package/dist/Dropdown/CommonStyling.js +8 -12
  38. package/dist/Dropdown/CommonStyling.js.map +1 -1
  39. package/dist/Dropdown/DropdownButton.cjs +11 -24
  40. package/dist/Dropdown/DropdownButton.cjs.map +1 -1
  41. package/dist/Dropdown/DropdownButton.js +11 -24
  42. package/dist/Dropdown/DropdownButton.js.map +1 -1
  43. package/dist/Dropdown/DropdownContent.cjs +21 -12
  44. package/dist/Dropdown/DropdownContent.cjs.map +1 -1
  45. package/dist/Dropdown/DropdownContent.js +21 -12
  46. package/dist/Dropdown/DropdownContent.js.map +1 -1
  47. package/dist/Dropdown/DropdownFilter.cjs +43 -46
  48. package/dist/Dropdown/DropdownFilter.cjs.map +1 -1
  49. package/dist/Dropdown/DropdownFilter.js +41 -45
  50. package/dist/Dropdown/DropdownFilter.js.map +1 -1
  51. package/dist/LinearProgress/LinearProgress.cjs +142 -0
  52. package/dist/LinearProgress/LinearProgress.cjs.map +1 -0
  53. package/dist/LinearProgress/LinearProgress.d.ts +25 -0
  54. package/dist/LinearProgress/LinearProgress.js +111 -0
  55. package/dist/LinearProgress/LinearProgress.js.map +1 -0
  56. package/dist/LinearProgress/index.cjs +32 -0
  57. package/dist/LinearProgress/index.cjs.map +1 -0
  58. package/dist/LinearProgress/index.d.ts +3 -0
  59. package/dist/LinearProgress/index.js +4 -0
  60. package/dist/LinearProgress/index.js.map +1 -0
  61. package/dist/Modals/ModalContainer.cjs +8 -3
  62. package/dist/Modals/ModalContainer.cjs.map +1 -1
  63. package/dist/Modals/ModalContainer.d.ts +1 -0
  64. package/dist/Modals/ModalContainer.js +8 -3
  65. package/dist/Modals/ModalContainer.js.map +1 -1
  66. package/dist/Modals/ModalDialog.cjs +5 -2
  67. package/dist/Modals/ModalDialog.cjs.map +1 -1
  68. package/dist/Modals/ModalDialog.d.ts +1 -0
  69. package/dist/Modals/ModalDialog.js +5 -2
  70. package/dist/Modals/ModalDialog.js.map +1 -1
  71. package/dist/SegmentControl/SegmentControl.cjs +99 -0
  72. package/dist/SegmentControl/SegmentControl.cjs.map +1 -0
  73. package/dist/SegmentControl/SegmentControl.d.ts +19 -0
  74. package/dist/SegmentControl/SegmentControl.js +71 -0
  75. package/dist/SegmentControl/SegmentControl.js.map +1 -0
  76. package/dist/SegmentControl/index.cjs +16 -0
  77. package/dist/SegmentControl/index.cjs.map +1 -0
  78. package/dist/SegmentControl/index.d.ts +3 -0
  79. package/dist/SegmentControl/index.js +3 -0
  80. package/dist/SegmentControl/index.js.map +1 -0
  81. package/dist/Table/TableFooter.cjs +1 -1
  82. package/dist/Table/TableFooter.cjs.map +1 -1
  83. package/dist/Table/TableFooter.js +1 -1
  84. package/dist/Table/TableFooter.js.map +1 -1
  85. package/dist/Table/TableStyles.cjs +1 -1
  86. package/dist/Table/TableStyles.cjs.map +1 -1
  87. package/dist/Table/TableStyles.js +1 -1
  88. package/dist/Table/TableStyles.js.map +1 -1
  89. package/dist/Tag/Tag.cjs +95 -0
  90. package/dist/Tag/Tag.cjs.map +1 -0
  91. package/dist/Tag/Tag.d.ts +9 -0
  92. package/dist/Tag/Tag.js +73 -0
  93. package/dist/Tag/Tag.js.map +1 -0
  94. package/dist/Tag/index.cjs +16 -0
  95. package/dist/Tag/index.cjs.map +1 -0
  96. package/dist/Tag/index.d.ts +2 -0
  97. package/dist/Tag/index.js +2 -0
  98. package/dist/Tag/index.js.map +1 -0
  99. package/dist/common/InputStyling.cjs +1 -1
  100. package/dist/common/InputStyling.cjs.map +1 -1
  101. package/dist/common/InputStyling.js +1 -1
  102. package/dist/common/InputStyling.js.map +1 -1
  103. package/dist/index.cjs +99 -0
  104. package/dist/index.cjs.map +1 -1
  105. package/dist/index.d.ts +5 -0
  106. package/dist/index.js +5 -0
  107. package/dist/index.js.map +1 -1
  108. package/package.json +4 -3
@@ -53,27 +53,27 @@ var StyledIconButton = _styledComponents.default.button(_templateObject || (_tem
53
53
  return props.unsetIconSize ? 'unset' : '24px';
54
54
  });
55
55
 
56
- var StyledPrimaryIconButton = (0, _styledComponents.default)(StyledIconButton)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n div {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n &:hover:not(:disabled) {\n div {\n background-color: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled) {\n div {\n background: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:disabled {\n div {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n &:focus:not(:disabled) {\n div {\n background-color: ", " !important;\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2e7fa1;\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n"])), function (props) {
56
+ var StyledPrimaryIconButton = (0, _styledComponents.default)(StyledIconButton)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n div {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n &:focus:not(:disabled) {\n div {\n background-color: ", " !important;\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2e7fa1;\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:hover:not(:disabled) {\n div {\n background-color: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled) {\n div {\n background: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:disabled {\n div {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n"])), function (props) {
57
57
  return props.useTransparentBackground ? 'transparent' : _styles.COLORS.primary_500;
58
58
  }, function (props) {
59
59
  return props.iconColor || _styles.COLORS.white;
60
60
  }, function (props) {
61
61
  return props.iconColor || _styles.COLORS.white;
62
- }, _styles.COLORS.primary_700, _styles.COLORS.white, _styles.COLORS.primary_800, _styles.COLORS.white, _styles.COLORS.neutral_200, _styles.COLORS.white, _styles.COLORS.white, function (props) {
62
+ }, function (props) {
63
63
  return props.focusBackgroundColor || _styles.COLORS.primary_700;
64
- }, _styles.COLORS.white);
64
+ }, _styles.COLORS.white, _styles.COLORS.primary_700, _styles.COLORS.white, _styles.COLORS.primary_800, _styles.COLORS.white, _styles.COLORS.neutral_200, _styles.COLORS.white, _styles.COLORS.white);
65
65
  exports.StyledPrimaryIconButton = StyledPrimaryIconButton;
66
- var StyledSecondaryIconButton = (0, _styledComponents.default)(StyledIconButton)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n div {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n &:hover:not(:disabled) {\n div {\n background-color: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled) {\n div {\n background: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n\n &:disabled {\n div {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n &:focus:not(:disabled) {\n div {\n background-color: ", ";\n box-shadow: 0px 0px 8px ", ", 0px 4px 12px rgba(46, 127, 161, 0.25);\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n"])), function (props) {
66
+ var StyledSecondaryIconButton = (0, _styledComponents.default)(StyledIconButton)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n div {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n\n &:focus:not(:disabled) {\n div {\n background-color: ", ";\n box-shadow: 0px 0px 8px ", ", 0px 4px 12px rgba(46, 127, 161, 0.25);\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n \n &:hover:not(:disabled) {\n div {\n background-color: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled) {\n div {\n background: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n\n &:disabled {\n div {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n"])), function (props) {
67
67
  return props.useTransparentBackground ? 'transparent' : _styles.COLORS.white;
68
68
  }, function (props) {
69
69
  return props.iconColor || _styles.COLORS.neutral_600;
70
70
  }, function (props) {
71
71
  return props.iconColor || _styles.COLORS.neutral_600;
72
- }, _styles.COLORS.primary_20, _styles.COLORS.primary_700, _styles.COLORS.primary_100, _styles.COLORS.primary_800, function (props) {
73
- return props.useTransparentBackground ? 'transparent' : _styles.COLORS.white;
74
- }, _styles.COLORS.neutral_300, _styles.COLORS.neutral_300, function (props) {
72
+ }, function (props) {
75
73
  return props.focusBackgroundColor || 'transparent';
76
- }, _styles.COLORS.primary_500, _styles.COLORS.neutral_600);
74
+ }, _styles.COLORS.primary_500, _styles.COLORS.neutral_600, _styles.COLORS.primary_20, _styles.COLORS.primary_700, _styles.COLORS.primary_100, _styles.COLORS.primary_800, function (props) {
75
+ return props.useTransparentBackground ? 'transparent' : _styles.COLORS.white;
76
+ }, _styles.COLORS.neutral_300, _styles.COLORS.neutral_300);
77
77
  exports.StyledSecondaryIconButton = StyledSecondaryIconButton;
78
78
 
79
79
  var IconButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
@@ -96,9 +96,8 @@ var IconButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
96
96
  type = _ref.type,
97
97
  hidden = _ref.hidden;
98
98
 
99
- var isPressingEnter = function isPressingEnter(e) {
100
- if (e.key === 'Enter') {
101
- e.preventDefault();
99
+ var isPressingEnterOrSpace = function isPressingEnterOrSpace(e) {
100
+ if (e.key === 'Enter' || e.key === ' ') {
102
101
  e.stopPropagation();
103
102
  return true;
104
103
  }
@@ -119,7 +118,7 @@ var IconButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
119
118
  action(event);
120
119
  },
121
120
  onKeyDown: function onKeyDown(e) {
122
- return isPressingEnter(e) ? action() : null;
121
+ return isPressingEnterOrSpace(e) ? action() : null;
123
122
  },
124
123
  disabled: disabled,
125
124
  hideOnLowWidth: hideOnLowWidth || false,
@@ -151,7 +150,7 @@ var IconButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
151
150
  action(event);
152
151
  },
153
152
  onKeyDown: function onKeyDown(e) {
154
- return isPressingEnter(e) ? action() : null;
153
+ return isPressingEnterOrSpace(e) ? action() : null;
155
154
  },
156
155
  disabled: disabled,
157
156
  hideOnLowWidth: hideOnLowWidth || false,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Button/Iconbutton.tsx"],"names":["getBorderRadius","props","borderRadius","getBorderRadiusStyle","radius","flatEdge","StyledIconButton","styled","button","hideOnLowWidth","BREAKPOINTS","MEDIUM","unsetIconSize","StyledPrimaryIconButton","useTransparentBackground","COLORS","primary_500","iconColor","white","primary_700","primary_800","neutral_200","focusBackgroundColor","StyledSecondaryIconButton","neutral_600","primary_20","primary_100","neutral_300","IconButton","React","forwardRef","ref","id","variant","shape","action","isInMobileMenu","children","disabled","tabIndex","onKeyPress","type","hidden","isPressingEnter","e","key","preventDefault","stopPropagation","event","defaultOnMouseDownHandler"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;AAcA,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAACC,KAAD;AAAA,SAA4BA,KAAK,CAACC,YAAN,aAAwBD,KAAK,CAACC,YAA9B,UAAiD,KAA7E;AAAA,CAAxB;;AAEA,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAuB,CAACF,KAAD,EAA2B;AACtD,MAAMG,MAAM,GAAGJ,eAAe,CAACC,KAAD,CAA9B;;AACA,UAAOA,KAAK,CAACI,QAAb;AAEI,SAAK,MAAL;AACI,2BAAcD,MAAd,cAAwBA,MAAxB;;AAEJ,SAAK,OAAL;AACI,uBA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AApBF,QADF;AA3BJ;AAoDD,CAnFkB,CAAnB;;;AApBEL,EAAAA,E;AACAC,EAAAA,O,4BAAU,S,EAAY,W;AACtBC,EAAAA,K,4BAAQ,Q,EAAW,U;AACnBC,EAAAA,M;AACA1B,EAAAA,c;AAEA2B,EAAAA,c;AACAE,EAAAA,Q;AACAxB,EAAAA,wB;AACAG,EAAAA,S;AACAL,EAAAA,a;AACA2B,EAAAA,Q;AACArC,EAAAA,Y;AACAsC,EAAAA,U;AACAlB,EAAAA,oB;AAEAe,EAAAA,Q;AACAK,EAAAA,M;;eAwFad,U","sourcesContent":["import React from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { BREAKPOINTS, COLORS } from '../styles';\nimport {defaultOnMouseDownHandler} from '../common';\n\ninterface HeaderItemProps {\n hideOnLowWidth: boolean;\n inMobileMenu?: boolean;\n useTransparentBackground?: boolean;\n iconColor?: string;\n unsetIconSize?: boolean;\n borderRadius?: number;\n shape?: string;\n flatEdge?: string;\n focusBackgroundColor?: string;\n}\n\nconst getBorderRadius = (props:HeaderItemProps) => (props.borderRadius ? `${props.borderRadius}px` : '4px');\n\nconst getBorderRadiusStyle = (props:HeaderItemProps) => {\n const radius = getBorderRadius(props);\n switch(props.flatEdge)\n {\n case 'left':\n return `0px ${radius} ${radius} 0px`;\n \n case 'right':\n return `${radius} 0px 0px ${radius}`;\n\n case 'none':\n default:\n return `${radius}`;\n }\n};\n\nconst StyledIconButton = styled.button<HeaderItemProps>`\n border-width: 0;\n cursor: pointer;\n height: 48px;\n width: 48px;\n background: transparent;\n\n display: ${(props) => (props.hideOnLowWidth ? 'none' : 'block')};\n ${BREAKPOINTS.MEDIUM} {\n display: block;\n }\n\n border-radius: ${(props) => (props.borderRadius ? `${props.borderRadius}px` : '4px')};\n div {\n height: 36px;\n width: 36px;\n border-radius: ${getBorderRadiusStyle};\n display: flex;\n justify-content: center;\n align-items: center;\n svg {\n height: ${(props) => (props.unsetIconSize ? 'unset' : '24px')};\n width: ${(props) => (props.unsetIconSize ? 'unset' : '24px')};\n padding: 0;\n }\n }\n &:only-child {\n margin: 0;\n }\n &:disabled {\n cursor: not-allowed;\n }\n &:focus:not(:disabled) {\n outline: none;\n div {\n outline: none;\n }\n }\n &:active:not(:disabled) {\n div {\n box-shadow: none !important;\n }\n }\n`;\n\nexport const StyledPrimaryIconButton = styled(StyledIconButton)`\n div {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.primary_500)};\n\n svg {\n fill: ${(props) => props.iconColor || COLORS.white};\n path {\n fill: ${(props) => props.iconColor || COLORS.white};\n }\n }\n }\n &:hover:not(:disabled) {\n div {\n background-color: ${COLORS.primary_700};\n }\n div svg path,\n div svg {\n fill: ${COLORS.white};\n }\n }\n &:active:not(:disabled) {\n div {\n background: ${COLORS.primary_800};\n }\n div svg path,\n div svg {\n fill: ${COLORS.white};\n }\n }\n &:disabled {\n div {\n background-color: ${COLORS.neutral_200};\n }\n svg {\n path {\n fill: ${COLORS.white};\n }\n fill: ${COLORS.white};\n }\n }\n &:focus:not(:disabled) {\n div {\n background-color: ${(props) => props.focusBackgroundColor || COLORS.primary_700} !important;\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2e7fa1;\n }\n div svg path,\n div svg {\n fill: ${COLORS.white};\n }\n }\n`;\n\nexport const StyledSecondaryIconButton = styled(StyledIconButton)`\n div {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.white)};\n\n svg {\n fill: ${(props) => props.iconColor || COLORS.neutral_600};\n path {\n fill: ${(props) => props.iconColor || COLORS.neutral_600};\n }\n }\n }\n &:hover:not(:disabled) {\n div {\n background-color: ${COLORS.primary_20};\n }\n div svg path,\n div svg {\n fill: ${COLORS.primary_700};\n }\n }\n &:active:not(:disabled) {\n div {\n background: ${COLORS.primary_100};\n }\n div svg path,\n div svg {\n fill: ${COLORS.primary_800};\n }\n }\n\n &:disabled {\n div {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.white)};\n }\n svg {\n path {\n fill: ${COLORS.neutral_300};\n }\n fill: ${COLORS.neutral_300};\n }\n }\n\n &:focus:not(:disabled) {\n div {\n background-color: ${(props) => props.focusBackgroundColor || 'transparent'};\n box-shadow: 0px 0px 8px ${COLORS.primary_500}, 0px 4px 12px rgba(46, 127, 161, 0.25);\n }\n div svg path,\n div svg {\n fill: ${COLORS.neutral_600};\n }\n }\n`;\n\nexport interface IconButtonProps {\n id?: string;\n variant?: 'primary' | 'secondary';\n shape?: 'square' | 'circular';\n action: (event?: React.MouseEvent<HTMLButtonElement>) => void;\n hideOnLowWidth?: boolean;\n flatEdge?: 'right' | 'left' | 'none' | undefined;\n isInMobileMenu?: boolean;\n disabled?: boolean;\n useTransparentBackground?: boolean;\n iconColor?: string;\n unsetIconSize?: boolean;\n tabIndex?: number;\n borderRadius?: number;\n onKeyPress?: React.KeyboardEventHandler<HTMLButtonElement>;\n focusBackgroundColor?: string;\n type?: 'submit' | 'reset' | 'button' | undefined;\n children?: React.ReactNode;\n hidden?: boolean;\n}\n\nconst IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(({\n id,\n variant,\n shape,\n action,\n hideOnLowWidth,\n isInMobileMenu,\n children,\n useTransparentBackground,\n disabled,\n iconColor,\n unsetIconSize,\n tabIndex,\n flatEdge,\n borderRadius,\n onKeyPress,\n focusBackgroundColor,\n type,\n hidden\n}: IconButtonProps, ref) => {\n\n const isPressingEnter = (e: any) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n e.stopPropagation();\n return true;\n }\n return false;\n };\n\n // Let's render button\n switch (variant) {\n case 'secondary':\n return (\n <StyledSecondaryIconButton\n id={id}\n type={type ?? 'button'}\n data-testid={id}\n ref={ref}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {event.stopPropagation(); action(event);}}\n onKeyDown={(e: any) => (isPressingEnter(e) ? action() : null)}\n disabled={disabled}\n hideOnLowWidth={hideOnLowWidth || false}\n inMobileMenu={isInMobileMenu}\n useTransparentBackground={useTransparentBackground}\n iconColor={iconColor}\n unsetIconSize={unsetIconSize}\n tabIndex={tabIndex || 0}\n borderRadius={borderRadius || shape === 'circular' ? 18 : 0}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={onKeyPress}\n hidden={hidden}\n focusBackgroundColor={focusBackgroundColor}>\n <div>{children}</div>\n </StyledSecondaryIconButton>\n );\n case 'primary':\n default:\n return (\n <StyledPrimaryIconButton\n id={id}\n type={type ?? 'button'}\n data-testid={id}\n flatEdge={flatEdge}\n ref={ref}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {event.stopPropagation(); action(event);}}\n onKeyDown={(e: any) => (isPressingEnter(e) ? action() : null)}\n disabled={disabled}\n hideOnLowWidth={hideOnLowWidth || false}\n inMobileMenu={isInMobileMenu}\n useTransparentBackground={useTransparentBackground}\n iconColor={iconColor}\n unsetIconSize={unsetIconSize}\n tabIndex={tabIndex || 0}\n borderRadius={borderRadius || shape === 'circular' ? 18 : 0}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={onKeyPress}\n hidden={hidden}\n focusBackgroundColor={focusBackgroundColor}>\n <div>{children}</div>\n </StyledPrimaryIconButton>\n );\n }\n});\n\nexport default IconButton;\n"],"file":"Iconbutton.cjs"}
1
+ {"version":3,"sources":["../../src/Button/Iconbutton.tsx"],"names":["getBorderRadius","props","borderRadius","getBorderRadiusStyle","radius","flatEdge","StyledIconButton","styled","button","hideOnLowWidth","BREAKPOINTS","MEDIUM","unsetIconSize","StyledPrimaryIconButton","useTransparentBackground","COLORS","primary_500","iconColor","white","focusBackgroundColor","primary_700","primary_800","neutral_200","StyledSecondaryIconButton","neutral_600","primary_20","primary_100","neutral_300","IconButton","React","forwardRef","ref","id","variant","shape","action","isInMobileMenu","children","disabled","tabIndex","onKeyPress","type","hidden","isPressingEnterOrSpace","e","key","stopPropagation","event","defaultOnMouseDownHandler"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;AAcA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B;AAYE,QAAA,SAAS,EAAEG,SAZb;AAaE,QAAA,aAAa,EAAEL,aAbjB;AAcE,QAAA,QAAQ,EAAE2B,QAAQ,IAAI,CAdxB;AAeE,QAAA,YAAY,EAAErC,YAAY,IAAIgC,KAAK,KAAK,UAA1B,GAAuC,EAAvC,GAA4C,CAf5D;AAgBE,QAAA,WAAW,EAAEc,iCAhBf;AAiBE,QAAA,UAAU,EAAER,UAjBd;AAkBE,QAAA,MAAM,EAAEE,MAlBV;AAmBE,QAAA,oBAAoB,EAAEvB,oBAnBxB;AAAA,+BAoBE;AAAA,oBAAMkB;AAAN;AApBF,QADF;AA3BJ;AAoDD,CAlFkB,CAAnB;;;AApBEL,EAAAA,E;AACAC,EAAAA,O,4BAAU,S,EAAY,W;AACtBC,EAAAA,K,4BAAQ,Q,EAAW,U;AACnBC,EAAAA,M;AACA1B,EAAAA,c;AAEA2B,EAAAA,c;AACAE,EAAAA,Q;AACAxB,EAAAA,wB;AACAG,EAAAA,S;AACAL,EAAAA,a;AACA2B,EAAAA,Q;AACArC,EAAAA,Y;AACAsC,EAAAA,U;AACArB,EAAAA,oB;AAEAkB,EAAAA,Q;AACAK,EAAAA,M;;eAuFad,U","sourcesContent":["import React from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { BREAKPOINTS, COLORS } from '../styles';\nimport {defaultOnMouseDownHandler} from '../common';\n\ninterface HeaderItemProps {\n hideOnLowWidth: boolean;\n inMobileMenu?: boolean;\n useTransparentBackground?: boolean;\n iconColor?: string;\n unsetIconSize?: boolean;\n borderRadius?: number;\n shape?: string;\n flatEdge?: string;\n focusBackgroundColor?: string;\n}\n\nconst getBorderRadius = (props:HeaderItemProps) => (props.borderRadius ? `${props.borderRadius}px` : '4px');\n\nconst getBorderRadiusStyle = (props:HeaderItemProps) => {\n const radius = getBorderRadius(props);\n switch(props.flatEdge)\n {\n case 'left':\n return `0px ${radius} ${radius} 0px`;\n\n case 'right':\n return `${radius} 0px 0px ${radius}`;\n\n case 'none':\n default:\n return `${radius}`;\n }\n};\n\nconst StyledIconButton = styled.button<HeaderItemProps>`\n border-width: 0;\n cursor: pointer;\n height: 48px;\n width: 48px;\n background: transparent;\n\n display: ${(props) => (props.hideOnLowWidth ? 'none' : 'block')};\n ${BREAKPOINTS.MEDIUM} {\n display: block;\n }\n\n border-radius: ${(props) => (props.borderRadius ? `${props.borderRadius}px` : '4px')};\n div {\n height: 36px;\n width: 36px;\n border-radius: ${getBorderRadiusStyle};\n display: flex;\n justify-content: center;\n align-items: center;\n svg {\n height: ${(props) => (props.unsetIconSize ? 'unset' : '24px')};\n width: ${(props) => (props.unsetIconSize ? 'unset' : '24px')};\n padding: 0;\n }\n }\n &:only-child {\n margin: 0;\n }\n &:disabled {\n cursor: not-allowed;\n }\n &:focus:not(:disabled) {\n outline: none;\n div {\n outline: none;\n }\n }\n &:active:not(:disabled) {\n div {\n box-shadow: none !important;\n }\n }\n`;\n\nexport const StyledPrimaryIconButton = styled(StyledIconButton)`\n div {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.primary_500)};\n\n svg {\n fill: ${(props) => props.iconColor || COLORS.white};\n path {\n fill: ${(props) => props.iconColor || COLORS.white};\n }\n }\n }\n &:focus:not(:disabled) {\n div {\n background-color: ${(props) => props.focusBackgroundColor || COLORS.primary_700} !important;\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2e7fa1;\n }\n div svg path,\n div svg {\n fill: ${COLORS.white};\n }\n }\n &:hover:not(:disabled) {\n div {\n background-color: ${COLORS.primary_700};\n }\n div svg path,\n div svg {\n fill: ${COLORS.white};\n }\n }\n &:active:not(:disabled) {\n div {\n background: ${COLORS.primary_800};\n }\n div svg path,\n div svg {\n fill: ${COLORS.white};\n }\n }\n &:disabled {\n div {\n background-color: ${COLORS.neutral_200};\n }\n svg {\n path {\n fill: ${COLORS.white};\n }\n fill: ${COLORS.white};\n }\n }\n\n`;\n\nexport const StyledSecondaryIconButton = styled(StyledIconButton)`\n div {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.white)};\n\n svg {\n fill: ${(props) => props.iconColor || COLORS.neutral_600};\n path {\n fill: ${(props) => props.iconColor || COLORS.neutral_600};\n }\n }\n }\n\n &:focus:not(:disabled) {\n div {\n background-color: ${(props) => props.focusBackgroundColor || 'transparent'};\n box-shadow: 0px 0px 8px ${COLORS.primary_500}, 0px 4px 12px rgba(46, 127, 161, 0.25);\n }\n div svg path,\n div svg {\n fill: ${COLORS.neutral_600};\n }\n }\n \n &:hover:not(:disabled) {\n div {\n background-color: ${COLORS.primary_20};\n }\n div svg path,\n div svg {\n fill: ${COLORS.primary_700};\n }\n }\n &:active:not(:disabled) {\n div {\n background: ${COLORS.primary_100};\n }\n div svg path,\n div svg {\n fill: ${COLORS.primary_800};\n }\n }\n\n &:disabled {\n div {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.white)};\n }\n svg {\n path {\n fill: ${COLORS.neutral_300};\n }\n fill: ${COLORS.neutral_300};\n }\n }\n\n`;\n\nexport interface IconButtonProps {\n id?: string;\n variant?: 'primary' | 'secondary';\n shape?: 'square' | 'circular';\n action: (event?: React.MouseEvent<HTMLButtonElement>) => void;\n hideOnLowWidth?: boolean;\n flatEdge?: 'right' | 'left' | 'none' | undefined;\n isInMobileMenu?: boolean;\n disabled?: boolean;\n useTransparentBackground?: boolean;\n iconColor?: string;\n unsetIconSize?: boolean;\n tabIndex?: number;\n borderRadius?: number;\n onKeyPress?: React.KeyboardEventHandler<HTMLButtonElement>;\n focusBackgroundColor?: string;\n type?: 'submit' | 'reset' | 'button' | undefined;\n children?: React.ReactNode;\n hidden?: boolean;\n}\n\nconst IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(({\n id,\n variant,\n shape,\n action,\n hideOnLowWidth,\n isInMobileMenu,\n children,\n useTransparentBackground,\n disabled,\n iconColor,\n unsetIconSize,\n tabIndex,\n flatEdge,\n borderRadius,\n onKeyPress,\n focusBackgroundColor,\n type,\n hidden\n}: IconButtonProps, ref) => {\n\n const isPressingEnterOrSpace = (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.stopPropagation();\n return true;\n }\n return false;\n };\n\n // Let's render button\n switch (variant) {\n case 'secondary':\n return (\n <StyledSecondaryIconButton\n id={id}\n type={type ?? 'button'}\n data-testid={id}\n ref={ref}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {event.stopPropagation(); action(event);}}\n onKeyDown={(e: any) => isPressingEnterOrSpace(e) ? action() : null}\n disabled={disabled}\n hideOnLowWidth={hideOnLowWidth || false}\n inMobileMenu={isInMobileMenu}\n useTransparentBackground={useTransparentBackground}\n iconColor={iconColor}\n unsetIconSize={unsetIconSize}\n tabIndex={tabIndex || 0}\n borderRadius={borderRadius || shape === 'circular' ? 18 : 0}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={onKeyPress}\n hidden={hidden}\n focusBackgroundColor={focusBackgroundColor}>\n <div>{children}</div>\n </StyledSecondaryIconButton>\n );\n case 'primary':\n default:\n return (\n <StyledPrimaryIconButton\n id={id}\n type={type ?? 'button'}\n data-testid={id}\n flatEdge={flatEdge}\n ref={ref}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {event.stopPropagation(); action(event);}}\n onKeyDown={(e: any) => isPressingEnterOrSpace(e) ? action() : null}\n disabled={disabled}\n hideOnLowWidth={hideOnLowWidth || false}\n inMobileMenu={isInMobileMenu}\n useTransparentBackground={useTransparentBackground}\n iconColor={iconColor}\n unsetIconSize={unsetIconSize}\n tabIndex={tabIndex || 0}\n borderRadius={borderRadius || shape === 'circular' ? 18 : 0}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={onKeyPress}\n hidden={hidden}\n focusBackgroundColor={focusBackgroundColor}>\n <div>{children}</div>\n </StyledPrimaryIconButton>\n );\n }\n});\n\nexport default IconButton;\n"],"file":"Iconbutton.cjs"}
@@ -38,26 +38,26 @@ var StyledIconButton = styled.button(_templateObject || (_templateObject = _tagg
38
38
  }, function (props) {
39
39
  return props.unsetIconSize ? 'unset' : '24px';
40
40
  });
41
- export var StyledPrimaryIconButton = styled(StyledIconButton)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n div {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n &:hover:not(:disabled) {\n div {\n background-color: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled) {\n div {\n background: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:disabled {\n div {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n &:focus:not(:disabled) {\n div {\n background-color: ", " !important;\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2e7fa1;\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n"])), function (props) {
41
+ export var StyledPrimaryIconButton = styled(StyledIconButton)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n div {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n &:focus:not(:disabled) {\n div {\n background-color: ", " !important;\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2e7fa1;\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:hover:not(:disabled) {\n div {\n background-color: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled) {\n div {\n background: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:disabled {\n div {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n"])), function (props) {
42
42
  return props.useTransparentBackground ? 'transparent' : COLORS.primary_500;
43
43
  }, function (props) {
44
44
  return props.iconColor || COLORS.white;
45
45
  }, function (props) {
46
46
  return props.iconColor || COLORS.white;
47
- }, COLORS.primary_700, COLORS.white, COLORS.primary_800, COLORS.white, COLORS.neutral_200, COLORS.white, COLORS.white, function (props) {
47
+ }, function (props) {
48
48
  return props.focusBackgroundColor || COLORS.primary_700;
49
- }, COLORS.white);
50
- export var StyledSecondaryIconButton = styled(StyledIconButton)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n div {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n &:hover:not(:disabled) {\n div {\n background-color: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled) {\n div {\n background: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n\n &:disabled {\n div {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n &:focus:not(:disabled) {\n div {\n background-color: ", ";\n box-shadow: 0px 0px 8px ", ", 0px 4px 12px rgba(46, 127, 161, 0.25);\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n"])), function (props) {
49
+ }, COLORS.white, COLORS.primary_700, COLORS.white, COLORS.primary_800, COLORS.white, COLORS.neutral_200, COLORS.white, COLORS.white);
50
+ export var StyledSecondaryIconButton = styled(StyledIconButton)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n div {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n\n &:focus:not(:disabled) {\n div {\n background-color: ", ";\n box-shadow: 0px 0px 8px ", ", 0px 4px 12px rgba(46, 127, 161, 0.25);\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n \n &:hover:not(:disabled) {\n div {\n background-color: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled) {\n div {\n background: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n\n &:disabled {\n div {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n"])), function (props) {
51
51
  return props.useTransparentBackground ? 'transparent' : COLORS.white;
52
52
  }, function (props) {
53
53
  return props.iconColor || COLORS.neutral_600;
54
54
  }, function (props) {
55
55
  return props.iconColor || COLORS.neutral_600;
56
- }, COLORS.primary_20, COLORS.primary_700, COLORS.primary_100, COLORS.primary_800, function (props) {
57
- return props.useTransparentBackground ? 'transparent' : COLORS.white;
58
- }, COLORS.neutral_300, COLORS.neutral_300, function (props) {
56
+ }, function (props) {
59
57
  return props.focusBackgroundColor || 'transparent';
60
- }, COLORS.primary_500, COLORS.neutral_600);
58
+ }, COLORS.primary_500, COLORS.neutral_600, COLORS.primary_20, COLORS.primary_700, COLORS.primary_100, COLORS.primary_800, function (props) {
59
+ return props.useTransparentBackground ? 'transparent' : COLORS.white;
60
+ }, COLORS.neutral_300, COLORS.neutral_300);
61
61
  var IconButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
62
62
  var id = _ref.id,
63
63
  variant = _ref.variant,
@@ -78,9 +78,8 @@ var IconButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
78
78
  type = _ref.type,
79
79
  hidden = _ref.hidden;
80
80
 
81
- var isPressingEnter = function isPressingEnter(e) {
82
- if (e.key === 'Enter') {
83
- e.preventDefault();
81
+ var isPressingEnterOrSpace = function isPressingEnterOrSpace(e) {
82
+ if (e.key === 'Enter' || e.key === ' ') {
84
83
  e.stopPropagation();
85
84
  return true;
86
85
  }
@@ -101,7 +100,7 @@ var IconButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
101
100
  action(event);
102
101
  },
103
102
  onKeyDown: function onKeyDown(e) {
104
- return isPressingEnter(e) ? action() : null;
103
+ return isPressingEnterOrSpace(e) ? action() : null;
105
104
  },
106
105
  disabled: disabled,
107
106
  hideOnLowWidth: hideOnLowWidth || false,
@@ -133,7 +132,7 @@ var IconButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
133
132
  action(event);
134
133
  },
135
134
  onKeyDown: function onKeyDown(e) {
136
- return isPressingEnter(e) ? action() : null;
135
+ return isPressingEnterOrSpace(e) ? action() : null;
137
136
  },
138
137
  disabled: disabled,
139
138
  hideOnLowWidth: hideOnLowWidth || false,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Button/Iconbutton.tsx"],"names":["React","styled","BREAKPOINTS","COLORS","defaultOnMouseDownHandler","getBorderRadius","props","borderRadius","getBorderRadiusStyle","radius","flatEdge","StyledIconButton","button","hideOnLowWidth","MEDIUM","unsetIconSize","StyledPrimaryIconButton","useTransparentBackground","primary_500","iconColor","white","primary_700","primary_800","neutral_200","focusBackgroundColor","StyledSecondaryIconButton","neutral_600","primary_20","primary_100","neutral_300","IconButton","forwardRef","ref","id","variant","shape","action","isInMobileMenu","children","disabled","tabIndex","onKeyPress","type","hidden","isPressingEnter","e","key","preventDefault","stopPropagation","event"],"mappings":";;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,MAAP,MAA4B,mBAA5B;AAEA,SAASC,WAAT,EAAsBC,MAAtB,QAAoC,WAApC;AACA,SAAQC,yBAAR,QAAwC,WAAxC;;;AAcA,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACC,KAAD;AAAA,SAA4BA,KAAK,CAACC,YAAN,aAAwBD,KAAK,CAACC,YAA9B,UAAiD,KAA7E;AAAA,CAAxB;;AAEA,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAuB,CAACF,KAAD,EAA2B;AACtD,MAAMG,MAAM,GAAGJ,eAAe,CAACC,KAAD,CAA9B;;AACA,UAAOA,KAAK,CAACI,QAAb;AAEI,SAAK,MAAL;AACI,2BAAcD,MAAd,cAAwBA,MAAxB;;AAEJ,SAAK,OAAL;AACI,uBAAUA,MAAV,sBAA4BA,MAA5B;;AAEJ,SAAK,MAAL;AACA;AACI,uBAAUA,MAAV;AAVR;AAYD,CAdD;;AAgBA,IAAME,gBAAgB,GAAGV,MAAM,CAACW,MAAV,ivBAOT,UAACN,KAAD;AAAA,SAAYA,KAAK,CAACO,cAAN,GAAuB,MAAvB,GAAgC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3BJ;AAoDD,CAnFkB,CAAnB;;AApBEL,EAAAA,E;AACAC,EAAAA,O,aAAU,S,EAAY,W;AACtBC,EAAAA,K,aAAQ,Q,EAAW,U;AACnBC,EAAAA,M;AACAvB,EAAAA,c;AAEAwB,EAAAA,c;AACAE,EAAAA,Q;AACAtB,EAAAA,wB;AACAE,EAAAA,S;AACAJ,EAAAA,a;AACAyB,EAAAA,Q;AACAjC,EAAAA,Y;AACAkC,EAAAA,U;AACAjB,EAAAA,oB;AAEAc,EAAAA,Q;AACAK,EAAAA,M;;AAwFF,eAAeb,UAAf","sourcesContent":["import React from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { BREAKPOINTS, COLORS } from '../styles';\nimport {defaultOnMouseDownHandler} from '../common';\n\ninterface HeaderItemProps {\n hideOnLowWidth: boolean;\n inMobileMenu?: boolean;\n useTransparentBackground?: boolean;\n iconColor?: string;\n unsetIconSize?: boolean;\n borderRadius?: number;\n shape?: string;\n flatEdge?: string;\n focusBackgroundColor?: string;\n}\n\nconst getBorderRadius = (props:HeaderItemProps) => (props.borderRadius ? `${props.borderRadius}px` : '4px');\n\nconst getBorderRadiusStyle = (props:HeaderItemProps) => {\n const radius = getBorderRadius(props);\n switch(props.flatEdge)\n {\n case 'left':\n return `0px ${radius} ${radius} 0px`;\n \n case 'right':\n return `${radius} 0px 0px ${radius}`;\n\n case 'none':\n default:\n return `${radius}`;\n }\n};\n\nconst StyledIconButton = styled.button<HeaderItemProps>`\n border-width: 0;\n cursor: pointer;\n height: 48px;\n width: 48px;\n background: transparent;\n\n display: ${(props) => (props.hideOnLowWidth ? 'none' : 'block')};\n ${BREAKPOINTS.MEDIUM} {\n display: block;\n }\n\n border-radius: ${(props) => (props.borderRadius ? `${props.borderRadius}px` : '4px')};\n div {\n height: 36px;\n width: 36px;\n border-radius: ${getBorderRadiusStyle};\n display: flex;\n justify-content: center;\n align-items: center;\n svg {\n height: ${(props) => (props.unsetIconSize ? 'unset' : '24px')};\n width: ${(props) => (props.unsetIconSize ? 'unset' : '24px')};\n padding: 0;\n }\n }\n &:only-child {\n margin: 0;\n }\n &:disabled {\n cursor: not-allowed;\n }\n &:focus:not(:disabled) {\n outline: none;\n div {\n outline: none;\n }\n }\n &:active:not(:disabled) {\n div {\n box-shadow: none !important;\n }\n }\n`;\n\nexport const StyledPrimaryIconButton = styled(StyledIconButton)`\n div {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.primary_500)};\n\n svg {\n fill: ${(props) => props.iconColor || COLORS.white};\n path {\n fill: ${(props) => props.iconColor || COLORS.white};\n }\n }\n }\n &:hover:not(:disabled) {\n div {\n background-color: ${COLORS.primary_700};\n }\n div svg path,\n div svg {\n fill: ${COLORS.white};\n }\n }\n &:active:not(:disabled) {\n div {\n background: ${COLORS.primary_800};\n }\n div svg path,\n div svg {\n fill: ${COLORS.white};\n }\n }\n &:disabled {\n div {\n background-color: ${COLORS.neutral_200};\n }\n svg {\n path {\n fill: ${COLORS.white};\n }\n fill: ${COLORS.white};\n }\n }\n &:focus:not(:disabled) {\n div {\n background-color: ${(props) => props.focusBackgroundColor || COLORS.primary_700} !important;\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2e7fa1;\n }\n div svg path,\n div svg {\n fill: ${COLORS.white};\n }\n }\n`;\n\nexport const StyledSecondaryIconButton = styled(StyledIconButton)`\n div {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.white)};\n\n svg {\n fill: ${(props) => props.iconColor || COLORS.neutral_600};\n path {\n fill: ${(props) => props.iconColor || COLORS.neutral_600};\n }\n }\n }\n &:hover:not(:disabled) {\n div {\n background-color: ${COLORS.primary_20};\n }\n div svg path,\n div svg {\n fill: ${COLORS.primary_700};\n }\n }\n &:active:not(:disabled) {\n div {\n background: ${COLORS.primary_100};\n }\n div svg path,\n div svg {\n fill: ${COLORS.primary_800};\n }\n }\n\n &:disabled {\n div {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.white)};\n }\n svg {\n path {\n fill: ${COLORS.neutral_300};\n }\n fill: ${COLORS.neutral_300};\n }\n }\n\n &:focus:not(:disabled) {\n div {\n background-color: ${(props) => props.focusBackgroundColor || 'transparent'};\n box-shadow: 0px 0px 8px ${COLORS.primary_500}, 0px 4px 12px rgba(46, 127, 161, 0.25);\n }\n div svg path,\n div svg {\n fill: ${COLORS.neutral_600};\n }\n }\n`;\n\nexport interface IconButtonProps {\n id?: string;\n variant?: 'primary' | 'secondary';\n shape?: 'square' | 'circular';\n action: (event?: React.MouseEvent<HTMLButtonElement>) => void;\n hideOnLowWidth?: boolean;\n flatEdge?: 'right' | 'left' | 'none' | undefined;\n isInMobileMenu?: boolean;\n disabled?: boolean;\n useTransparentBackground?: boolean;\n iconColor?: string;\n unsetIconSize?: boolean;\n tabIndex?: number;\n borderRadius?: number;\n onKeyPress?: React.KeyboardEventHandler<HTMLButtonElement>;\n focusBackgroundColor?: string;\n type?: 'submit' | 'reset' | 'button' | undefined;\n children?: React.ReactNode;\n hidden?: boolean;\n}\n\nconst IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(({\n id,\n variant,\n shape,\n action,\n hideOnLowWidth,\n isInMobileMenu,\n children,\n useTransparentBackground,\n disabled,\n iconColor,\n unsetIconSize,\n tabIndex,\n flatEdge,\n borderRadius,\n onKeyPress,\n focusBackgroundColor,\n type,\n hidden\n}: IconButtonProps, ref) => {\n\n const isPressingEnter = (e: any) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n e.stopPropagation();\n return true;\n }\n return false;\n };\n\n // Let's render button\n switch (variant) {\n case 'secondary':\n return (\n <StyledSecondaryIconButton\n id={id}\n type={type ?? 'button'}\n data-testid={id}\n ref={ref}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {event.stopPropagation(); action(event);}}\n onKeyDown={(e: any) => (isPressingEnter(e) ? action() : null)}\n disabled={disabled}\n hideOnLowWidth={hideOnLowWidth || false}\n inMobileMenu={isInMobileMenu}\n useTransparentBackground={useTransparentBackground}\n iconColor={iconColor}\n unsetIconSize={unsetIconSize}\n tabIndex={tabIndex || 0}\n borderRadius={borderRadius || shape === 'circular' ? 18 : 0}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={onKeyPress}\n hidden={hidden}\n focusBackgroundColor={focusBackgroundColor}>\n <div>{children}</div>\n </StyledSecondaryIconButton>\n );\n case 'primary':\n default:\n return (\n <StyledPrimaryIconButton\n id={id}\n type={type ?? 'button'}\n data-testid={id}\n flatEdge={flatEdge}\n ref={ref}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {event.stopPropagation(); action(event);}}\n onKeyDown={(e: any) => (isPressingEnter(e) ? action() : null)}\n disabled={disabled}\n hideOnLowWidth={hideOnLowWidth || false}\n inMobileMenu={isInMobileMenu}\n useTransparentBackground={useTransparentBackground}\n iconColor={iconColor}\n unsetIconSize={unsetIconSize}\n tabIndex={tabIndex || 0}\n borderRadius={borderRadius || shape === 'circular' ? 18 : 0}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={onKeyPress}\n hidden={hidden}\n focusBackgroundColor={focusBackgroundColor}>\n <div>{children}</div>\n </StyledPrimaryIconButton>\n );\n }\n});\n\nexport default IconButton;\n"],"file":"Iconbutton.js"}
1
+ {"version":3,"sources":["../../src/Button/Iconbutton.tsx"],"names":["React","styled","BREAKPOINTS","COLORS","defaultOnMouseDownHandler","getBorderRadius","props","borderRadius","getBorderRadiusStyle","radius","flatEdge","StyledIconButton","button","hideOnLowWidth","MEDIUM","unsetIconSize","StyledPrimaryIconButton","useTransparentBackground","primary_500","iconColor","white","focusBackgroundColor","primary_700","primary_800","neutral_200","StyledSecondaryIconButton","neutral_600","primary_20","primary_100","neutral_300","IconButton","forwardRef","ref","id","variant","shape","action","isInMobileMenu","children","disabled","tabIndex","onKeyPress","type","hidden","isPressingEnterOrSpace","e","key","stopPropagation","event"],"mappings":";;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,MAAP,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AAD,CAAN;AAAe,SANrG;AAOE,QAAA,SAAS,EAAE,mBAACH,CAAD;AAAA,iBAAYD,sBAAsB,CAACC,CAAD,CAAtB,GAA4BT,MAAM,EAAlC,GAAuC,IAAnD;AAAA,SAPb;AAQE,QAAA,QAAQ,EAAEG,QARZ;AASE,QAAA,cAAc,EAAE1B,cAAc,IAAI,KATpC;AAUE,QAAA,YAAY,EAAEwB,cAVhB;AAWE,QAAA,wBAAwB,EAAEpB,wBAX5B;AAYE,QAAA,SAAS,EAAEE,SAZb;AAaE,QAAA,aAAa,EAAEJ,aAbjB;AAcE,QAAA,QAAQ,EAAEyB,QAAQ,IAAI,CAdxB;AAeE,QAAA,YAAY,EAAEjC,YAAY,IAAI4B,KAAK,KAAK,UAA1B,GAAuC,EAAvC,GAA4C,CAf5D;AAgBE,QAAA,WAAW,EAAE/B,yBAhBf;AAiBE,QAAA,UAAU,EAAEqC,UAjBd;AAkBE,QAAA,MAAM,EAAEE,MAlBV;AAmBE,QAAA,oBAAoB,EAAEtB,oBAnBxB;AAAA,+BAoBE;AAAA,oBAAMiB;AAAN;AApBF,QADF;AA3BJ;AAoDD,CAlFkB,CAAnB;;AApBEL,EAAAA,E;AACAC,EAAAA,O,aAAU,S,EAAY,W;AACtBC,EAAAA,K,aAAQ,Q,EAAW,U;AACnBC,EAAAA,M;AACAvB,EAAAA,c;AAEAwB,EAAAA,c;AACAE,EAAAA,Q;AACAtB,EAAAA,wB;AACAE,EAAAA,S;AACAJ,EAAAA,a;AACAyB,EAAAA,Q;AACAjC,EAAAA,Y;AACAkC,EAAAA,U;AACApB,EAAAA,oB;AAEAiB,EAAAA,Q;AACAK,EAAAA,M;;AAuFF,eAAeb,UAAf","sourcesContent":["import React from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { BREAKPOINTS, COLORS } from '../styles';\nimport {defaultOnMouseDownHandler} from '../common';\n\ninterface HeaderItemProps {\n hideOnLowWidth: boolean;\n inMobileMenu?: boolean;\n useTransparentBackground?: boolean;\n iconColor?: string;\n unsetIconSize?: boolean;\n borderRadius?: number;\n shape?: string;\n flatEdge?: string;\n focusBackgroundColor?: string;\n}\n\nconst getBorderRadius = (props:HeaderItemProps) => (props.borderRadius ? `${props.borderRadius}px` : '4px');\n\nconst getBorderRadiusStyle = (props:HeaderItemProps) => {\n const radius = getBorderRadius(props);\n switch(props.flatEdge)\n {\n case 'left':\n return `0px ${radius} ${radius} 0px`;\n\n case 'right':\n return `${radius} 0px 0px ${radius}`;\n\n case 'none':\n default:\n return `${radius}`;\n }\n};\n\nconst StyledIconButton = styled.button<HeaderItemProps>`\n border-width: 0;\n cursor: pointer;\n height: 48px;\n width: 48px;\n background: transparent;\n\n display: ${(props) => (props.hideOnLowWidth ? 'none' : 'block')};\n ${BREAKPOINTS.MEDIUM} {\n display: block;\n }\n\n border-radius: ${(props) => (props.borderRadius ? `${props.borderRadius}px` : '4px')};\n div {\n height: 36px;\n width: 36px;\n border-radius: ${getBorderRadiusStyle};\n display: flex;\n justify-content: center;\n align-items: center;\n svg {\n height: ${(props) => (props.unsetIconSize ? 'unset' : '24px')};\n width: ${(props) => (props.unsetIconSize ? 'unset' : '24px')};\n padding: 0;\n }\n }\n &:only-child {\n margin: 0;\n }\n &:disabled {\n cursor: not-allowed;\n }\n &:focus:not(:disabled) {\n outline: none;\n div {\n outline: none;\n }\n }\n &:active:not(:disabled) {\n div {\n box-shadow: none !important;\n }\n }\n`;\n\nexport const StyledPrimaryIconButton = styled(StyledIconButton)`\n div {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.primary_500)};\n\n svg {\n fill: ${(props) => props.iconColor || COLORS.white};\n path {\n fill: ${(props) => props.iconColor || COLORS.white};\n }\n }\n }\n &:focus:not(:disabled) {\n div {\n background-color: ${(props) => props.focusBackgroundColor || COLORS.primary_700} !important;\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2e7fa1;\n }\n div svg path,\n div svg {\n fill: ${COLORS.white};\n }\n }\n &:hover:not(:disabled) {\n div {\n background-color: ${COLORS.primary_700};\n }\n div svg path,\n div svg {\n fill: ${COLORS.white};\n }\n }\n &:active:not(:disabled) {\n div {\n background: ${COLORS.primary_800};\n }\n div svg path,\n div svg {\n fill: ${COLORS.white};\n }\n }\n &:disabled {\n div {\n background-color: ${COLORS.neutral_200};\n }\n svg {\n path {\n fill: ${COLORS.white};\n }\n fill: ${COLORS.white};\n }\n }\n\n`;\n\nexport const StyledSecondaryIconButton = styled(StyledIconButton)`\n div {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.white)};\n\n svg {\n fill: ${(props) => props.iconColor || COLORS.neutral_600};\n path {\n fill: ${(props) => props.iconColor || COLORS.neutral_600};\n }\n }\n }\n\n &:focus:not(:disabled) {\n div {\n background-color: ${(props) => props.focusBackgroundColor || 'transparent'};\n box-shadow: 0px 0px 8px ${COLORS.primary_500}, 0px 4px 12px rgba(46, 127, 161, 0.25);\n }\n div svg path,\n div svg {\n fill: ${COLORS.neutral_600};\n }\n }\n \n &:hover:not(:disabled) {\n div {\n background-color: ${COLORS.primary_20};\n }\n div svg path,\n div svg {\n fill: ${COLORS.primary_700};\n }\n }\n &:active:not(:disabled) {\n div {\n background: ${COLORS.primary_100};\n }\n div svg path,\n div svg {\n fill: ${COLORS.primary_800};\n }\n }\n\n &:disabled {\n div {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.white)};\n }\n svg {\n path {\n fill: ${COLORS.neutral_300};\n }\n fill: ${COLORS.neutral_300};\n }\n }\n\n`;\n\nexport interface IconButtonProps {\n id?: string;\n variant?: 'primary' | 'secondary';\n shape?: 'square' | 'circular';\n action: (event?: React.MouseEvent<HTMLButtonElement>) => void;\n hideOnLowWidth?: boolean;\n flatEdge?: 'right' | 'left' | 'none' | undefined;\n isInMobileMenu?: boolean;\n disabled?: boolean;\n useTransparentBackground?: boolean;\n iconColor?: string;\n unsetIconSize?: boolean;\n tabIndex?: number;\n borderRadius?: number;\n onKeyPress?: React.KeyboardEventHandler<HTMLButtonElement>;\n focusBackgroundColor?: string;\n type?: 'submit' | 'reset' | 'button' | undefined;\n children?: React.ReactNode;\n hidden?: boolean;\n}\n\nconst IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(({\n id,\n variant,\n shape,\n action,\n hideOnLowWidth,\n isInMobileMenu,\n children,\n useTransparentBackground,\n disabled,\n iconColor,\n unsetIconSize,\n tabIndex,\n flatEdge,\n borderRadius,\n onKeyPress,\n focusBackgroundColor,\n type,\n hidden\n}: IconButtonProps, ref) => {\n\n const isPressingEnterOrSpace = (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.stopPropagation();\n return true;\n }\n return false;\n };\n\n // Let's render button\n switch (variant) {\n case 'secondary':\n return (\n <StyledSecondaryIconButton\n id={id}\n type={type ?? 'button'}\n data-testid={id}\n ref={ref}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {event.stopPropagation(); action(event);}}\n onKeyDown={(e: any) => isPressingEnterOrSpace(e) ? action() : null}\n disabled={disabled}\n hideOnLowWidth={hideOnLowWidth || false}\n inMobileMenu={isInMobileMenu}\n useTransparentBackground={useTransparentBackground}\n iconColor={iconColor}\n unsetIconSize={unsetIconSize}\n tabIndex={tabIndex || 0}\n borderRadius={borderRadius || shape === 'circular' ? 18 : 0}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={onKeyPress}\n hidden={hidden}\n focusBackgroundColor={focusBackgroundColor}>\n <div>{children}</div>\n </StyledSecondaryIconButton>\n );\n case 'primary':\n default:\n return (\n <StyledPrimaryIconButton\n id={id}\n type={type ?? 'button'}\n data-testid={id}\n flatEdge={flatEdge}\n ref={ref}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {event.stopPropagation(); action(event);}}\n onKeyDown={(e: any) => isPressingEnterOrSpace(e) ? action() : null}\n disabled={disabled}\n hideOnLowWidth={hideOnLowWidth || false}\n inMobileMenu={isInMobileMenu}\n useTransparentBackground={useTransparentBackground}\n iconColor={iconColor}\n unsetIconSize={unsetIconSize}\n tabIndex={tabIndex || 0}\n borderRadius={borderRadius || shape === 'circular' ? 18 : 0}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={onKeyPress}\n hidden={hidden}\n focusBackgroundColor={focusBackgroundColor}>\n <div>{children}</div>\n </StyledPrimaryIconButton>\n );\n }\n});\n\nexport default IconButton;\n"],"file":"Iconbutton.js"}
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.default = exports.InteractionType = exports.CardTopLevelContainer = void 0;
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
15
+
16
+ var _propTypes = _interopRequireDefault(require("prop-types"));
17
+
18
+ var React = _interopRequireWildcard(require("react"));
19
+
20
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
21
+
22
+ var _CardTopSection = _interopRequireDefault(require("./CardTopSection"));
23
+
24
+ var _CardMiddleSection = _interopRequireDefault(require("./CardMiddleSection"));
25
+
26
+ var _CardBottomSection = _interopRequireDefault(require("./CardBottomSection"));
27
+
28
+ var _ = require("..");
29
+
30
+ var _jsxRuntime = require("react/jsx-runtime");
31
+
32
+ var _templateObject;
33
+
34
+ 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); }
35
+
36
+ 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; }
37
+
38
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
39
+
40
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
41
+
42
+ var CardTopLevelContainer = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n background-color: ", ";\n\n box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.15);\n border-radius: 8px;\n\n border: 1px solid transparent;\n background-clip: padding-box;\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n\n ", "\n"])), _.COLORS.white, function (props) {
43
+ return props.interactionType == InteractionType.Clickable && !props.disabled ? "\n\n &:active, &.active-state {\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.15);\n border: 1px solid ".concat(_.COLORS.neutral_200, ";\n }\n\n &:hover:focus, &:hover {\n outline: none;\n overflow: visible;\n border-width: 0px;\n border: 1px solid ").concat(_.COLORS.neutral_200, ";\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.15);\n }\n \n &:focus, &.focus-state {\n border-width: 0px;\n border: 1px solid ").concat(_.COLORS.neutral_200, ";\n outline: none;\n overflow: hidden;\n box-shadow: 0px 4px 12px 2px rgba(46, 127, 161, 0.25), 0px 0px 8px 2px #2E7FA1;\n }") : "";
44
+ });
45
+
46
+ exports.CardTopLevelContainer = CardTopLevelContainer;
47
+ var InteractionType;
48
+ exports.InteractionType = InteractionType;
49
+
50
+ (function (InteractionType) {
51
+ InteractionType[InteractionType["None"] = 0] = "None";
52
+ InteractionType[InteractionType["Clickable"] = 1] = "Clickable";
53
+ InteractionType[InteractionType["Selectable"] = 2] = "Selectable";
54
+ })(InteractionType || (exports.InteractionType = InteractionType = {}));
55
+
56
+ var Card = function Card(_ref) {
57
+ var _ref$interactionType = _ref.interactionType,
58
+ interactionType = _ref$interactionType === void 0 ? InteractionType.None : _ref$interactionType,
59
+ onCardClicked = _ref.onCardClicked,
60
+ topSectionProps = _ref.topSectionProps,
61
+ middleSectionProps = _ref.middleSectionProps,
62
+ bottomSectionProps = _ref.bottomSectionProps,
63
+ disabled = _ref.disabled;
64
+ var rootRef = React.useRef(null);
65
+
66
+ var onCardClick = function onCardClick() {
67
+ if (interactionType == InteractionType.Clickable) {
68
+ var _rootRef$current;
69
+
70
+ if (onCardClicked) onCardClicked();
71
+ (_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.blur();
72
+ }
73
+ };
74
+
75
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(CardTopLevelContainer, {
76
+ disabled: disabled,
77
+ ref: rootRef,
78
+ tabIndex: interactionType == InteractionType.Clickable && !disabled ? 0 : -1,
79
+ interactionType: interactionType,
80
+ onClick: onCardClick,
81
+ children: [topSectionProps && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardTopSection.default, _objectSpread(_objectSpread({}, topSectionProps), {}, {
82
+ disabled: disabled,
83
+ interactionType: interactionType
84
+ })), middleSectionProps && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardMiddleSection.default, _objectSpread(_objectSpread({}, middleSectionProps), {}, {
85
+ disabled: disabled,
86
+ interactionType: interactionType
87
+ })), bottomSectionProps && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardBottomSection.default, _objectSpread(_objectSpread({}, bottomSectionProps), {}, {
88
+ disabled: disabled,
89
+ interactionType: interactionType
90
+ }))]
91
+ });
92
+ };
93
+
94
+ Card.propTypes = {
95
+ interactionType: _propTypes.default.oneOf([0, 1, 2]).isRequired,
96
+ onCardClicked: _propTypes.default.func.isRequired,
97
+ disabled: _propTypes.default.bool.isRequired
98
+ };
99
+ var _default = Card;
100
+ exports.default = _default;
101
+ //# sourceMappingURL=Card.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Card/Card.tsx"],"names":["CardTopLevelContainer","styled","div","COLORS","white","props","interactionType","InteractionType","Clickable","disabled","neutral_200","Card","None","onCardClicked","topSectionProps","middleSectionProps","bottomSectionProps","rootRef","React","useRef","onCardClick","current","blur"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEO,IAAMA,qBAAqB,GAAGC,0BAAOC,GAAV,iVACZC,SAAOC,KADK,EAY9B,UAAAC,KAAK;AAAA,SACLA,KAAK,CAACC,eAAN,IAAyBC,eAAe,CAACC,SAAzC,IAAsD,CAACH,KAAK,CAACI,QAA7D,kIAKsBN,SAAOO,WAL7B,yJAYsBP,SAAOO,WAZ7B,sKAkBsBP,SAAOO,WAlB7B,wJADK;AAAA,CAZyB,CAA3B;;;IAuCKH,e;;;WAAAA,e;AAAAA,EAAAA,e,CAAAA,e;AAAAA,EAAAA,e,CAAAA,e;AAAAA,EAAAA,e,CAAAA,e;GAAAA,e,+BAAAA,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D,CAxBD;;;AAREA,EAAAA,e;AACAO,EAAAA,a;AACAJ,EAAAA,Q;;eAgCaE,I","sourcesContent":["import * as React from 'react';\nimport styled from 'styled-components';\nimport CardTopSection, { CardTopSectionProps } from './CardTopSection';\nimport CardMiddleSection, { CardMiddleSectionProps } from './CardMiddleSection';\nimport CardBottomSection, { CardBottomSectionProps } from './CardBottomSection';\nimport { COLORS, CommonInteractionStyling } from '..';\n\nexport const CardTopLevelContainer = styled.div<{ interactionType: InteractionType; disabled: boolean; }>`\n background-color: ${COLORS.white};\n\n box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.15);\n border-radius: 8px;\n\n border: 1px solid transparent;\n background-clip: padding-box;\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n\n ${props =>\n props.interactionType == InteractionType.Clickable && !props.disabled\n ? `\n\n &:active, &.active-state {\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.15);\n border: 1px solid ${COLORS.neutral_200};\n }\n\n &:hover:focus, &:hover {\n outline: none;\n overflow: visible;\n border-width: 0px;\n border: 1px solid ${COLORS.neutral_200};\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.15);\n }\n \n &:focus, &.focus-state {\n border-width: 0px;\n border: 1px solid ${COLORS.neutral_200};\n outline: none;\n overflow: hidden;\n box-shadow: 0px 4px 12px 2px rgba(46, 127, 161, 0.25), 0px 0px 8px 2px #2E7FA1;\n }`\n : ``}\n`;\n\nexport enum InteractionType {\n None,\n Clickable,\n Selectable,\n}\n\nexport interface CardProps {\n interactionType: InteractionType;\n onCardClicked: () => {};\n disabled: boolean;\n topSectionProps?: CardTopSectionProps;\n middleSectionProps?: CardMiddleSectionProps;\n bottomSectionProps?: CardBottomSectionProps;\n}\n\nconst Card: React.FunctionComponent<CardProps> = ({\n interactionType = InteractionType.None,\n onCardClicked,\n topSectionProps,\n middleSectionProps,\n bottomSectionProps,\n disabled\n}: CardProps) => {\n const rootRef = React.useRef<HTMLDivElement>(null);\n\n const onCardClick = () => {\n if (interactionType == InteractionType.Clickable) {\n if(onCardClicked) onCardClicked();\n rootRef.current?.blur();\n }\n };\n\n return (\n <CardTopLevelContainer disabled={disabled} ref={rootRef} tabIndex={interactionType == InteractionType.Clickable && !disabled ? 0 : -1} interactionType={interactionType} onClick={onCardClick}>\n {topSectionProps && <CardTopSection {...topSectionProps} disabled={disabled} interactionType={interactionType} />}\n {middleSectionProps && <CardMiddleSection {...middleSectionProps} disabled={disabled} interactionType={interactionType} />}\n {bottomSectionProps && <CardBottomSection {...bottomSectionProps} disabled={disabled} interactionType={interactionType} />}\n </CardTopLevelContainer>\n );\n};\n\nexport default Card;\n"],"file":"Card.cjs"}
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ import { CardTopSectionProps } from './CardTopSection';
3
+ import { CardMiddleSectionProps } from './CardMiddleSection';
4
+ import { CardBottomSectionProps } from './CardBottomSection';
5
+ export declare const CardTopLevelContainer: import("styled-components").StyledComponent<"div", any, {
6
+ interactionType: InteractionType;
7
+ disabled: boolean;
8
+ }, never>;
9
+ export declare enum InteractionType {
10
+ None = 0,
11
+ Clickable = 1,
12
+ Selectable = 2
13
+ }
14
+ export interface CardProps {
15
+ interactionType: InteractionType;
16
+ onCardClicked: () => {};
17
+ disabled: boolean;
18
+ topSectionProps?: CardTopSectionProps;
19
+ middleSectionProps?: CardMiddleSectionProps;
20
+ bottomSectionProps?: CardBottomSectionProps;
21
+ }
22
+ declare const Card: React.FunctionComponent<CardProps>;
23
+ export default Card;
@@ -0,0 +1,74 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
3
+ import _pt from "prop-types";
4
+
5
+ var _templateObject;
6
+
7
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
8
+
9
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
10
+
11
+ import * as React from 'react';
12
+ import styled from 'styled-components';
13
+ import CardTopSection from './CardTopSection';
14
+ import CardMiddleSection from './CardMiddleSection';
15
+ import CardBottomSection from './CardBottomSection';
16
+ import { COLORS } from '..';
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ import { jsxs as _jsxs } from "react/jsx-runtime";
19
+ export var CardTopLevelContainer = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n\n box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.15);\n border-radius: 8px;\n\n border: 1px solid transparent;\n background-clip: padding-box;\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n\n ", "\n"])), COLORS.white, function (props) {
20
+ return props.interactionType == InteractionType.Clickable && !props.disabled ? "\n\n &:active, &.active-state {\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.15);\n border: 1px solid ".concat(COLORS.neutral_200, ";\n }\n\n &:hover:focus, &:hover {\n outline: none;\n overflow: visible;\n border-width: 0px;\n border: 1px solid ").concat(COLORS.neutral_200, ";\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.15);\n }\n \n &:focus, &.focus-state {\n border-width: 0px;\n border: 1px solid ").concat(COLORS.neutral_200, ";\n outline: none;\n overflow: hidden;\n box-shadow: 0px 4px 12px 2px rgba(46, 127, 161, 0.25), 0px 0px 8px 2px #2E7FA1;\n }") : "";
21
+ });
22
+ export var InteractionType;
23
+
24
+ (function (InteractionType) {
25
+ InteractionType[InteractionType["None"] = 0] = "None";
26
+ InteractionType[InteractionType["Clickable"] = 1] = "Clickable";
27
+ InteractionType[InteractionType["Selectable"] = 2] = "Selectable";
28
+ })(InteractionType || (InteractionType = {}));
29
+
30
+ var Card = function Card(_ref) {
31
+ var _ref$interactionType = _ref.interactionType,
32
+ interactionType = _ref$interactionType === void 0 ? InteractionType.None : _ref$interactionType,
33
+ onCardClicked = _ref.onCardClicked,
34
+ topSectionProps = _ref.topSectionProps,
35
+ middleSectionProps = _ref.middleSectionProps,
36
+ bottomSectionProps = _ref.bottomSectionProps,
37
+ disabled = _ref.disabled;
38
+ var rootRef = React.useRef(null);
39
+
40
+ var onCardClick = function onCardClick() {
41
+ if (interactionType == InteractionType.Clickable) {
42
+ var _rootRef$current;
43
+
44
+ if (onCardClicked) onCardClicked();
45
+ (_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.blur();
46
+ }
47
+ };
48
+
49
+ return /*#__PURE__*/_jsxs(CardTopLevelContainer, {
50
+ disabled: disabled,
51
+ ref: rootRef,
52
+ tabIndex: interactionType == InteractionType.Clickable && !disabled ? 0 : -1,
53
+ interactionType: interactionType,
54
+ onClick: onCardClick,
55
+ children: [topSectionProps && /*#__PURE__*/_jsx(CardTopSection, _objectSpread(_objectSpread({}, topSectionProps), {}, {
56
+ disabled: disabled,
57
+ interactionType: interactionType
58
+ })), middleSectionProps && /*#__PURE__*/_jsx(CardMiddleSection, _objectSpread(_objectSpread({}, middleSectionProps), {}, {
59
+ disabled: disabled,
60
+ interactionType: interactionType
61
+ })), bottomSectionProps && /*#__PURE__*/_jsx(CardBottomSection, _objectSpread(_objectSpread({}, bottomSectionProps), {}, {
62
+ disabled: disabled,
63
+ interactionType: interactionType
64
+ }))]
65
+ });
66
+ };
67
+
68
+ Card.propTypes = {
69
+ interactionType: _pt.oneOf([0, 1, 2]).isRequired,
70
+ onCardClicked: _pt.func.isRequired,
71
+ disabled: _pt.bool.isRequired
72
+ };
73
+ export default Card;
74
+ //# sourceMappingURL=Card.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Card/Card.tsx"],"names":["React","styled","CardTopSection","CardMiddleSection","CardBottomSection","COLORS","CardTopLevelContainer","div","white","props","interactionType","InteractionType","Clickable","disabled","neutral_200","Card","None","onCardClicked","topSectionProps","middleSectionProps","bottomSectionProps","rootRef","useRef","onCardClick","current","blur"],"mappings":";;;;;;;;;;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,OAAOC,MAAP,MAAmB,mBAAnB;AACA,OAAOC,cAAP,MAAoD,kBAApD;AACA,OAAOC,iBAAP,MAA0D,qBAA1D;AACA,OAAOC,iBAAP,MAA0D,qBAA1D;AACA,SAASC,MAAT,QAAiD,IAAjD;;;AAEA,OAAO,IAAMC,qBAAqB,GAAGL,MAAM,CAACM,GAAV,mUACZF,MAAM,CAACG,KADK,EAY9B,UAAAC,KAAK;AAAA,SACLA,KAAK,CAACC,eAAN,IAAyBC,eAAe,CAACC,SAAzC,IAAsD,CAACH,KAAK,CAACI,QAA7D,kIAKsBR,MAAM,CAACS,WAL7B,yJAYsBT,MAAM,CAACS,WAZ7B,sKAkBsBT,MAAM,CAACS,WAlB7B,wJADK;AAAA,CAZyB,CAA3B;AAuCP,WAAYH,eAAZ;;WAAYA,e;AAAAA,EAAAA,e,CAAAA,e;AAAAA,EAAAA,e,CAAAA,e;AAAAA,EAAAA,e,CAAAA,e;GAAAA,e,KAAAA,e;;AAeZ,IAAMI,IAAwC,GAAG,SAA3CA,IAA2C,OAOhC;AAAA,kCANfL,eAMe;AAAA,MANfA,eAMe,qCANGC,eAAe,CAACK,IAMnB;AAAA,MALfC,aAKe,QALfA,aAKe;AAAA,MAJfC,eAIe,QAJfA,eAIe;AAAA,MAHfC,kBAGe,QAHfA,kBAGe;AAAA,MAFfC,kBAEe,QAFfA,kBAEe;AAAA,MADfP,QACe,QADfA,QACe;AACf,MAAMQ,OAAO,GAAGrB,KAAK,CAACsB,MAAN,CAA6B,IAA7B,CAAhB;;AAEA,MAAMC,WAAW,GAAG,SAAdA,WAAc,GAAM;AACxB,QAAIb,eAAe,IAAIC,eAAe,CAACC,SAAvC,EAAkD;AAAA;;AAChD,UAAGK,aAAH,EAAkBA,aAAa;AAC/B,0BAAAI,OAAO,CAACG,OAAR,sEAAiBC,IAAjB;AACD;AACF,GALD;;AAOA,sBACE,MAAC,qBAAD;AAAuB,IAAA,QAAQ,EAAEZ,QAAjC;AAA2C,IAAA,GAAG,EAAEQ,OAAhD;AAAyD,IAAA,QAAQ,EAAEX,eAAe,IAAIC,eAAe,CAACC,SAAnC,IAAgD,CAACC,QAAjD,GAA4D,CAA5D,GAAgE,CAAC,CAApI;AAAuI,IAAA,eAAe,EAAEH,eAAxJ;AAAyK,IAAA,OAAO,EAAEa,WAAlL;AAAA,eACGL,eAAe,iBAAI,KAAC,cAAD,kCAAoBA,eAApB;AAAqC,MAAA,QAAQ,EAAEL,QAA/C;AAAyD,MAAA,eAAe,EAAEH;AAA1E,OADtB,EAEGS,kBAAkB,iBAAI,KAAC,iBAAD,kCAAuBA,kBAAvB;AAA2C,MAAA,QAAQ,EAAEN,QAArD;AAA+D,MAAA,eAAe,EAAEH;AAAhF,OAFzB,EAGGU,kBAAkB,iBAAI,KAAC,iBAAD,kCAAuBA,kBAAvB;AAA2C,MAAA,QAAQ,EAAEP,QAArD;AAA+D,MAAA,eAAe,EAAEH;AAAhF,OAHzB;AAAA,IADF;AAOD,CAxBD;;;AAREA,EAAAA,e;AACAO,EAAAA,a;AACAJ,EAAAA,Q;;AAgCF,eAAeE,IAAf","sourcesContent":["import * as React from 'react';\nimport styled from 'styled-components';\nimport CardTopSection, { CardTopSectionProps } from './CardTopSection';\nimport CardMiddleSection, { CardMiddleSectionProps } from './CardMiddleSection';\nimport CardBottomSection, { CardBottomSectionProps } from './CardBottomSection';\nimport { COLORS, CommonInteractionStyling } from '..';\n\nexport const CardTopLevelContainer = styled.div<{ interactionType: InteractionType; disabled: boolean; }>`\n background-color: ${COLORS.white};\n\n box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.15);\n border-radius: 8px;\n\n border: 1px solid transparent;\n background-clip: padding-box;\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n\n ${props =>\n props.interactionType == InteractionType.Clickable && !props.disabled\n ? `\n\n &:active, &.active-state {\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.15);\n border: 1px solid ${COLORS.neutral_200};\n }\n\n &:hover:focus, &:hover {\n outline: none;\n overflow: visible;\n border-width: 0px;\n border: 1px solid ${COLORS.neutral_200};\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.15);\n }\n \n &:focus, &.focus-state {\n border-width: 0px;\n border: 1px solid ${COLORS.neutral_200};\n outline: none;\n overflow: hidden;\n box-shadow: 0px 4px 12px 2px rgba(46, 127, 161, 0.25), 0px 0px 8px 2px #2E7FA1;\n }`\n : ``}\n`;\n\nexport enum InteractionType {\n None,\n Clickable,\n Selectable,\n}\n\nexport interface CardProps {\n interactionType: InteractionType;\n onCardClicked: () => {};\n disabled: boolean;\n topSectionProps?: CardTopSectionProps;\n middleSectionProps?: CardMiddleSectionProps;\n bottomSectionProps?: CardBottomSectionProps;\n}\n\nconst Card: React.FunctionComponent<CardProps> = ({\n interactionType = InteractionType.None,\n onCardClicked,\n topSectionProps,\n middleSectionProps,\n bottomSectionProps,\n disabled\n}: CardProps) => {\n const rootRef = React.useRef<HTMLDivElement>(null);\n\n const onCardClick = () => {\n if (interactionType == InteractionType.Clickable) {\n if(onCardClicked) onCardClicked();\n rootRef.current?.blur();\n }\n };\n\n return (\n <CardTopLevelContainer disabled={disabled} ref={rootRef} tabIndex={interactionType == InteractionType.Clickable && !disabled ? 0 : -1} interactionType={interactionType} onClick={onCardClick}>\n {topSectionProps && <CardTopSection {...topSectionProps} disabled={disabled} interactionType={interactionType} />}\n {middleSectionProps && <CardMiddleSection {...middleSectionProps} disabled={disabled} interactionType={interactionType} />}\n {bottomSectionProps && <CardBottomSection {...bottomSectionProps} disabled={disabled} interactionType={interactionType} />}\n </CardTopLevelContainer>\n );\n};\n\nexport default Card;\n"],"file":"Card.js"}