@laerdal/life-react-components 1.3.1 → 1.3.2-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/Accordion/ContentAccordion.js +238 -0
- package/dist/esm/Accordion/ContentAccordion.js.map +1 -0
- package/dist/esm/Accordion/__tests__/ContetnAccordion.test.js +137 -0
- package/dist/esm/Accordion/__tests__/ContetnAccordion.test.js.map +1 -0
- package/dist/esm/Accordion/index.js +1 -0
- package/dist/esm/Accordion/index.js.map +1 -1
- package/dist/esm/Button/Button.js +8 -53
- package/dist/esm/Button/Button.js.map +1 -1
- package/dist/esm/Modals/__tests__/Modal.test.js +154 -0
- package/dist/esm/Modals/__tests__/Modal.test.js.map +1 -0
- package/dist/esm/Tabs/TabLink.js +1 -0
- package/dist/esm/Tabs/TabLink.js.map +1 -1
- package/dist/js/Accordion/ContentAccordion.d.ts +18 -0
- package/dist/js/Accordion/ContentAccordion.js +151 -0
- package/dist/js/Accordion/ContentAccordion.js.map +1 -0
- package/dist/js/Accordion/__tests__/ContetnAccordion.test.js +151 -0
- package/dist/js/Accordion/__tests__/ContetnAccordion.test.js.map +1 -0
- package/dist/js/Accordion/index.d.ts +1 -0
- package/dist/js/Accordion/index.js +8 -0
- package/dist/js/Accordion/index.js.map +1 -1
- package/dist/js/Button/Button.js +6 -12
- package/dist/js/Button/Button.js.map +1 -1
- package/dist/js/Modals/__tests__/Modal.test.js +231 -0
- package/dist/js/Modals/__tests__/Modal.test.js.map +1 -0
- package/dist/js/Tabs/TabLink.js +1 -1
- package/dist/js/Tabs/TabLink.js.map +1 -1
- package/dist/umd/Accordion/ContentAccordion.js +266 -0
- package/dist/umd/Accordion/ContentAccordion.js.map +1 -0
- package/dist/umd/Accordion/__tests__/ContetnAccordion.test.js +165 -0
- package/dist/umd/Accordion/__tests__/ContetnAccordion.test.js.map +1 -0
- package/dist/umd/Accordion/index.js +10 -4
- package/dist/umd/Accordion/index.js.map +1 -1
- package/dist/umd/Button/Button.js +8 -53
- package/dist/umd/Button/Button.js.map +1 -1
- package/dist/umd/Modals/__tests__/Modal.test.js +173 -0
- package/dist/umd/Modals/__tests__/Modal.test.js.map +1 -0
- package/dist/umd/Tabs/TabLink.js +1 -0
- package/dist/umd/Tabs/TabLink.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
|
|
5
|
+
var _react2 = require("@testing-library/react");
|
|
6
|
+
|
|
7
|
+
require("jest-styled-components");
|
|
8
|
+
|
|
9
|
+
var _ = require("..");
|
|
10
|
+
|
|
11
|
+
var _2 = require("../..");
|
|
12
|
+
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
|
|
15
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
16
|
+
|
|
17
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
18
|
+
|
|
19
|
+
describe('<ModalDialog />', function () {
|
|
20
|
+
var mountingDiv;
|
|
21
|
+
beforeEach(function () {
|
|
22
|
+
//being rendered as a React.Portal we need to have the 'root' div defined
|
|
23
|
+
mountingDiv = document.createElement('div');
|
|
24
|
+
mountingDiv.id = 'root';
|
|
25
|
+
document.body.appendChild(mountingDiv);
|
|
26
|
+
});
|
|
27
|
+
afterEach(function () {
|
|
28
|
+
document.body.removeChild(mountingDiv);
|
|
29
|
+
});
|
|
30
|
+
it('Check modal not rendered when isModalOpen is false', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
31
|
+
var _render, container, getByText;
|
|
32
|
+
|
|
33
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
34
|
+
while (1) {
|
|
35
|
+
switch (_context.prev = _context.next) {
|
|
36
|
+
case 0:
|
|
37
|
+
_render = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.ModalDialog, {
|
|
38
|
+
key: "smallModalWithoutImage",
|
|
39
|
+
closeModalAndClearInput: function closeModalAndClearInput() {},
|
|
40
|
+
title: 'Header',
|
|
41
|
+
size: _2.Size.Small,
|
|
42
|
+
isModalOpen: false,
|
|
43
|
+
closeAction: function closeAction() {},
|
|
44
|
+
submitAction: function submitAction() {}
|
|
45
|
+
})), container = _render.container, getByText = _render.getByText; //check modal portal not exists when modal not opened
|
|
46
|
+
|
|
47
|
+
expect(container.querySelector('.ReactModalPortal')).toBeNull();
|
|
48
|
+
|
|
49
|
+
case 2:
|
|
50
|
+
case "end":
|
|
51
|
+
return _context.stop();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}, _callee);
|
|
55
|
+
})));
|
|
56
|
+
it('Check modal visible, title and footer buttons displayed correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
57
|
+
var _render2, container, getByText;
|
|
58
|
+
|
|
59
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
60
|
+
while (1) {
|
|
61
|
+
switch (_context2.prev = _context2.next) {
|
|
62
|
+
case 0:
|
|
63
|
+
_render2 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.ModalDialog, {
|
|
64
|
+
key: "smallModalWithoutImage",
|
|
65
|
+
closeModalAndClearInput: function closeModalAndClearInput() {},
|
|
66
|
+
title: 'Header',
|
|
67
|
+
size: _2.Size.Small,
|
|
68
|
+
isModalOpen: true,
|
|
69
|
+
closeAction: function closeAction() {},
|
|
70
|
+
submitAction: function submitAction() {},
|
|
71
|
+
buttons: [{
|
|
72
|
+
action: function action() {},
|
|
73
|
+
text: 'Close',
|
|
74
|
+
variant: 'tertiary'
|
|
75
|
+
}, {
|
|
76
|
+
action: function action() {},
|
|
77
|
+
text: 'Save'
|
|
78
|
+
}]
|
|
79
|
+
})), container = _render2.container, getByText = _render2.getByText; //check modal portal defined
|
|
80
|
+
|
|
81
|
+
expect(container.querySelector('.ReactModalPortal')).toBeDefined(); //Check header and footer buttons
|
|
82
|
+
|
|
83
|
+
expect(getByText('Header')).toBeDefined();
|
|
84
|
+
expect(getByText('Close')).toBeDefined();
|
|
85
|
+
expect(getByText('Save')).toBeDefined();
|
|
86
|
+
|
|
87
|
+
case 5:
|
|
88
|
+
case "end":
|
|
89
|
+
return _context2.stop();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, _callee2);
|
|
93
|
+
})));
|
|
94
|
+
it('Check tooltip, and link displayed without right footer buttons', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
95
|
+
var _render3, baseElement, getByText;
|
|
96
|
+
|
|
97
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
98
|
+
while (1) {
|
|
99
|
+
switch (_context3.prev = _context3.next) {
|
|
100
|
+
case 0:
|
|
101
|
+
_render3 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.ModalDialog, {
|
|
102
|
+
key: "smallModalWithoutImage",
|
|
103
|
+
closeModalAndClearInput: function closeModalAndClearInput() {},
|
|
104
|
+
title: 'Header',
|
|
105
|
+
size: _2.Size.Small,
|
|
106
|
+
isModalOpen: true,
|
|
107
|
+
closeAction: function closeAction() {},
|
|
108
|
+
submitAction: function submitAction() {},
|
|
109
|
+
tooltip: 'some test tooltip',
|
|
110
|
+
leftFooterAction: {
|
|
111
|
+
id: 'test-link',
|
|
112
|
+
actionType: 'hyperlink',
|
|
113
|
+
text: 'Link',
|
|
114
|
+
href: 'http://test.com',
|
|
115
|
+
icon: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null),
|
|
116
|
+
variant: 'default'
|
|
117
|
+
}
|
|
118
|
+
})), baseElement = _render3.baseElement, getByText = _render3.getByText; //check tooltip displayed
|
|
119
|
+
|
|
120
|
+
expect(getByText('some test tooltip').textContent).toBeDefined(); //check footer link displayed
|
|
121
|
+
|
|
122
|
+
expect(getByText('Link').children).toBeDefined();
|
|
123
|
+
|
|
124
|
+
case 3:
|
|
125
|
+
case "end":
|
|
126
|
+
return _context3.stop();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}, _callee3);
|
|
130
|
+
})));
|
|
131
|
+
it('Check note and footer note displayed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
132
|
+
var _baseElement$querySel;
|
|
133
|
+
|
|
134
|
+
var _render4, baseElement, getByText;
|
|
135
|
+
|
|
136
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
137
|
+
while (1) {
|
|
138
|
+
switch (_context4.prev = _context4.next) {
|
|
139
|
+
case 0:
|
|
140
|
+
_render4 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.ModalDialog, {
|
|
141
|
+
key: "smallModalWithoutImage",
|
|
142
|
+
closeModalAndClearInput: function closeModalAndClearInput() {},
|
|
143
|
+
title: 'Header',
|
|
144
|
+
size: _2.Size.Small,
|
|
145
|
+
isModalOpen: true,
|
|
146
|
+
closeAction: function closeAction() {},
|
|
147
|
+
submitAction: function submitAction() {},
|
|
148
|
+
leftFooterAction: {
|
|
149
|
+
id: 'test-note',
|
|
150
|
+
actionType: 'note',
|
|
151
|
+
text: 'Test note',
|
|
152
|
+
icon: /*#__PURE__*/_react.default.createElement(_2.SystemIcons.Information, null)
|
|
153
|
+
},
|
|
154
|
+
note: 'Message text',
|
|
155
|
+
state: 'critical'
|
|
156
|
+
})), baseElement = _render4.baseElement, getByText = _render4.getByText; //check footer note text displayed
|
|
157
|
+
|
|
158
|
+
expect(getByText('Test note').textContent).toBeDefined(); //check note section added
|
|
159
|
+
|
|
160
|
+
expect((_baseElement$querySel = baseElement.querySelectorAll('section')) === null || _baseElement$querySel === void 0 ? void 0 : _baseElement$querySel.length).toEqual(4); //check note message displayed
|
|
161
|
+
|
|
162
|
+
expect(getByText('Message text').children).toBeDefined();
|
|
163
|
+
|
|
164
|
+
case 4:
|
|
165
|
+
case "end":
|
|
166
|
+
return _context4.stop();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}, _callee4);
|
|
170
|
+
})));
|
|
171
|
+
it('Check back button and close icon displayed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
|
|
172
|
+
var _baseElement$querySel2;
|
|
173
|
+
|
|
174
|
+
var _render5, baseElement, getByText, container;
|
|
175
|
+
|
|
176
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
177
|
+
while (1) {
|
|
178
|
+
switch (_context5.prev = _context5.next) {
|
|
179
|
+
case 0:
|
|
180
|
+
_render5 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.ModalDialog, {
|
|
181
|
+
key: "smallModalWithoutImage",
|
|
182
|
+
closeModalAndClearInput: function closeModalAndClearInput() {},
|
|
183
|
+
title: 'Header',
|
|
184
|
+
size: _2.Size.Small,
|
|
185
|
+
backButton: function backButton() {},
|
|
186
|
+
isModalOpen: true,
|
|
187
|
+
closeAction: function closeAction() {},
|
|
188
|
+
submitAction: function submitAction() {}
|
|
189
|
+
})), baseElement = _render5.baseElement, getByText = _render5.getByText, container = _render5.container; //only 2 svg elements should be found in the header of the modal
|
|
190
|
+
|
|
191
|
+
expect((_baseElement$querySel2 = baseElement.querySelectorAll('svg')) === null || _baseElement$querySel2 === void 0 ? void 0 : _baseElement$querySel2.length).toEqual(2);
|
|
192
|
+
|
|
193
|
+
case 2:
|
|
194
|
+
case "end":
|
|
195
|
+
return _context5.stop();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}, _callee5);
|
|
199
|
+
})));
|
|
200
|
+
it('Check modal body displayed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
|
|
201
|
+
var _baseElement$querySel3, _baseElement$querySel4;
|
|
202
|
+
|
|
203
|
+
var _render6, baseElement, getByText, container;
|
|
204
|
+
|
|
205
|
+
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
206
|
+
while (1) {
|
|
207
|
+
switch (_context6.prev = _context6.next) {
|
|
208
|
+
case 0:
|
|
209
|
+
_render6 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.ModalDialog, {
|
|
210
|
+
key: "smallModalWithoutImage",
|
|
211
|
+
closeModalAndClearInput: function closeModalAndClearInput() {},
|
|
212
|
+
title: 'Header',
|
|
213
|
+
size: _2.Size.Small,
|
|
214
|
+
isModalOpen: true,
|
|
215
|
+
closeAction: function closeAction() {},
|
|
216
|
+
submitAction: function submitAction() {}
|
|
217
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, "Inner modal text"))), baseElement = _render6.baseElement, getByText = _render6.getByText, container = _render6.container; //Check all dialog sections are displayed
|
|
218
|
+
|
|
219
|
+
expect((_baseElement$querySel3 = baseElement.querySelectorAll('section')) === null || _baseElement$querySel3 === void 0 ? void 0 : _baseElement$querySel3.length).toEqual(3); //Check that the second section (modal body) has the correct text
|
|
220
|
+
|
|
221
|
+
expect((_baseElement$querySel4 = baseElement.querySelectorAll('section')) === null || _baseElement$querySel4 === void 0 ? void 0 : _baseElement$querySel4[1].textContent).toEqual('Inner modal text');
|
|
222
|
+
|
|
223
|
+
case 3:
|
|
224
|
+
case "end":
|
|
225
|
+
return _context6.stop();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}, _callee6);
|
|
229
|
+
})));
|
|
230
|
+
});
|
|
231
|
+
//# sourceMappingURL=Modal.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/Modals/__tests__/Modal.test.tsx"],"names":["describe","mountingDiv","beforeEach","document","createElement","id","body","appendChild","afterEach","removeChild","it","Size","Small","container","getByText","expect","querySelector","toBeNull","action","text","variant","toBeDefined","actionType","href","icon","baseElement","textContent","children","querySelectorAll","length","toEqual"],"mappings":";;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEAA,QAAQ,CAAC,iBAAD,EAAoB,YAAM;AAChC,MAAIC,WAAJ;AAEAC,EAAAA,UAAU,CAAC,YAAM;AACf;AACAD,IAAAA,WAAW,GAAGE,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAd;AACAH,IAAAA,WAAW,CAACI,EAAZ,GAAiB,MAAjB;AACAF,IAAAA,QAAQ,CAACG,IAAT,CAAcC,WAAd,CAA0BN,WAA1B;AACD,GALS,CAAV;AAOAO,EAAAA,SAAS,CAAC,YAAM;AACdL,IAAAA,QAAQ,CAACG,IAAT,CAAcG,WAAd,CAA0BR,WAA1B;AACD,GAFQ,CAAT;AAIAS,EAAAA,EAAE,CAAC,oDAAD,uEAAuD;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,sBACtB,kCAC/B,6BAAC,aAAD;AACE,cAAA,GAAG,EAAC,wBADN;AAEE,cAAA,uBAAuB,EAAE,mCAAM,CAAE,CAFnC;AAGE,cAAA,KAAK,EAAE,QAHT;AAIE,cAAA,IAAI,EAAEC,QAAKC,KAJb;AAKE,cAAA,WAAW,EAAE,KALf;AAME,cAAA,WAAW,EAAE,uBAAM,CAAE,CANvB;AAOE,cAAA,YAAY,EAAE,wBAAM,CAAE;AAPxB,cAD+B,CADsB,EAC/CC,SAD+C,WAC/CA,SAD+C,EACpCC,SADoC,WACpCA,SADoC,EAYvD;;AACAC,YAAAA,MAAM,CAACF,SAAS,CAACG,aAAV,CAAwB,mBAAxB,CAAD,CAAN,CAAqDC,QAArD;;AAbuD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAAvD,GA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AW,CAACG,gBAAZ,CAA6B,KAA7B,CAAD,2DAAC,uBAAqCC,MAAtC,CAAN,CAAoDC,OAApD,CAA4D,CAA5D;;AAd+C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAA/C,GAAF;AAiBApB,EAAAA,EAAE,CAAC,4BAAD,uEAA+B;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,uBACe,kCAC5C,6BAAC,aAAD;AACE,cAAA,GAAG,EAAC,wBADN;AAEE,cAAA,uBAAuB,EAAE,mCAAM,CAAE,CAFnC;AAGE,cAAA,KAAK,EAAE,QAHT;AAIE,cAAA,IAAI,EAAEC,QAAKC,KAJb;AAKE,cAAA,WAAW,EAAE,IALf;AAME,cAAA,WAAW,EAAE,uBAAM,CAAE,CANvB;AAOE,cAAA,YAAY,EAAE,wBAAM,CAAE;AAPxB,4BAQE,8DARF,CAD4C,CADf,EACvBa,WADuB,YACvBA,WADuB,EACVX,SADU,YACVA,SADU,EACCD,SADD,YACCA,SADD,EAa/B;;AACAE,YAAAA,MAAM,2BAACU,WAAW,CAACG,gBAAZ,CAA6B,SAA7B,CAAD,2DAAC,uBAAyCC,MAA1C,CAAN,CAAwDC,OAAxD,CAAgE,CAAhE,EAd+B,CAe/B;;AACAf,YAAAA,MAAM,2BAACU,WAAW,CAACG,gBAAZ,CAA6B,SAA7B,CAAD,2DAAC,uBAA0C,CAA1C,EAA6CF,WAA9C,CAAN,CAAiEI,OAAjE,CAAyE,kBAAzE;;AAhB+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAA/B,GAAF;AAkBD,CA3IO,CAAR","sourcesContent":["import React from 'react';\nimport { render } from '@testing-library/react';\nimport 'jest-styled-components';\nimport { ModalDialog } from '..';\nimport { COLORS, Size, SystemIcons } from '../..';\n\ndescribe('<ModalDialog />', () => {\n let mountingDiv: HTMLElement;\n\n beforeEach(() => {\n //being rendered as a React.Portal we need to have the 'root' div defined\n mountingDiv = document.createElement('div');\n mountingDiv.id = 'root';\n document.body.appendChild(mountingDiv);\n });\n\n afterEach(() => {\n document.body.removeChild(mountingDiv);\n });\n\n it('Check modal not rendered when isModalOpen is false', async () => {\n const { container, getByText } = render(\n <ModalDialog\n key=\"smallModalWithoutImage\"\n closeModalAndClearInput={() => {}}\n title={'Header'}\n size={Size.Small}\n isModalOpen={false}\n closeAction={() => {}}\n submitAction={() => {}}\n />,\n );\n //check modal portal not exists when modal not opened\n expect(container.querySelector('.ReactModalPortal')).toBeNull();\n });\n\n it('Check modal visible, title and footer buttons displayed correctly', async () => {\n const { container, getByText } = render(\n <ModalDialog\n key=\"smallModalWithoutImage\"\n closeModalAndClearInput={() => {}}\n title={'Header'}\n size={Size.Small}\n isModalOpen={true}\n closeAction={() => {}}\n submitAction={() => {}}\n buttons={[\n {\n action: () => {},\n text: 'Close',\n variant: 'tertiary',\n },\n {\n action: () => {},\n text: 'Save',\n },\n ]}\n />,\n );\n //check modal portal defined\n expect(container.querySelector('.ReactModalPortal')).toBeDefined();\n //Check header and footer buttons\n expect(getByText('Header')).toBeDefined();\n expect(getByText('Close')).toBeDefined();\n expect(getByText('Save')).toBeDefined();\n });\n\n it('Check tooltip, and link displayed without right footer buttons', async () => {\n const { baseElement, getByText } = render(\n <ModalDialog\n key=\"smallModalWithoutImage\"\n closeModalAndClearInput={() => {}}\n title={'Header'}\n size={Size.Small}\n isModalOpen={true}\n closeAction={() => {}}\n submitAction={() => {}}\n tooltip={'some test tooltip'}\n leftFooterAction={{ id: 'test-link', actionType: 'hyperlink', text: 'Link', href: 'http://test.com', icon: <></>, variant: 'default' }}\n />,\n );\n //check tooltip displayed\n expect(getByText('some test tooltip').textContent).toBeDefined();\n //check footer link displayed\n expect(getByText('Link').children).toBeDefined();\n });\n\n it('Check note and footer note displayed', async () => {\n const { baseElement, getByText } = render(\n <ModalDialog\n key=\"smallModalWithoutImage\"\n closeModalAndClearInput={() => {}}\n title={'Header'}\n size={Size.Small}\n isModalOpen={true}\n closeAction={() => {}}\n submitAction={() => {}}\n leftFooterAction={{ id: 'test-note', actionType: 'note', text: 'Test note', icon: <SystemIcons.Information /> }}\n note={'Message text'}\n state={'critical'}\n />,\n );\n //check footer note text displayed\n expect(getByText('Test note').textContent).toBeDefined();\n //check note section added\n expect(baseElement.querySelectorAll('section')?.length).toEqual(4);\n //check note message displayed\n expect(getByText('Message text').children).toBeDefined();\n });\n\n it('Check back button and close icon displayed', async () => {\n const { baseElement, getByText, container } = render(\n <ModalDialog\n key=\"smallModalWithoutImage\"\n closeModalAndClearInput={() => {}}\n title={'Header'}\n size={Size.Small}\n backButton={() => {}}\n isModalOpen={true}\n closeAction={() => {}}\n submitAction={() => {}}\n />,\n );\n //only 2 svg elements should be found in the header of the modal\n expect(baseElement.querySelectorAll('svg')?.length).toEqual(2);\n });\n\n it('Check modal body displayed', async () => {\n const { baseElement, getByText, container } = render(\n <ModalDialog\n key=\"smallModalWithoutImage\"\n closeModalAndClearInput={() => {}}\n title={'Header'}\n size={Size.Small}\n isModalOpen={true}\n closeAction={() => {}}\n submitAction={() => {}}>\n <span>Inner modal text</span>\n </ModalDialog>,\n );\n //Check all dialog sections are displayed\n expect(baseElement.querySelectorAll('section')?.length).toEqual(3);\n //Check that the second section (modal body) has the correct text\n expect(baseElement.querySelectorAll('section')?.[1].textContent).toEqual('Inner modal text');\n });\n});\n"],"file":"Modal.test.js"}
|
package/dist/js/Tabs/TabLink.js
CHANGED
|
@@ -43,7 +43,7 @@ var OptionalLineWrapperWithIcon = _styledComponents.default.div(_templateObject2
|
|
|
43
43
|
|
|
44
44
|
var TopWrapper = _styledComponents.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n span:not(:only-child) {\n width: calc(100% - 32px);\n }\n"])));
|
|
45
45
|
|
|
46
|
-
var TextContainer = _styledComponents.default.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: 100%;\n"])));
|
|
46
|
+
var TextContainer = _styledComponents.default.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: 100%;\n margin: auto 0 auto 16px !important;\n"])));
|
|
47
47
|
|
|
48
48
|
var StyledNotification = _styledComponents.default.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n margin: 0 15px 0 0 !important;\n"])));
|
|
49
49
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Tabs/TabLink.tsx"],"names":["StyledTabLink","NavLink","COLORS","neutral_600","props","disabled","neutral_100","Z_INDEXES","focus","white","active","neutral_20","primary_20","hover","primary_600","primary_100","primary_800","primary_500","neutral_300","OptionalLineWrapperWithIcon","styled","div","TopWrapper","TextContainer","StyledNotification","OptionalLineWrapper","TabLink","to","exact","requiredLine","optionalLine","OptionalLineIcon","onLinkClick","testId","showNotificationDot","size","Size","Small","variant","location","ref","React","useRef","toString","pathname","current","blur","undefined"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;;;AAmBA,IAAMA,aAAa,GAAG,+BAAOC,uBAAP,CAAH,kkDAORC,eAAOC,WAPC,EASG,UAACC,KAAD;AAAA,SAAYA,KAAK,CAACC,QAAN,GAAiBH,eAAOI,WAAxB,GAAsC,aAAlD;AAAA,CATH,EAUP,UAACF,KAAD;AAAA,SAAYA,KAAK,CAACC,QAAN,GAAiB,aAAjB,GAAiC,SAA7C;AAAA,CAVO,EAqBJE,oBAAUC,KArBN,EAsBKN,eAAOO,KAtBZ,EA2BOP,eAAOO,KA3Bd,EAgCJF,oBAAUG,MAhCN,EAiCKR,eAAOS,UAjCZ,EAqCKT,eAAOU,UArCZ,EAyCKV,eAAOO,KAzCZ,EA6CJF,oBAAUM,KA7CN,EA8CKX,eAAOU,UA9CZ,EA+CNV,eAAOY,WA/CD,EAmDJP,oBAAUG,MAnDN,EAqDKR,eAAOa,WArDZ,EAsDNb,eAAOc,WAtDD,EAiEOd,eAAOe,WAjEd,EAyEOf,eAAOY,WAzEd,EA8EKZ,eAAOa,WA9EZ,EAiFOb,eAAOc,WAjFd,EAuFKd,eAAOO,KAvFZ,EA0FJP,eAAOgB,WA1FH,EA8FOhB,eAAOO,KA9Fd,CAAnB;;AAmGA,IAAMU,2BAA2B,GAAGC,0BAAOC,GAAV,mNAAjC;;AAUA,IAAMC,UAAU,GAAGF,0BAAOC,GAAV,kLAAhB;;AAQA,IAAME,aAAa,GAAGH,0BAAOC,GAAV,
|
|
1
|
+
{"version":3,"sources":["../../../src/Tabs/TabLink.tsx"],"names":["StyledTabLink","NavLink","COLORS","neutral_600","props","disabled","neutral_100","Z_INDEXES","focus","white","active","neutral_20","primary_20","hover","primary_600","primary_100","primary_800","primary_500","neutral_300","OptionalLineWrapperWithIcon","styled","div","TopWrapper","TextContainer","StyledNotification","OptionalLineWrapper","TabLink","to","exact","requiredLine","optionalLine","OptionalLineIcon","onLinkClick","testId","showNotificationDot","size","Size","Small","variant","location","ref","React","useRef","toString","pathname","current","blur","undefined"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;;;AAmBA,IAAMA,aAAa,GAAG,+BAAOC,uBAAP,CAAH,kkDAORC,eAAOC,WAPC,EASG,UAACC,KAAD;AAAA,SAAYA,KAAK,CAACC,QAAN,GAAiBH,eAAOI,WAAxB,GAAsC,aAAlD;AAAA,CATH,EAUP,UAACF,KAAD;AAAA,SAAYA,KAAK,CAACC,QAAN,GAAiB,aAAjB,GAAiC,SAA7C;AAAA,CAVO,EAqBJE,oBAAUC,KArBN,EAsBKN,eAAOO,KAtBZ,EA2BOP,eAAOO,KA3Bd,EAgCJF,oBAAUG,MAhCN,EAiCKR,eAAOS,UAjCZ,EAqCKT,eAAOU,UArCZ,EAyCKV,eAAOO,KAzCZ,EA6CJF,oBAAUM,KA7CN,EA8CKX,eAAOU,UA9CZ,EA+CNV,eAAOY,WA/CD,EAmDJP,oBAAUG,MAnDN,EAqDKR,eAAOa,WArDZ,EAsDNb,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,QAFlB;AAGE,IAAA,QAAQ,EAAEtC,QAHZ;AAIE,IAAA,KAAK,EAAEuB,KAJT;AAKE,IAAA,IAAI,EAAC,KALP;AAME,qBAAeD,EAAE,KAAKY,QAAQ,CAACK,QANjC;AAOE,IAAA,OAAO,EAAE,mBAAM;AAAA;;AACbJ,MAAAA,GAAG,SAAH,IAAAA,GAAG,WAAH,4BAAAA,GAAG,CAAEK,OAAL,8DAAcC,IAAd;;AACA,UAAId,WAAJ,EAAiB;AACfA,QAAAA,WAAW;AACZ;AACF,KAZH;AAaE,IAAA,GAAG,EAAEQ,GAbP;AAcE,mBAAaP;AAdf,kBAeE,oBAAC,aAAD,qBACA,oBAAC,UAAD,qBACE,kCAAOJ,YAAP,CADF,CADA,EAICC,YAAY,IAAIC,gBAAhB,gBACC,oBAAC,2BAAD,QACGA,gBAAgB,iBAAI,oBAAC,gBAAD;AAAkB,IAAA,IAAI,EAAC;AAAvB,IADvB,EAEGD,YAAY,KAAKiB,SAAjB,iBAA8B,kCAAOjB,YAAP,CAFjC,CADD,GAKGA,YAAY,gBACd,oBAAC,mBAAD,qBACE,kCAAOA,YAAP,CADF,CADc,gBAKd,yCAdF,CAfF,eAgCE,oBAAC,kBAAD,QACGI,mBAAmB,iBAAI,oBAAC,gCAAD;AAAiB,IAAA,MAAM,EAAC,iBAAxB;AAA0C,IAAA,IAAI,EAAEC,IAAhD;AAAsD,IAAA,OAAO,EAAEG;AAA/D,IAD1B,CAhCF,CADF;AAsCD,CA1CD;;;AAlJEjC,EAAAA,Q;AACAwB,EAAAA,Y;AACAC,EAAAA,Y;AAEAE,EAAAA,W;AACAC,EAAAA,M;AACAC,EAAAA,mB;AAEAI,EAAAA,O,4BAAU,U,EAAa,U;;eAsLVZ,O","sourcesContent":["import * as React from 'react';\nimport { NavLink, NavLinkProps, useLocation } from 'react-router-dom';\nimport styled from 'styled-components';\nimport { NotificationDot } from '../NotificationDot';\nimport { BaseProps } from '../icons';\nimport { Size } from '../types';\nimport { COLORS } from '../styles';\nimport {Z_INDEXES} from '../styles/z-indexes';\n\ntype TabLinkProps = {\n disabled?: boolean;\n requiredLine: string;\n optionalLine?: string;\n OptionalLineIcon?: React.FunctionComponent<BaseProps>;\n onLinkClick?: () => void;\n testId?: string;\n showNotificationDot?: boolean;\n size?: Size.Small | Size.Medium | Size.Large;\n variant?: 'positive' | 'critical';\n} & NavLinkProps;\n\ntype StyledTabLinkProps = {\n disabled?: boolean;\n exact: boolean;\n};\n\nconst StyledTabLink = styled(NavLink)<StyledTabLinkProps>`\n display: flex;\n flex-direction: row;\n align-items: center;\n\n font-size: 16px;\n line-height: 120%;\n color: ${COLORS.neutral_600};\n\n background-color: ${(props) => (props.disabled ? COLORS.neutral_100 : 'transparent')};\n cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};\n border-left: 1px solid transparent;\n text-decoration: none;\n position: relative;\n border-radius: 2px;\n\n &:not(:last-child) {\n margin-bottom: 4px;\n }\n\n &:focus {\n z-index: ${Z_INDEXES.focus};\n background-color: ${COLORS.white};\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2e7fa1;\n outline: none;\n\n &::after {\n background-color: ${COLORS.white};\n }\n }\n\n &.active {\n z-index: ${Z_INDEXES.active};\n background-color: ${COLORS.neutral_20};\n }\n\n &.active:hover {\n background-color: ${COLORS.primary_20};\n }\n\n &.active:focus {\n background-color: ${COLORS.white};\n }\n\n &:hover {\n z-index: ${Z_INDEXES.hover};\n background-color: ${COLORS.primary_20};\n color: ${COLORS.primary_600};\n }\n\n &:active {\n z-index: ${Z_INDEXES.active};\n box-shadow: none;\n background-color: ${COLORS.primary_100};\n color: ${COLORS.primary_800};\n }\n\n &.active {\n &::after {\n position: absolute;\n content: ' ';\n width: 4px;\n top: 0;\n bottom: 0;\n left: -1px;\n background-color: ${COLORS.primary_500};\n\n border-radius: 2px;\n }\n }\n\n &.active:hover {\n &::after {\n background-color: ${COLORS.primary_600};\n }\n }\n\n &.active:active {\n background-color: ${COLORS.primary_100};\n\n &::after {\n background-color: ${COLORS.primary_800};\n }\n }\n\n &:disabled {\n box-shadow: none;\n background-color: ${COLORS.white};\n\n span {\n color: ${COLORS.neutral_300};\n }\n\n &::after {\n background-color: ${COLORS.white};\n }\n }\n`;\n\nconst OptionalLineWrapperWithIcon = styled.div`\n display: flex;\n flex-direction: row;\n span {\n margin: 0 0 0 4px !important;\n font-size: 12px;\n line-height: 16px;\n }\n`;\n\nconst TopWrapper = styled.div`\n display: flex;\n flex-direction: row;\n span:not(:only-child) {\n width: calc(100% - 32px);\n }\n`;\n\nconst TextContainer = styled.div`\n width: 100%;\n margin: auto 0 auto 16px !important;\n`;\n\nconst StyledNotification = styled.div`\n margin: 0 15px 0 0 !important;\n`;\n\nconst OptionalLineWrapper = styled.div`\n font-size: 12px;\n`;\n\nconst TabLink = ({ to, disabled = false, exact = false, requiredLine, optionalLine, OptionalLineIcon, onLinkClick, testId, showNotificationDot = false, size = Size.Small, variant = 'critical' }: TabLinkProps) => {\n const location = useLocation();\n const ref = React.useRef<any>(null);\n\n return (\n <StyledTabLink\n to={to.toString()}\n activeClassName=\"active\"\n disabled={disabled}\n exact={exact}\n role=\"tab\"\n aria-selected={to === location.pathname}\n onClick={() => {\n ref?.current?.blur();\n if (onLinkClick) {\n onLinkClick();\n }\n }}\n ref={ref}\n data-testid={testId}>\n <TextContainer> \n <TopWrapper>\n <span>{requiredLine}</span> \n </TopWrapper>\n {optionalLine && OptionalLineIcon ? (\n <OptionalLineWrapperWithIcon>\n {OptionalLineIcon && <OptionalLineIcon size=\"16px\" />}\n {optionalLine !== undefined && <span>{optionalLine}</span>}\n </OptionalLineWrapperWithIcon>\n ) : optionalLine ? (\n <OptionalLineWrapper>\n <span>{optionalLine}</span>\n </OptionalLineWrapper>\n ) : (\n <></>\n )}\n </TextContainer>\n <StyledNotification>\n {showNotificationDot && <NotificationDot testId=\"NotificationDot\" size={size} variant={variant} />}\n </StyledNotification>\n </StyledTabLink>\n );\n};\n\nexport default TabLink;\n"],"file":"TabLink.js"}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
if (typeof define === "function" && define.amd) {
|
|
3
|
+
define(["exports", "prop-types", "react", "styled-components", "../types", "../icons", "../styles/typography", "../styles", "../styles/z-indexes"], factory);
|
|
4
|
+
} else if (typeof exports !== "undefined") {
|
|
5
|
+
factory(exports, require("prop-types"), require("react"), require("styled-components"), require("../types"), require("../icons"), require("../styles/typography"), require("../styles"), require("../styles/z-indexes"));
|
|
6
|
+
} else {
|
|
7
|
+
var mod = {
|
|
8
|
+
exports: {}
|
|
9
|
+
};
|
|
10
|
+
factory(mod.exports, global.propTypes, global.react, global.styledComponents, global.types, global.icons, global.typography, global.styles, global.zIndexes);
|
|
11
|
+
global.undefined = mod.exports;
|
|
12
|
+
}
|
|
13
|
+
})(this, function (exports, _propTypes, _react, _styledComponents, _types, _icons, _typography, _styles, _zIndexes) {
|
|
14
|
+
"use strict";
|
|
15
|
+
|
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
19
|
+
exports.ContentAccordion = undefined;
|
|
20
|
+
|
|
21
|
+
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
22
|
+
|
|
23
|
+
var _react2 = _interopRequireDefault(_react);
|
|
24
|
+
|
|
25
|
+
var _styledComponents2 = _interopRequireDefault(_styledComponents);
|
|
26
|
+
|
|
27
|
+
function _interopRequireDefault(obj) {
|
|
28
|
+
return obj && obj.__esModule ? obj : {
|
|
29
|
+
default: obj
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const ContentAccordionWrapper = _styledComponents2.default.div`
|
|
34
|
+
width: 100%;
|
|
35
|
+
position: relative;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
.content-accordion-item {
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
border-top: 1px solid ${_styles.COLORS.neutral_100};
|
|
42
|
+
|
|
43
|
+
.item-header {
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
min-height: 48px;
|
|
48
|
+
color: ${_styles.COLORS.neutral_600};
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
|
|
51
|
+
&:hover {
|
|
52
|
+
color: ${_styles.COLORS.primary_700};
|
|
53
|
+
background-color: ${_styles.COLORS.primary_20};
|
|
54
|
+
z-index: ${_zIndexes.Z_INDEXES.hover};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&:focus {
|
|
58
|
+
box-shadow: 0 4px 12px rgba(46, 127, 161, 0.25), 0 0 8px #2E7FA1;
|
|
59
|
+
background-color: ${_styles.COLORS.white};
|
|
60
|
+
z-index: ${_zIndexes.Z_INDEXES.focus};
|
|
61
|
+
outline: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&:active {
|
|
65
|
+
color: ${_styles.COLORS.primary_800};
|
|
66
|
+
background-color: ${_styles.COLORS.primary_100};
|
|
67
|
+
box-shadow: none;
|
|
68
|
+
z-index: ${_zIndexes.Z_INDEXES.active};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.item-header-icon,
|
|
72
|
+
.item-header-icon svg {
|
|
73
|
+
width: 24px;
|
|
74
|
+
height: 24px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.item-header-text {
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.item-content {
|
|
82
|
+
display: none;
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
|
|
85
|
+
.item-content-header {
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.item-content-body {
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.item-content-footer {
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&.active {
|
|
98
|
+
.item-content {
|
|
99
|
+
display: flex;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&.disabled {
|
|
104
|
+
.item-header {
|
|
105
|
+
color: ${_styles.COLORS.neutral_300};
|
|
106
|
+
cursor: not-allowed;
|
|
107
|
+
pointer-events: none;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.content-accordion-item:last-child {
|
|
113
|
+
border-bottom: 1px solid ${_styles.COLORS.neutral_100};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&.small {
|
|
117
|
+
min-width: 320px;
|
|
118
|
+
max-width: 528px;
|
|
119
|
+
|
|
120
|
+
.item-header {
|
|
121
|
+
gap: 8px;
|
|
122
|
+
padding: 0 8px;
|
|
123
|
+
${(0, _typography.ComponentSStyling)(_typography.ComponentTextStyle.Regular, null)}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.item-content {
|
|
127
|
+
padding: 0 8px 16px 40px;
|
|
128
|
+
gap: 8px;
|
|
129
|
+
|
|
130
|
+
.item-content-header {
|
|
131
|
+
${(0, _typography.ComponentSStyling)(_typography.ComponentTextStyle.Bold, null)}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.item-content-body {
|
|
135
|
+
${(0, _typography.ComponentSStyling)(_typography.ComponentTextStyle.Regular, null)}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
&.medium {
|
|
142
|
+
min-width: 344px;
|
|
143
|
+
max-width: 584px;
|
|
144
|
+
|
|
145
|
+
.item-header {
|
|
146
|
+
gap: 12px;
|
|
147
|
+
padding: 0 12px;
|
|
148
|
+
${(0, _typography.ComponentMStyling)(_typography.ComponentTextStyle.Regular, null)}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.item-content {
|
|
152
|
+
padding: 8px 12px 24px 48px;
|
|
153
|
+
gap: 12px;
|
|
154
|
+
|
|
155
|
+
.item-content-header {
|
|
156
|
+
${(0, _typography.ComponentMStyling)(_typography.ComponentTextStyle.Bold, null)}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.item-content-body {
|
|
160
|
+
${(0, _typography.ComponentMStyling)(_typography.ComponentTextStyle.Regular, null)}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
&.large {
|
|
167
|
+
min-width: 384px;
|
|
168
|
+
max-width: 656px;
|
|
169
|
+
|
|
170
|
+
.item-header {
|
|
171
|
+
gap: 16px;
|
|
172
|
+
padding: 0 16px;
|
|
173
|
+
${(0, _typography.ComponentLStyling)(_typography.ComponentTextStyle.Regular, null)}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.item-content {
|
|
177
|
+
padding: 16px 16px 32px 56px;
|
|
178
|
+
gap: 16px;
|
|
179
|
+
|
|
180
|
+
.item-content-header {
|
|
181
|
+
${(0, _typography.ComponentLStyling)(_typography.ComponentTextStyle.Bold, null)}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.item-content-body {
|
|
185
|
+
${(0, _typography.ComponentLStyling)(_typography.ComponentTextStyle.Regular, null)}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
`;
|
|
190
|
+
|
|
191
|
+
const ContentAccordion = exports.ContentAccordion = props => {
|
|
192
|
+
const [opened, setOpened] = _react2.default.useState([]);
|
|
193
|
+
|
|
194
|
+
_react2.default.useEffect(() => {
|
|
195
|
+
if (props.multi) {
|
|
196
|
+
setOpened(props.items.filter(item => item.active).map(item => item.key));
|
|
197
|
+
} else {
|
|
198
|
+
let active = props.items.find(item => !!item.active)?.key;
|
|
199
|
+
|
|
200
|
+
if (active) {
|
|
201
|
+
setOpened([active]);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}, [props.items, props.multi]);
|
|
205
|
+
|
|
206
|
+
const onItemClick = item => {
|
|
207
|
+
if (item.disabled) return;
|
|
208
|
+
|
|
209
|
+
if (opened.includes(item.key)) {
|
|
210
|
+
setOpened(opened.filter(key => key !== item.key));
|
|
211
|
+
} else {
|
|
212
|
+
if (props.multi) {
|
|
213
|
+
setOpened([...opened, item.key]);
|
|
214
|
+
} else {
|
|
215
|
+
setOpened([item.key]);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
const renderItem = item => {
|
|
221
|
+
const isActive = opened.includes(item.key);
|
|
222
|
+
return /*#__PURE__*/_react2.default.createElement("div", {
|
|
223
|
+
key: item.key,
|
|
224
|
+
id: `item_${item.key}`,
|
|
225
|
+
className: 'content-accordion-item'.concat(isActive ? ' active' : '').concat(item.disabled ? ' disabled' : '')
|
|
226
|
+
}, /*#__PURE__*/_react2.default.createElement("div", {
|
|
227
|
+
className: 'item-header',
|
|
228
|
+
tabIndex: !item.disabled ? 0 : undefined,
|
|
229
|
+
onMouseDown: e => e.preventDefault(),
|
|
230
|
+
onClick: () => !item.disabled && onItemClick(item),
|
|
231
|
+
onKeyPress: event => event.key === 'Enter' && onItemClick(item)
|
|
232
|
+
}, /*#__PURE__*/_react2.default.createElement("div", {
|
|
233
|
+
className: 'item-header-icon'
|
|
234
|
+
}, props.multi ? isActive ? /*#__PURE__*/_react2.default.createElement(_icons.SystemIcons.Minus, null) : /*#__PURE__*/_react2.default.createElement(_icons.SystemIcons.Plus, null) : isActive ? /*#__PURE__*/_react2.default.createElement(_icons.SystemIcons.ChevronDown, null) : /*#__PURE__*/_react2.default.createElement(_icons.SystemIcons.ChevronRight, null)), /*#__PURE__*/_react2.default.createElement("div", {
|
|
235
|
+
className: 'item-header-text'
|
|
236
|
+
}, item.title)), /*#__PURE__*/_react2.default.createElement("div", {
|
|
237
|
+
className: 'item-content'
|
|
238
|
+
}, item.header && /*#__PURE__*/_react2.default.createElement("div", {
|
|
239
|
+
className: 'item-content-header'
|
|
240
|
+
}, item.header), /*#__PURE__*/_react2.default.createElement("div", {
|
|
241
|
+
className: 'item-content-body'
|
|
242
|
+
}, item.body), item.footer && /*#__PURE__*/_react2.default.createElement("div", {
|
|
243
|
+
className: 'item-content-footer'
|
|
244
|
+
}, item.footer)));
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
return /*#__PURE__*/_react2.default.createElement(ContentAccordionWrapper, {
|
|
248
|
+
className: 'content-accordion'.concat(` ${props.size ?? _types.Size.Medium}`)
|
|
249
|
+
}, props.items.map(item => renderItem(item)));
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
ContentAccordion.propTypes = {
|
|
253
|
+
items: _propTypes2.default.arrayOf(_propTypes2.default.shape({
|
|
254
|
+
key: _propTypes2.default.string.isRequired,
|
|
255
|
+
title: _propTypes2.default.string.isRequired,
|
|
256
|
+
header: _propTypes2.default.string,
|
|
257
|
+
body: _propTypes2.default.any.isRequired,
|
|
258
|
+
footer: _propTypes2.default.any,
|
|
259
|
+
disabled: _propTypes2.default.bool,
|
|
260
|
+
active: _propTypes2.default.bool
|
|
261
|
+
})).isRequired,
|
|
262
|
+
multi: _propTypes2.default.bool
|
|
263
|
+
};
|
|
264
|
+
exports.default = ContentAccordion;
|
|
265
|
+
});
|
|
266
|
+
//# sourceMappingURL=ContentAccordion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/Accordion/ContentAccordion.tsx"],"names":["ContentAccordionWrapper","styled","div","COLORS","neutral_100","neutral_600","primary_700","primary_20","Z_INDEXES","hover","white","focus","primary_800","primary_100","active","neutral_300","ComponentSStyling","ComponentTextStyle","ComponentMStyling","ComponentLStyling","key","title","header","body","footer","disabled","items","multi","ContentAccordion","props","React","setOpened","item","onItemClick","opened","renderItem","isActive","e","event","Size","Medium"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,QAAMA,uBAAuB,GAAGC,2BAAOC,GAAI;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4BC,eAAOC,WAAY;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA,eAAeD,eAAOE,WAAY;AAClC;AACA;AACA;AACA,iBAAiBF,eAAOG,WAAY;AACpC,4BAA4BH,eAAOI,UAAW;AAC9C,mBAAmBC,oBAAUC,KAAM;AACnC;AACA;AACA;AACA;AACA,4BAA4BN,eAAOO,KAAM;AACzC,mBAAmBF,oBAAUG,KAAM;AACnC;AACA;AACA;AACA;AACA,iBAAiBR,eAAOS,WAAY;AACpC,4BAA4BT,eAAOU,WAAY;AAC/C;AACA,mBAAmBL,oBAAUM,MAAO;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiBX,eAAOY,WAAY;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+BZ,eAAOC,WAAY;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQY,mCAAkBC,+BAAD,OAAjBD,EAAiB,IAAjBA,CAAoD;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAUA,mCAAkBC,+BAAD,IAAjBD,EAAiB,IAAjBA,CAAiD;AAC3D;AACA;AACA;AACA,UAAUA,mCAAkBC,+BAAD,OAAjBD,EAAiB,IAAjBA,CAAoD;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQE,mCAAkBD,+BAAD,OAAjBC,EAAiB,IAAjBA,CAAoD;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAUA,mCAAkBD,+BAAD,IAAjBC,EAAiB,IAAjBA,CAAiD;AAC3D;AACA;AACA;AACA,UAAUA,mCAAkBD,+BAAD,OAAjBC,EAAiB,IAAjBA,CAAoD;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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AAAA,M;AACAC,MAAAA,Q;AACAX,MAAAA,M;;AAKAa,IAAAA,K;;oBAuFF,gB","sourcesContent":["import React from 'react'\nimport styled from 'styled-components';\nimport {Size} from '../types';\nimport {SystemIcons} from '../icons';\nimport {ComponentLStyling, ComponentMStyling, ComponentSStyling, ComponentTextStyle} from '../styles/typography';\nimport {COLORS} from '../styles';\nimport {Z_INDEXES} from '../styles/z-indexes';\n\n\nconst ContentAccordionWrapper = styled.div`\n width: 100%;\n position: relative;\n\n\n .content-accordion-item {\n display: flex;\n flex-direction: column;\n border-top: 1px solid ${COLORS.neutral_100};\n\n .item-header {\n display: flex;\n align-items: center;\n box-sizing: border-box;\n min-height: 48px;\n color: ${COLORS.neutral_600};\n cursor: pointer;\n\n &:hover {\n color: ${COLORS.primary_700};\n background-color: ${COLORS.primary_20};\n z-index: ${Z_INDEXES.hover};\n }\n\n &:focus {\n box-shadow: 0 4px 12px rgba(46, 127, 161, 0.25), 0 0 8px #2E7FA1;\n background-color: ${COLORS.white};\n z-index: ${Z_INDEXES.focus};\n outline: none;\n }\n\n &:active {\n color: ${COLORS.primary_800};\n background-color: ${COLORS.primary_100};\n box-shadow: none;\n z-index: ${Z_INDEXES.active};\n }\n\n .item-header-icon,\n .item-header-icon svg {\n width: 24px;\n height: 24px;\n }\n\n .item-header-text {\n }\n }\n\n .item-content {\n display: none;\n flex-direction: column;\n\n .item-content-header {\n\n }\n\n .item-content-body {\n\n }\n\n .item-content-footer {\n }\n }\n\n &.active {\n .item-content {\n display: flex;\n }\n }\n\n &.disabled {\n .item-header {\n color: ${COLORS.neutral_300};\n cursor: not-allowed;\n pointer-events: none;\n }\n }\n }\n\n .content-accordion-item:last-child {\n border-bottom: 1px solid ${COLORS.neutral_100};\n }\n\n &.small {\n min-width: 320px;\n max-width: 528px;\n\n .item-header {\n gap: 8px;\n padding: 0 8px;\n ${ComponentSStyling(ComponentTextStyle.Regular, null)}\n }\n\n .item-content {\n padding: 0 8px 16px 40px;\n gap: 8px;\n\n .item-content-header {\n ${ComponentSStyling(ComponentTextStyle.Bold, null)}\n }\n\n .item-content-body {\n ${ComponentSStyling(ComponentTextStyle.Regular, null)}\n }\n }\n }\n\n\n &.medium {\n min-width: 344px;\n max-width: 584px;\n\n .item-header {\n gap: 12px;\n padding: 0 12px;\n ${ComponentMStyling(ComponentTextStyle.Regular, null)}\n }\n\n .item-content {\n padding: 8px 12px 24px 48px;\n gap: 12px;\n\n .item-content-header {\n ${ComponentMStyling(ComponentTextStyle.Bold, null)}\n }\n\n .item-content-body {\n ${ComponentMStyling(ComponentTextStyle.Regular, null)}\n }\n\n }\n }\n\n &.large {\n min-width: 384px;\n max-width: 656px;\n\n .item-header {\n gap: 16px;\n padding: 0 16px;\n ${ComponentLStyling(ComponentTextStyle.Regular, null)}\n }\n\n .item-content {\n padding: 16px 16px 32px 56px;\n gap: 16px;\n\n .item-content-header {\n ${ComponentLStyling(ComponentTextStyle.Bold, null)}\n }\n\n .item-content-body {\n ${ComponentLStyling(ComponentTextStyle.Regular, null)}\n }\n }\n }\n`;\n\nexport interface ContentAccordionItem {\n key: string;\n title: string;\n header?: string;\n body: any;\n footer?: any;\n disabled?: boolean;\n active?: boolean;\n}\n\nexport interface ContentAccordionProps {\n items: ContentAccordionItem[];\n multi?: boolean;\n size?: Size;\n}\n\nexport const ContentAccordion: React.FunctionComponent<ContentAccordionProps> = (props) => {\n\n const [opened, setOpened] = React.useState<string[]>([]);\n\n React.useEffect(() => {\n if (props.multi) {\n setOpened(props.items.filter(item => item.active).map(item => item.key));\n } else {\n let active = props.items.find(item => !!item.active)?.key;\n if (active) {\n setOpened([active]);\n }\n }\n }, [props.items, props.multi]);\n\n const onItemClick = (item: ContentAccordionItem) => {\n if (item.disabled) return;\n if (opened.includes(item.key)) {\n setOpened(opened.filter(key => key !== item.key));\n } else {\n if (props.multi) {\n setOpened([...opened, item.key]);\n } else {\n setOpened([item.key]);\n }\n }\n }\n\n const renderItem = (item: ContentAccordionItem) => {\n const isActive = opened.includes(item.key);\n\n return (\n <div key={item.key}\n id={`item_${item.key}`}\n className={'content-accordion-item'.concat(isActive ? ' active' : '').concat(item.disabled ? ' disabled' : '')}>\n <div className={'item-header'}\n tabIndex={!item.disabled ? 0 : undefined}\n onMouseDown={e => e.preventDefault()}\n onClick={() => !item.disabled && onItemClick(item)}\n onKeyPress={event => event.key === 'Enter' && onItemClick(item)}>\n <div className={'item-header-icon'}>\n {\n props.multi\n ? isActive\n ? <SystemIcons.Minus/>\n : <SystemIcons.Plus/>\n : isActive\n ? <SystemIcons.ChevronDown/>\n : <SystemIcons.ChevronRight/>\n }\n </div>\n <div className={'item-header-text'}>\n {item.title}\n </div>\n </div>\n <div className={'item-content'}>\n {\n item.header &&\n <div className={'item-content-header'}>\n {item.header}\n </div>\n }\n <div className={'item-content-body'}>\n {item.body}\n </div>\n {\n item.footer &&\n <div className={'item-content-footer'}>\n {item.footer}\n </div>\n }\n </div>\n </div>\n );\n }\n\n return (\n <ContentAccordionWrapper className={'content-accordion'.concat(` ${props.size ?? Size.Medium}`)}>\n {props.items.map(item => renderItem(item))}\n </ContentAccordionWrapper>\n );\n};\n\nexport default ContentAccordion;\n"],"file":"ContentAccordion.js"}
|