@laerdal/life-react-components 6.0.0-dev.27.full → 6.0.0-dev.30

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 (50) hide show
  1. package/README.md +42 -0
  2. package/dist/Button/Button.cjs +469 -0
  3. package/dist/Button/Button.cjs.map +1 -0
  4. package/dist/Button/Button.d.ts +70 -0
  5. package/dist/Button/Button.js +461 -0
  6. package/dist/Button/Button.js.map +1 -0
  7. package/dist/Card/HorizontalCard/__tests__/VerticalCard.test.tsx +124 -0
  8. package/dist/Card/VerticalCard/Card.cjs +187 -0
  9. package/dist/Card/VerticalCard/Card.cjs.map +1 -0
  10. package/dist/Card/VerticalCard/Card.d.ts +25 -0
  11. package/dist/Card/VerticalCard/Card.js +178 -0
  12. package/dist/Card/VerticalCard/Card.js.map +1 -0
  13. package/dist/Card/VerticalCard/CardBottomSection.cjs +261 -0
  14. package/dist/Card/VerticalCard/CardBottomSection.cjs.map +1 -0
  15. package/dist/Card/VerticalCard/CardBottomSection.d.ts +53 -0
  16. package/dist/Card/VerticalCard/CardBottomSection.js +252 -0
  17. package/dist/Card/VerticalCard/CardBottomSection.js.map +1 -0
  18. package/dist/Card/VerticalCard/CardMiddleSection.cjs +145 -0
  19. package/dist/Card/VerticalCard/CardMiddleSection.cjs.map +1 -0
  20. package/dist/Card/VerticalCard/CardMiddleSection.d.ts +42 -0
  21. package/dist/Card/VerticalCard/CardMiddleSection.js +136 -0
  22. package/dist/Card/VerticalCard/CardMiddleSection.js.map +1 -0
  23. package/dist/Card/VerticalCard/CardTopSection.cjs +165 -0
  24. package/dist/Card/VerticalCard/CardTopSection.cjs.map +1 -0
  25. package/dist/Card/VerticalCard/CardTopSection.d.ts +45 -0
  26. package/dist/Card/VerticalCard/CardTopSection.js +156 -0
  27. package/dist/Card/VerticalCard/CardTopSection.js.map +1 -0
  28. package/dist/Card/__tests__/Card.test.tsx +146 -0
  29. package/dist/Footer/Components/FooterNewsletterAndSocialSection.cjs +0 -1
  30. package/dist/Footer/Components/FooterNewsletterAndSocialSection.cjs.map +1 -1
  31. package/dist/Footer/Components/FooterNewsletterAndSocialSection.js +0 -1
  32. package/dist/Footer/Components/FooterNewsletterAndSocialSection.js.map +1 -1
  33. package/dist/Footer/Components/FooterTop.cjs.map +1 -1
  34. package/dist/Footer/Components/FooterTop.js.map +1 -1
  35. package/dist/InputFields/RichTextField.cjs +3 -2
  36. package/dist/InputFields/RichTextField.cjs.map +1 -1
  37. package/dist/InputFields/RichTextField.d.ts +4 -5
  38. package/dist/InputFields/RichTextField.js +2 -1
  39. package/dist/InputFields/RichTextField.js.map +1 -1
  40. package/dist/InputFields/TextField.cjs +2 -5
  41. package/dist/InputFields/TextField.cjs.map +1 -1
  42. package/dist/InputFields/TextField.d.ts +0 -8
  43. package/dist/InputFields/TextField.js +2 -5
  44. package/dist/InputFields/TextField.js.map +1 -1
  45. package/dist/InputFields/styling.cjs +1 -4
  46. package/dist/InputFields/styling.cjs.map +1 -1
  47. package/dist/InputFields/styling.d.ts +0 -1
  48. package/dist/InputFields/styling.js +1 -4
  49. package/dist/InputFields/styling.js.map +1 -1
  50. package/package.json +148 -152
@@ -0,0 +1,124 @@
1
+ import React from 'react';
2
+ import { fireEvent, render } from '../../../test-utils';
3
+ import 'jest-styled-components';
4
+ import { Card } from '../..';
5
+ import { COLORS } from '../../../styles';
6
+ import { SystemIcons } from '../../../icons';
7
+
8
+
9
+ describe('<Card />',()=>{
10
+ it('renders top section', async () => {
11
+ const{getByTestId} = render(
12
+ <Card topSectionProps={{disabled: false}} disabled/>
13
+ );
14
+
15
+ expect(getByTestId('card-topSection')).toBeDefined();
16
+ });
17
+
18
+ it('renders middle section', async () => {
19
+ const{getByTestId} = render(
20
+ <Card middleSectionProps={{title:'title',disabled:false}} disabled/>
21
+ );
22
+
23
+ expect(getByTestId('card-middleSection')).toBeDefined();
24
+ });
25
+
26
+ it('renders bottom section', async () => {
27
+ const{getByTestId} = render(
28
+ <Card bottomSectionProps={{disabled:false}} disabled/>
29
+ );
30
+
31
+ expect(getByTestId('card-bottomSection')).toBeDefined();
32
+ });
33
+
34
+ it('fires card clicked event on click', async () => {
35
+ const cardClicked = jest.fn();
36
+ const{getByTestId} = render(
37
+ <Card bottomSectionProps={{disabled:false}} disabled={false} onCardClicked={cardClicked}/>
38
+ );
39
+
40
+ fireEvent.click(getByTestId('card-link'));
41
+ expect(cardClicked).toHaveBeenCalled();
42
+ });
43
+
44
+ it('fires card clicked event on keyDown', async () => {
45
+ const cardClicked = jest.fn();
46
+ const{getByTestId} = render(
47
+ <Card bottomSectionProps={{disabled:false}} disabled={false} onCardClicked={cardClicked}/>
48
+ );
49
+
50
+ fireEvent.keyDown(getByTestId('card-wrapper'), {key: 'Enter', code: 'Enter', charCode: 13});
51
+ expect(cardClicked).toHaveBeenCalled();
52
+ });
53
+
54
+ it('renders tag in top section', async () => {
55
+ const{getByText} = render(
56
+ <Card topSectionProps={{disabled: false, tagLabel:'test_label'}} disabled/>
57
+ );
58
+
59
+ expect(getByText('test_label')).toBeDefined();
60
+ });
61
+
62
+ it('renders checkbox in top section', async () => {
63
+ const{getByTestId} = render(
64
+ <Card topSectionProps={{disabled: false, selected: true}} disabled/>
65
+ );
66
+
67
+ expect(getByTestId('card-topSection-checkbox')).toBeDefined();
68
+ });
69
+
70
+ it('renders highlight ribbon in top section', async () => {
71
+ const{getByTestId, getByText} = render(
72
+ <Card topSectionProps={{disabled: false, highlightRibbonText:'testRibbon', highlightRibbonBgColor:'red'}} disabled={false}/>
73
+ );
74
+
75
+ expect(getByText('testRibbon')).toBeDefined();
76
+ expect(getByTestId('card-topSection-ribbon')).toHaveStyleRule('background-color','red');
77
+ });
78
+
79
+ it('renders title ,description and category label in middle section', async () => {
80
+ const{getByText} = render(
81
+ <Card middleSectionProps={{title:'testTitle', disabled: false, description:'testDescription', categoryLabel:'testCatLabel'}} disabled={false}/>
82
+ );
83
+
84
+ expect(getByText('testTitle')).toBeDefined();
85
+ expect(getByText('testDescription')).toBeDefined();
86
+ expect(getByText('testCatLabel')).toBeDefined();
87
+ });
88
+
89
+ it('renders tags in middle section', async () => {
90
+ const{getByText} = render(
91
+ <Card middleSectionProps={{title:'testTitle', disabled: false, tags:[{label:'testTag'}], row2Tags:[{label:'testTag2'}]}} disabled={false}/>
92
+ );
93
+
94
+ expect(getByText('testTitle')).toBeDefined();
95
+ expect(getByText('testTag2')).toBeDefined();
96
+ });
97
+
98
+ it('renders note text in bottom section', async () => {
99
+ const{getByText} = render(
100
+ <Card bottomSectionProps={{disabled: false, noteLeft:'leftNote', noteRight:'rightNote'}} disabled={false}/>
101
+ );
102
+
103
+ expect(getByText('leftNote')).toBeDefined();
104
+ expect(getByText('rightNote')).toBeDefined();
105
+ });
106
+
107
+ it('renders author in bottom section', async () => {
108
+ const{getByText,getByTestId} = render(
109
+ <Card bottomSectionProps={{disabled: true, authorName:'testAuthor'}} disabled={true}/>
110
+ );
111
+
112
+ expect(getByText('testAuthor')).toBeDefined();
113
+ expect(getByTestId('card-bottomSection-author')).toBeDefined();
114
+ });
115
+
116
+ it('renders actions in bottom section', async () => {
117
+ const{getByText,getByTestId} = render(
118
+ <Card bottomSectionProps={{disabled: true, authorName:'testAuthor', actions:[{icon:<SystemIcons.Add/>,onClick:()=>{}}]}} disabled={true}/>
119
+ );
120
+
121
+ expect(getByText('testAuthor')).toBeDefined();
122
+ expect(getByTestId('card-bottomSection-author')).toBeDefined();
123
+ });
124
+ })
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.CardTopLevelContainerStyles = exports.CardLink = exports.CardContainerStyles = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+ var React = _interopRequireWildcard(require("react"));
12
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
13
+ var _CardTopSection = _interopRequireDefault(require("./CardTopSection"));
14
+ var _CardMiddleSection = _interopRequireDefault(require("./CardMiddleSection"));
15
+ var _CardBottomSection = _interopRequireDefault(require("./CardBottomSection"));
16
+ var _index = require("../../index");
17
+ var _jsxRuntime = require("react/jsx-runtime");
18
+ const _excluded = ["onCardClicked", "topSectionProps", "middleSectionProps", "bottomSectionProps", "disabled", "variant", "className", "id", "maxWidth"];
19
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
23
+ const CardTopLevelContainerStyles = exports.CardTopLevelContainerStyles = _styledComponents.default.div`
24
+ background-color: ${props => _index.COLORS.generateToken({
25
+ componentType: 'bg-surface',
26
+ defaultVariant: 'default'
27
+ }, props.theme)};
28
+ min-width: 240px;
29
+ overflow: hidden;
30
+
31
+ border-radius: 8px;
32
+
33
+ background-clip: padding-box;
34
+ box-sizing: border-box;
35
+ display: flex;
36
+ flex-direction: column;
37
+ position: relative;
38
+
39
+ .elevated & {
40
+ box-shadow: ${_index.BOXSHADOWS.BOXSHADOW_L1};
41
+ }
42
+
43
+ .outline & {
44
+ border: 1px solid ${props => _index.COLORS.generateToken({
45
+ componentType: 'border',
46
+ defaultVariant: 'subtle'
47
+ }, props.theme)};
48
+ }
49
+ `;
50
+
51
+ // Full-card link that covers the entire card area
52
+ const CardLink = exports.CardLink = _styledComponents.default.a`
53
+ position: absolute;
54
+ top: 0;
55
+ left: 0;
56
+ right: 0;
57
+ bottom: 0;
58
+ z-index: 100;
59
+ text-decoration: none;
60
+ color: inherit;
61
+ pointer-events: auto;
62
+ cursor: pointer;
63
+
64
+ &:focus {
65
+ outline: none;
66
+ }
67
+
68
+ &:focus-visible {
69
+ ${_index.focusStyles}
70
+ }
71
+ `;
72
+ const CardContainerStyles = exports.CardContainerStyles = _styledComponents.default.div`
73
+ &.interactive:not(.disabled) {
74
+ &:focus {
75
+ ${_index.focusStyles}
76
+ }
77
+
78
+ &:not(.action-within) {
79
+ ${CardTopLevelContainerStyles} {
80
+ &:hover {
81
+ background-color: ${props => _index.COLORS.generateToken({
82
+ componentType: 'bg-surface',
83
+ state: 'hover'
84
+ }, props.theme)};
85
+ }
86
+
87
+ &:active, &.active-state {
88
+ background-color: ${props => _index.COLORS.generateToken({
89
+ componentType: 'bg-surface',
90
+ state: 'active'
91
+ }, props.theme)};
92
+ }
93
+ }
94
+ }
95
+
96
+ &.elevated:not(.action-within) {
97
+ ${CardTopLevelContainerStyles} {
98
+ &:hover {
99
+ box-shadow: ${_index.BOXSHADOWS.BOXSHADOW_L3};
100
+ }
101
+
102
+ &:active, &.active-state {
103
+ box-shadow: ${_index.BOXSHADOWS.BOXSHADOW_L2};
104
+ }
105
+ }
106
+ }
107
+ }
108
+
109
+ &.disabled {
110
+ cursor: not-allowed;
111
+ ${CardTopLevelContainerStyles}{
112
+ border: 1px solid ${props => _index.COLORS.generateToken({
113
+ componentType: 'border',
114
+ state: 'disabled'
115
+ }, props.theme)};
116
+ }
117
+ }
118
+ `;
119
+ const Card = _ref => {
120
+ let {
121
+ onCardClicked,
122
+ topSectionProps,
123
+ middleSectionProps,
124
+ bottomSectionProps,
125
+ disabled,
126
+ variant = 'elevated',
127
+ className,
128
+ id,
129
+ maxWidth = 560
130
+ } = _ref,
131
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
132
+ const [actionsRefs, setActionsRefs] = React.useState([]);
133
+ const checkBoxRef = React.useRef(null);
134
+ const containerRef = React.useRef(null);
135
+ const autoId = React.useId();
136
+ (0, _index.useActionWithin)(containerRef, [...actionsRefs, checkBoxRef]);
137
+ const cls = `${!!onCardClicked ? 'interactive' : ''} ${disabled ? 'disabled' : ''} ${variant} ${className || ''}`;
138
+ const handleCardClick = e => {
139
+ e.preventDefault();
140
+ if (!disabled && onCardClicked) {
141
+ onCardClicked();
142
+ }
143
+ };
144
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(CardContainerStyles, _objectSpread(_objectSpread({
145
+ ref: containerRef,
146
+ role: "group",
147
+ className: cls,
148
+ "aria-labelledby": `${autoId}-title`,
149
+ tabIndex: !!onCardClicked && !disabled ? 0 : -1,
150
+ onKeyDown: e => e.key === 'Enter' && !disabled && onCardClicked && onCardClicked(),
151
+ "data-testid": 'card-wrapper'
152
+ }, rest), {}, {
153
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(CardTopLevelContainerStyles, {
154
+ style: {
155
+ maxWidth: maxWidth
156
+ },
157
+ children: [onCardClicked && !disabled && /*#__PURE__*/(0, _jsxRuntime.jsx)(CardLink, {
158
+ href: '#',
159
+ "data-testid": 'card-link',
160
+ onClick: handleCardClick,
161
+ "aria-labelledby": `${autoId}-title`,
162
+ tabIndex: -1
163
+ }), topSectionProps && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardTopSection.default, _objectSpread(_objectSpread({
164
+ ref: checkBoxRef
165
+ }, topSectionProps), {}, {
166
+ disabled: disabled
167
+ })), middleSectionProps && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardMiddleSection.default, _objectSpread(_objectSpread({}, middleSectionProps), {}, {
168
+ componentId: autoId,
169
+ disabled: disabled
170
+ })), bottomSectionProps && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardBottomSection.default, _objectSpread(_objectSpread({
171
+ ref: instance => {
172
+ setActionsRefs(instance ?? []);
173
+ }
174
+ }, bottomSectionProps), {}, {
175
+ disabled: disabled
176
+ }))]
177
+ })
178
+ }));
179
+ };
180
+ Card.propTypes = {
181
+ onCardClicked: _propTypes.default.func,
182
+ disabled: _propTypes.default.bool,
183
+ maxWidth: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
184
+ variant: _propTypes.default.oneOf(['outline', 'elevated'])
185
+ };
186
+ var _default = exports.default = Card;
187
+ //# sourceMappingURL=Card.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card.cjs","names":["React","_interopRequireWildcard","require","_styledComponents","_interopRequireDefault","_CardTopSection","_CardMiddleSection","_CardBottomSection","_index","_jsxRuntime","_excluded","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ownKeys","keys","getOwnPropertySymbols","o","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","CardTopLevelContainerStyles","exports","styled","div","props","COLORS","generateToken","componentType","defaultVariant","theme","BOXSHADOWS","BOXSHADOW_L1","CardLink","focusStyles","CardContainerStyles","state","BOXSHADOW_L3","BOXSHADOW_L2","Card","_ref","onCardClicked","topSectionProps","middleSectionProps","bottomSectionProps","disabled","variant","className","id","maxWidth","rest","_objectWithoutProperties2","actionsRefs","setActionsRefs","useState","checkBoxRef","useRef","containerRef","autoId","useId","useActionWithin","cls","handleCardClick","preventDefault","jsx","ref","role","tabIndex","onKeyDown","key","children","jsxs","style","href","onClick","componentId","instance","propTypes","_propTypes","func","bool","oneOfType","number","string","oneOf","_default"],"sources":["../../../src/Card/VerticalCard/Card.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport styled from 'styled-components';\r\nimport CardTopSection, {CardTopSectionProps} from './CardTopSection';\r\nimport CardMiddleSection, {CardMiddleSectionProps} from './CardMiddleSection';\r\nimport CardBottomSection, {CardBottomSectionProps} from './CardBottomSection';\r\nimport {BOXSHADOWS, COLORS, defaultOnMouseDownHandler, focusStyles, useActionWithin} from '../../index';\r\n\r\nexport const CardTopLevelContainerStyles = styled.div`\r\n background-color: ${props => COLORS.generateToken({componentType:'bg-surface', defaultVariant:'default'}, props.theme)};\r\n min-width: 240px;\r\n overflow: hidden;\r\n\r\n border-radius: 8px;\r\n\r\n background-clip: padding-box;\r\n box-sizing: border-box;\r\n display: flex;\r\n flex-direction: column;\r\n position: relative;\r\n\r\n .elevated & {\r\n box-shadow: ${BOXSHADOWS.BOXSHADOW_L1};\r\n }\r\n\r\n .outline & {\r\n border: 1px solid ${props => COLORS.generateToken({componentType:'border', defaultVariant: 'subtle'}, props.theme)};\r\n }\r\n`;\r\n\r\n// Full-card link that covers the entire card area\r\nexport const CardLink = styled.a`\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n right: 0;\r\n bottom: 0;\r\n z-index: 100;\r\n text-decoration: none;\r\n color: inherit;\r\n pointer-events: auto;\r\n cursor: pointer;\r\n \r\n &:focus {\r\n outline: none;\r\n }\r\n \r\n &:focus-visible {\r\n ${focusStyles}\r\n }\r\n`;\r\n\r\nexport const CardContainerStyles = styled.div`\r\n &.interactive:not(.disabled) {\r\n &:focus {\r\n ${focusStyles}\r\n }\r\n\r\n &:not(.action-within) {\r\n ${CardTopLevelContainerStyles} {\r\n &:hover {\r\n background-color: ${props => COLORS.generateToken({componentType:'bg-surface', state:'hover'}, props.theme)};\r\n }\r\n\r\n &:active, &.active-state {\r\n background-color: ${props => COLORS.generateToken({componentType:'bg-surface', state:'active'}, props.theme)};\r\n }\r\n }\r\n }\r\n\r\n &.elevated:not(.action-within) {\r\n ${CardTopLevelContainerStyles} {\r\n &:hover {\r\n box-shadow: ${BOXSHADOWS.BOXSHADOW_L3};\r\n }\r\n\r\n &:active, &.active-state {\r\n box-shadow: ${BOXSHADOWS.BOXSHADOW_L2};\r\n }\r\n }\r\n }\r\n }\r\n\r\n &.disabled {\r\n cursor: not-allowed;\r\n ${CardTopLevelContainerStyles}{\r\n border: 1px solid ${props => COLORS.generateToken({componentType:'border', state:'disabled'}, props.theme)};\r\n }\r\n }\r\n`;\r\n\r\n\r\nexport interface CardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'tabIndex' | 'onMouseDown' | 'onKeyDown' | 'onClick'> {\r\n /** Action to be executed when Card is clicked. */\r\n onCardClicked?: () => void;\r\n /** If disabled then users can not click on the card, also styles are greyed out.*/\r\n disabled?: boolean;\r\n /** Maximum width of the card. */\r\n maxWidth?: number | string;\r\n /** Properties of Card top section. */\r\n topSectionProps?: CardTopSectionProps;\r\n /** Properties of Card middle section. */\r\n middleSectionProps?: CardMiddleSectionProps;\r\n /** Properties of Card bottom section. */\r\n bottomSectionProps?: CardBottomSectionProps;\r\n /** Card container style variant. */\r\n variant?: 'outline' | 'elevated';\r\n}\r\n\r\nconst Card: React.FunctionComponent<CardProps> = ({\r\n onCardClicked,\r\n topSectionProps,\r\n middleSectionProps,\r\n bottomSectionProps,\r\n disabled,\r\n variant = 'elevated',\r\n className,\r\n id,\r\n maxWidth = 560,\r\n ...rest\r\n }: CardProps) => {\r\n\r\n\r\n const [actionsRefs, setActionsRefs] = React.useState<React.RefObject<HTMLElement | null>[]>([]);\r\n const checkBoxRef = React.useRef<HTMLDivElement>(null);\r\n const containerRef = React.useRef<HTMLDivElement>(null);\r\n const autoId = React.useId();\r\n\r\n useActionWithin(containerRef, [...actionsRefs, checkBoxRef]);\r\n\r\n const cls = `${!!onCardClicked ? 'interactive' : ''} ${disabled ? 'disabled' : ''} ${variant} ${className || ''}`;\r\n\r\n const handleCardClick = (e: React.MouseEvent) => {\r\n e.preventDefault();\r\n if (!disabled && onCardClicked) {\r\n onCardClicked();\r\n }\r\n };\r\n\r\n return (\r\n <CardContainerStyles ref={containerRef}\r\n role=\"group\"\r\n className={cls}\r\n aria-labelledby={`${autoId}-title`}\r\n tabIndex={!!onCardClicked && !disabled ? 0 : -1}\r\n onKeyDown={e => e.key === 'Enter' && !disabled && onCardClicked && onCardClicked()}\r\n data-testid={'card-wrapper'}\r\n {...rest}>\r\n <CardTopLevelContainerStyles style={{maxWidth: maxWidth}}>\r\n {/* Full-card link for accessibility */}\r\n {onCardClicked && !disabled && (\r\n <CardLink\r\n href={'#'}\r\n data-testid={'card-link'}\r\n onClick={handleCardClick}\r\n aria-labelledby={`${autoId}-title`}\r\n tabIndex={-1}\r\n />\r\n )}\r\n \r\n {\r\n topSectionProps &&\r\n <CardTopSection ref={checkBoxRef}\r\n {...topSectionProps} disabled={disabled}/>\r\n }\r\n {\r\n middleSectionProps &&\r\n <CardMiddleSection {...middleSectionProps} componentId={autoId} disabled={disabled}/>\r\n }\r\n {\r\n bottomSectionProps &&\r\n <CardBottomSection ref={instance => {\r\n setActionsRefs(instance ?? []);\r\n }}\r\n {...bottomSectionProps} disabled={disabled}/>\r\n }\r\n </CardTopLevelContainerStyles>\r\n </CardContainerStyles>\r\n );\r\n};\r\n\r\nexport default Card;\r\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,eAAA,GAAA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AE,CAAC;QAChC;MAAE,GACqBhC,kBAAkB;QAAEC,QAAQ,EAAEA;MAAS,EAAC,CAAC;IAAA,CAEvC;EAAC,EACX,CAAC;AAE1B,CAAC;AAACN,IAAA,CAAAsC,SAAA;EArFApC,aAAa,EAAAqC,UAAA,CAAAtF,OAAA,CAAAuF,IAAA;EAEblC,QAAQ,EAAAiC,UAAA,CAAAtF,OAAA,CAAAwF,IAAA;EAER/B,QAAQ,EAAA6B,UAAA,CAAAtF,OAAA,CAAAyF,SAAA,EAAAH,UAAA,CAAAtF,OAAA,CAAA0F,MAAA,EAAAJ,UAAA,CAAAtF,OAAA,CAAA2F,MAAA;EAQRrC,OAAO,EAAAgC,UAAA,CAAAtF,OAAA,CAAA4F,KAAA,EAAG,SAAS,EAAG,UAAU;AAAA;AAAA,IAAAC,QAAA,GAAA/D,OAAA,CAAA9B,OAAA,GA2EnB+C,IAAI","ignoreList":[]}
@@ -0,0 +1,25 @@
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 CardTopLevelContainerStyles: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
6
+ export declare const CardLink: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, never>> & string;
7
+ export declare const CardContainerStyles: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
8
+ export interface CardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'tabIndex' | 'onMouseDown' | 'onKeyDown' | 'onClick'> {
9
+ /** Action to be executed when Card is clicked. */
10
+ onCardClicked?: () => void;
11
+ /** If disabled then users can not click on the card, also styles are greyed out.*/
12
+ disabled?: boolean;
13
+ /** Maximum width of the card. */
14
+ maxWidth?: number | string;
15
+ /** Properties of Card top section. */
16
+ topSectionProps?: CardTopSectionProps;
17
+ /** Properties of Card middle section. */
18
+ middleSectionProps?: CardMiddleSectionProps;
19
+ /** Properties of Card bottom section. */
20
+ bottomSectionProps?: CardBottomSectionProps;
21
+ /** Card container style variant. */
22
+ variant?: 'outline' | 'elevated';
23
+ }
24
+ declare const Card: React.FunctionComponent<CardProps>;
25
+ export default Card;
@@ -0,0 +1,178 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ import _pt from "prop-types";
4
+ const _excluded = ["onCardClicked", "topSectionProps", "middleSectionProps", "bottomSectionProps", "disabled", "variant", "className", "id", "maxWidth"];
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ import * as React from 'react';
8
+ import styled from 'styled-components';
9
+ import CardTopSection from './CardTopSection';
10
+ import CardMiddleSection from './CardMiddleSection';
11
+ import CardBottomSection from './CardBottomSection';
12
+ import { BOXSHADOWS, COLORS, focusStyles, useActionWithin } from '../../index';
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ export const CardTopLevelContainerStyles = styled.div`
15
+ background-color: ${props => COLORS.generateToken({
16
+ componentType: 'bg-surface',
17
+ defaultVariant: 'default'
18
+ }, props.theme)};
19
+ min-width: 240px;
20
+ overflow: hidden;
21
+
22
+ border-radius: 8px;
23
+
24
+ background-clip: padding-box;
25
+ box-sizing: border-box;
26
+ display: flex;
27
+ flex-direction: column;
28
+ position: relative;
29
+
30
+ .elevated & {
31
+ box-shadow: ${BOXSHADOWS.BOXSHADOW_L1};
32
+ }
33
+
34
+ .outline & {
35
+ border: 1px solid ${props => COLORS.generateToken({
36
+ componentType: 'border',
37
+ defaultVariant: 'subtle'
38
+ }, props.theme)};
39
+ }
40
+ `;
41
+
42
+ // Full-card link that covers the entire card area
43
+ export const CardLink = styled.a`
44
+ position: absolute;
45
+ top: 0;
46
+ left: 0;
47
+ right: 0;
48
+ bottom: 0;
49
+ z-index: 100;
50
+ text-decoration: none;
51
+ color: inherit;
52
+ pointer-events: auto;
53
+ cursor: pointer;
54
+
55
+ &:focus {
56
+ outline: none;
57
+ }
58
+
59
+ &:focus-visible {
60
+ ${focusStyles}
61
+ }
62
+ `;
63
+ export const CardContainerStyles = styled.div`
64
+ &.interactive:not(.disabled) {
65
+ &:focus {
66
+ ${focusStyles}
67
+ }
68
+
69
+ &:not(.action-within) {
70
+ ${CardTopLevelContainerStyles} {
71
+ &:hover {
72
+ background-color: ${props => COLORS.generateToken({
73
+ componentType: 'bg-surface',
74
+ state: 'hover'
75
+ }, props.theme)};
76
+ }
77
+
78
+ &:active, &.active-state {
79
+ background-color: ${props => COLORS.generateToken({
80
+ componentType: 'bg-surface',
81
+ state: 'active'
82
+ }, props.theme)};
83
+ }
84
+ }
85
+ }
86
+
87
+ &.elevated:not(.action-within) {
88
+ ${CardTopLevelContainerStyles} {
89
+ &:hover {
90
+ box-shadow: ${BOXSHADOWS.BOXSHADOW_L3};
91
+ }
92
+
93
+ &:active, &.active-state {
94
+ box-shadow: ${BOXSHADOWS.BOXSHADOW_L2};
95
+ }
96
+ }
97
+ }
98
+ }
99
+
100
+ &.disabled {
101
+ cursor: not-allowed;
102
+ ${CardTopLevelContainerStyles}{
103
+ border: 1px solid ${props => COLORS.generateToken({
104
+ componentType: 'border',
105
+ state: 'disabled'
106
+ }, props.theme)};
107
+ }
108
+ }
109
+ `;
110
+ const Card = _ref => {
111
+ let {
112
+ onCardClicked,
113
+ topSectionProps,
114
+ middleSectionProps,
115
+ bottomSectionProps,
116
+ disabled,
117
+ variant = 'elevated',
118
+ className,
119
+ id,
120
+ maxWidth = 560
121
+ } = _ref,
122
+ rest = _objectWithoutProperties(_ref, _excluded);
123
+ const [actionsRefs, setActionsRefs] = React.useState([]);
124
+ const checkBoxRef = React.useRef(null);
125
+ const containerRef = React.useRef(null);
126
+ const autoId = React.useId();
127
+ useActionWithin(containerRef, [...actionsRefs, checkBoxRef]);
128
+ const cls = `${!!onCardClicked ? 'interactive' : ''} ${disabled ? 'disabled' : ''} ${variant} ${className || ''}`;
129
+ const handleCardClick = e => {
130
+ e.preventDefault();
131
+ if (!disabled && onCardClicked) {
132
+ onCardClicked();
133
+ }
134
+ };
135
+ return /*#__PURE__*/_jsx(CardContainerStyles, _objectSpread(_objectSpread({
136
+ ref: containerRef,
137
+ role: "group",
138
+ className: cls,
139
+ "aria-labelledby": `${autoId}-title`,
140
+ tabIndex: !!onCardClicked && !disabled ? 0 : -1,
141
+ onKeyDown: e => e.key === 'Enter' && !disabled && onCardClicked && onCardClicked(),
142
+ "data-testid": 'card-wrapper'
143
+ }, rest), {}, {
144
+ children: /*#__PURE__*/_jsxs(CardTopLevelContainerStyles, {
145
+ style: {
146
+ maxWidth: maxWidth
147
+ },
148
+ children: [onCardClicked && !disabled && /*#__PURE__*/_jsx(CardLink, {
149
+ href: '#',
150
+ "data-testid": 'card-link',
151
+ onClick: handleCardClick,
152
+ "aria-labelledby": `${autoId}-title`,
153
+ tabIndex: -1
154
+ }), topSectionProps && /*#__PURE__*/_jsx(CardTopSection, _objectSpread(_objectSpread({
155
+ ref: checkBoxRef
156
+ }, topSectionProps), {}, {
157
+ disabled: disabled
158
+ })), middleSectionProps && /*#__PURE__*/_jsx(CardMiddleSection, _objectSpread(_objectSpread({}, middleSectionProps), {}, {
159
+ componentId: autoId,
160
+ disabled: disabled
161
+ })), bottomSectionProps && /*#__PURE__*/_jsx(CardBottomSection, _objectSpread(_objectSpread({
162
+ ref: instance => {
163
+ setActionsRefs(instance ?? []);
164
+ }
165
+ }, bottomSectionProps), {}, {
166
+ disabled: disabled
167
+ }))]
168
+ })
169
+ }));
170
+ };
171
+ Card.propTypes = {
172
+ onCardClicked: _pt.func,
173
+ disabled: _pt.bool,
174
+ maxWidth: _pt.oneOfType([_pt.number, _pt.string]),
175
+ variant: _pt.oneOf(['outline', 'elevated'])
176
+ };
177
+ export default Card;
178
+ //# sourceMappingURL=Card.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card.js","names":["React","styled","CardTopSection","CardMiddleSection","CardBottomSection","BOXSHADOWS","COLORS","focusStyles","useActionWithin","jsx","_jsx","jsxs","_jsxs","CardTopLevelContainerStyles","div","props","generateToken","componentType","defaultVariant","theme","BOXSHADOW_L1","CardLink","a","CardContainerStyles","state","BOXSHADOW_L3","BOXSHADOW_L2","Card","_ref","onCardClicked","topSectionProps","middleSectionProps","bottomSectionProps","disabled","variant","className","id","maxWidth","rest","_objectWithoutProperties","_excluded","actionsRefs","setActionsRefs","useState","checkBoxRef","useRef","containerRef","autoId","useId","cls","handleCardClick","e","preventDefault","_objectSpread","ref","role","tabIndex","onKeyDown","key","children","style","href","onClick","componentId","instance","propTypes","_pt","func","bool","oneOfType","number","string","oneOf"],"sources":["../../../src/Card/VerticalCard/Card.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport styled from 'styled-components';\r\nimport CardTopSection, {CardTopSectionProps} from './CardTopSection';\r\nimport CardMiddleSection, {CardMiddleSectionProps} from './CardMiddleSection';\r\nimport CardBottomSection, {CardBottomSectionProps} from './CardBottomSection';\r\nimport {BOXSHADOWS, COLORS, defaultOnMouseDownHandler, focusStyles, useActionWithin} from '../../index';\r\n\r\nexport const CardTopLevelContainerStyles = styled.div`\r\n background-color: ${props => COLORS.generateToken({componentType:'bg-surface', defaultVariant:'default'}, props.theme)};\r\n min-width: 240px;\r\n overflow: hidden;\r\n\r\n border-radius: 8px;\r\n\r\n background-clip: padding-box;\r\n box-sizing: border-box;\r\n display: flex;\r\n flex-direction: column;\r\n position: relative;\r\n\r\n .elevated & {\r\n box-shadow: ${BOXSHADOWS.BOXSHADOW_L1};\r\n }\r\n\r\n .outline & {\r\n border: 1px solid ${props => COLORS.generateToken({componentType:'border', defaultVariant: 'subtle'}, props.theme)};\r\n }\r\n`;\r\n\r\n// Full-card link that covers the entire card area\r\nexport const CardLink = styled.a`\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n right: 0;\r\n bottom: 0;\r\n z-index: 100;\r\n text-decoration: none;\r\n color: inherit;\r\n pointer-events: auto;\r\n cursor: pointer;\r\n \r\n &:focus {\r\n outline: none;\r\n }\r\n \r\n &:focus-visible {\r\n ${focusStyles}\r\n }\r\n`;\r\n\r\nexport const CardContainerStyles = styled.div`\r\n &.interactive:not(.disabled) {\r\n &:focus {\r\n ${focusStyles}\r\n }\r\n\r\n &:not(.action-within) {\r\n ${CardTopLevelContainerStyles} {\r\n &:hover {\r\n background-color: ${props => COLORS.generateToken({componentType:'bg-surface', state:'hover'}, props.theme)};\r\n }\r\n\r\n &:active, &.active-state {\r\n background-color: ${props => COLORS.generateToken({componentType:'bg-surface', state:'active'}, props.theme)};\r\n }\r\n }\r\n }\r\n\r\n &.elevated:not(.action-within) {\r\n ${CardTopLevelContainerStyles} {\r\n &:hover {\r\n box-shadow: ${BOXSHADOWS.BOXSHADOW_L3};\r\n }\r\n\r\n &:active, &.active-state {\r\n box-shadow: ${BOXSHADOWS.BOXSHADOW_L2};\r\n }\r\n }\r\n }\r\n }\r\n\r\n &.disabled {\r\n cursor: not-allowed;\r\n ${CardTopLevelContainerStyles}{\r\n border: 1px solid ${props => COLORS.generateToken({componentType:'border', state:'disabled'}, props.theme)};\r\n }\r\n }\r\n`;\r\n\r\n\r\nexport interface CardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'tabIndex' | 'onMouseDown' | 'onKeyDown' | 'onClick'> {\r\n /** Action to be executed when Card is clicked. */\r\n onCardClicked?: () => void;\r\n /** If disabled then users can not click on the card, also styles are greyed out.*/\r\n disabled?: boolean;\r\n /** Maximum width of the card. */\r\n maxWidth?: number | string;\r\n /** Properties of Card top section. */\r\n topSectionProps?: CardTopSectionProps;\r\n /** Properties of Card middle section. */\r\n middleSectionProps?: CardMiddleSectionProps;\r\n /** Properties of Card bottom section. */\r\n bottomSectionProps?: CardBottomSectionProps;\r\n /** Card container style variant. */\r\n variant?: 'outline' | 'elevated';\r\n}\r\n\r\nconst Card: React.FunctionComponent<CardProps> = ({\r\n onCardClicked,\r\n topSectionProps,\r\n middleSectionProps,\r\n bottomSectionProps,\r\n disabled,\r\n variant = 'elevated',\r\n className,\r\n id,\r\n maxWidth = 560,\r\n ...rest\r\n }: CardProps) => {\r\n\r\n\r\n const [actionsRefs, setActionsRefs] = React.useState<React.RefObject<HTMLElement | null>[]>([]);\r\n const checkBoxRef = React.useRef<HTMLDivElement>(null);\r\n const containerRef = React.useRef<HTMLDivElement>(null);\r\n const autoId = React.useId();\r\n\r\n useActionWithin(containerRef, [...actionsRefs, checkBoxRef]);\r\n\r\n const cls = `${!!onCardClicked ? 'interactive' : ''} ${disabled ? 'disabled' : ''} ${variant} ${className || ''}`;\r\n\r\n const handleCardClick = (e: React.MouseEvent) => {\r\n e.preventDefault();\r\n if (!disabled && onCardClicked) {\r\n onCardClicked();\r\n }\r\n };\r\n\r\n return (\r\n <CardContainerStyles ref={containerRef}\r\n role=\"group\"\r\n className={cls}\r\n aria-labelledby={`${autoId}-title`}\r\n tabIndex={!!onCardClicked && !disabled ? 0 : -1}\r\n onKeyDown={e => e.key === 'Enter' && !disabled && onCardClicked && onCardClicked()}\r\n data-testid={'card-wrapper'}\r\n {...rest}>\r\n <CardTopLevelContainerStyles style={{maxWidth: maxWidth}}>\r\n {/* Full-card link for accessibility */}\r\n {onCardClicked && !disabled && (\r\n <CardLink\r\n href={'#'}\r\n data-testid={'card-link'}\r\n onClick={handleCardClick}\r\n aria-labelledby={`${autoId}-title`}\r\n tabIndex={-1}\r\n />\r\n )}\r\n \r\n {\r\n topSectionProps &&\r\n <CardTopSection ref={checkBoxRef}\r\n {...topSectionProps} disabled={disabled}/>\r\n }\r\n {\r\n middleSectionProps &&\r\n <CardMiddleSection {...middleSectionProps} componentId={autoId} disabled={disabled}/>\r\n }\r\n {\r\n bottomSectionProps &&\r\n <CardBottomSection ref={instance => {\r\n setActionsRefs(instance ?? []);\r\n }}\r\n {...bottomSectionProps} disabled={disabled}/>\r\n }\r\n </CardTopLevelContainerStyles>\r\n </CardContainerStyles>\r\n );\r\n};\r\n\r\nexport default Card;\r\n"],"mappings":";;;;;;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,MAAM,MAAM,mBAAmB;AACtC,OAAOC,cAAc,MAA6B,kBAAkB;AACpE,OAAOC,iBAAiB,MAAgC,qBAAqB;AAC7E,OAAOC,iBAAiB,MAAgC,qBAAqB;AAC7E,SAAQC,UAAU,EAAEC,MAAM,EAA6BC,WAAW,EAAEC,eAAe,QAAO,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAExG,OAAO,MAAMC,2BAA2B,GAAGZ,MAAM,CAACa,GAAG;AACrD,sBAAsBC,KAAK,IAAIT,MAAM,CAACU,aAAa,CAAC;EAACC,aAAa,EAAC,YAAY;EAAEC,cAAc,EAAC;AAAS,CAAC,EAAEH,KAAK,CAACI,KAAK,CAAC;AACxH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkBd,UAAU,CAACe,YAAY;AACzC;AACA;AACA;AACA,wBAAwBL,KAAK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