@entur/expand 3.6.13-beta.0 → 3.6.13-beta.10
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/Accordion.d.ts +17 -0
- package/dist/AccordionItem.d.ts +16 -0
- package/dist/BaseExpand.d.ts +11 -0
- package/dist/BaseExpandablePanel.d.ts +20 -0
- package/dist/ExpandArrow.d.ts +13 -0
- package/dist/ExpandablePanel.d.ts +17 -0
- package/dist/ExpandableText.d.ts +25 -0
- package/dist/ExpandableTextButton.d.ts +14 -0
- package/dist/expand.cjs.development.js +259 -0
- package/dist/expand.cjs.development.js.map +1 -0
- package/dist/expand.cjs.production.min.js +2 -0
- package/dist/expand.cjs.production.min.js.map +1 -0
- package/dist/expand.esm.js +218 -837
- package/dist/expand.esm.js.map +1 -1
- package/dist/index.d.ts +8 -121
- package/dist/index.js +8 -0
- package/dist/styles.css +97 -87
- package/package.json +14 -32
- package/dist/expand.cjs.js +0 -867
- package/dist/expand.cjs.js.map +0 -1
package/dist/expand.esm.js
CHANGED
|
@@ -1,867 +1,248 @@
|
|
|
1
|
-
import { useRandomId, warnAboutMissingStyles } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { Heading5, SubParagraph, Paragraph, Heading2, Heading3, Heading4 } from
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return
|
|
1
|
+
import { useRandomId, warnAboutMissingStyles } from '@entur/utils';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { Heading5, SubParagraph, Paragraph, Heading2, Heading3, Heading4 } from '@entur/typography';
|
|
5
|
+
import { UnmountClosed } from 'react-collapse';
|
|
6
|
+
import { DownArrowIcon } from '@entur/icons';
|
|
7
|
+
|
|
8
|
+
function _extends() {
|
|
9
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
10
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
11
|
+
var t = arguments[e];
|
|
12
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
13
|
+
}
|
|
14
|
+
return n;
|
|
15
|
+
}, _extends.apply(null, arguments);
|
|
16
|
+
}
|
|
17
|
+
function _objectDestructuringEmpty(t) {
|
|
18
|
+
if (null == t) throw new TypeError("Cannot destructure " + t);
|
|
19
|
+
}
|
|
20
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
21
|
+
if (null == r) return {};
|
|
22
|
+
var t = {};
|
|
23
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
24
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
25
|
+
t[n] = r[n];
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var AccordionContext = /*#__PURE__*/React.createContext(null);
|
|
31
|
+
var Accordion = function Accordion(_ref) {
|
|
32
|
+
var rest = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
33
|
+
var currentlyOpenState = React.useState(null);
|
|
34
|
+
return React.createElement(AccordionContext.Provider, _extends({
|
|
35
|
+
value: currentlyOpenState
|
|
36
|
+
}, rest));
|
|
10
37
|
};
|
|
11
|
-
|
|
12
|
-
|
|
38
|
+
var useAccordion = function useAccordion(_ref2) {
|
|
39
|
+
var id = _ref2.id,
|
|
40
|
+
defaultOpen = _ref2.defaultOpen;
|
|
41
|
+
var contextValue = React.useContext(AccordionContext);
|
|
13
42
|
if (!contextValue) {
|
|
14
|
-
throw new Error(
|
|
43
|
+
throw new Error('You need to wrap your AccordionItem inside an Accordion');
|
|
15
44
|
}
|
|
16
|
-
|
|
17
|
-
|
|
45
|
+
var openId = contextValue[0],
|
|
46
|
+
setOpenId = contextValue[1];
|
|
47
|
+
React.useEffect(function () {
|
|
18
48
|
if (defaultOpen) {
|
|
19
49
|
setOpenId(id);
|
|
20
50
|
}
|
|
21
51
|
}, [defaultOpen, id, setOpenId]);
|
|
22
|
-
|
|
52
|
+
var isOpen = openId === id;
|
|
23
53
|
return {
|
|
24
|
-
isOpen,
|
|
25
|
-
toggle: ()
|
|
54
|
+
isOpen: isOpen,
|
|
55
|
+
toggle: function toggle() {
|
|
56
|
+
return setOpenId(isOpen ? null : id);
|
|
57
|
+
}
|
|
26
58
|
};
|
|
27
59
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*/
|
|
37
|
-
var hasRequiredClassnames;
|
|
38
|
-
function requireClassnames() {
|
|
39
|
-
if (hasRequiredClassnames) return classnames.exports;
|
|
40
|
-
hasRequiredClassnames = 1;
|
|
41
|
-
(function(module) {
|
|
42
|
-
(function() {
|
|
43
|
-
var hasOwn = {}.hasOwnProperty;
|
|
44
|
-
function classNames2() {
|
|
45
|
-
var classes = "";
|
|
46
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
47
|
-
var arg = arguments[i];
|
|
48
|
-
if (arg) {
|
|
49
|
-
classes = appendClass(classes, parseValue(arg));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return classes;
|
|
53
|
-
}
|
|
54
|
-
function parseValue(arg) {
|
|
55
|
-
if (typeof arg === "string" || typeof arg === "number") {
|
|
56
|
-
return arg;
|
|
57
|
-
}
|
|
58
|
-
if (typeof arg !== "object") {
|
|
59
|
-
return "";
|
|
60
|
-
}
|
|
61
|
-
if (Array.isArray(arg)) {
|
|
62
|
-
return classNames2.apply(null, arg);
|
|
63
|
-
}
|
|
64
|
-
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
65
|
-
return arg.toString();
|
|
66
|
-
}
|
|
67
|
-
var classes = "";
|
|
68
|
-
for (var key in arg) {
|
|
69
|
-
if (hasOwn.call(arg, key) && arg[key]) {
|
|
70
|
-
classes = appendClass(classes, key);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return classes;
|
|
74
|
-
}
|
|
75
|
-
function appendClass(value, newClass) {
|
|
76
|
-
if (!newClass) {
|
|
77
|
-
return value;
|
|
78
|
-
}
|
|
79
|
-
if (value) {
|
|
80
|
-
return value + " " + newClass;
|
|
81
|
-
}
|
|
82
|
-
return value + newClass;
|
|
83
|
-
}
|
|
84
|
-
if (module.exports) {
|
|
85
|
-
classNames2.default = classNames2;
|
|
86
|
-
module.exports = classNames2;
|
|
87
|
-
} else {
|
|
88
|
-
window.classNames = classNames2;
|
|
89
|
-
}
|
|
90
|
-
})();
|
|
91
|
-
})(classnames);
|
|
92
|
-
return classnames.exports;
|
|
93
|
-
}
|
|
94
|
-
var classnamesExports = requireClassnames();
|
|
95
|
-
const classNames = /* @__PURE__ */ getDefaultExportFromCjs(classnamesExports);
|
|
96
|
-
var Collapse = {};
|
|
97
|
-
var hasRequiredCollapse;
|
|
98
|
-
function requireCollapse() {
|
|
99
|
-
if (hasRequiredCollapse) return Collapse;
|
|
100
|
-
hasRequiredCollapse = 1;
|
|
101
|
-
function _typeof(obj) {
|
|
102
|
-
"@babel/helpers - typeof";
|
|
103
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
104
|
-
_typeof = function _typeof2(obj2) {
|
|
105
|
-
return typeof obj2;
|
|
106
|
-
};
|
|
107
|
-
} else {
|
|
108
|
-
_typeof = function _typeof2(obj2) {
|
|
109
|
-
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
return _typeof(obj);
|
|
113
|
-
}
|
|
114
|
-
Object.defineProperty(Collapse, "__esModule", {
|
|
115
|
-
value: true
|
|
116
|
-
});
|
|
117
|
-
Collapse.Collapse = void 0;
|
|
118
|
-
var _react = _interopRequireDefault(React);
|
|
119
|
-
function _interopRequireDefault(obj) {
|
|
120
|
-
return obj && obj.__esModule ? obj : { "default": obj };
|
|
121
|
-
}
|
|
122
|
-
function _classCallCheck(instance, Constructor) {
|
|
123
|
-
if (!(instance instanceof Constructor)) {
|
|
124
|
-
throw new TypeError("Cannot call a class as a function");
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function _defineProperties(target, props) {
|
|
128
|
-
for (var i = 0; i < props.length; i++) {
|
|
129
|
-
var descriptor = props[i];
|
|
130
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
131
|
-
descriptor.configurable = true;
|
|
132
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
133
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
137
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
138
|
-
return Constructor;
|
|
139
|
-
}
|
|
140
|
-
function _inherits(subClass, superClass) {
|
|
141
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
142
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
143
|
-
}
|
|
144
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
|
|
145
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
146
|
-
}
|
|
147
|
-
function _setPrototypeOf(o, p) {
|
|
148
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
|
|
149
|
-
o2.__proto__ = p2;
|
|
150
|
-
return o2;
|
|
151
|
-
};
|
|
152
|
-
return _setPrototypeOf(o, p);
|
|
153
|
-
}
|
|
154
|
-
function _createSuper(Derived) {
|
|
155
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
156
|
-
return function _createSuperInternal() {
|
|
157
|
-
var Super = _getPrototypeOf(Derived), result;
|
|
158
|
-
if (hasNativeReflectConstruct) {
|
|
159
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
160
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
161
|
-
} else {
|
|
162
|
-
result = Super.apply(this, arguments);
|
|
163
|
-
}
|
|
164
|
-
return _possibleConstructorReturn(this, result);
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
function _possibleConstructorReturn(self, call) {
|
|
168
|
-
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
169
|
-
return call;
|
|
170
|
-
} else if (call !== void 0) {
|
|
171
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
172
|
-
}
|
|
173
|
-
return _assertThisInitialized(self);
|
|
174
|
-
}
|
|
175
|
-
function _assertThisInitialized(self) {
|
|
176
|
-
if (self === void 0) {
|
|
177
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
178
|
-
}
|
|
179
|
-
return self;
|
|
180
|
-
}
|
|
181
|
-
function _isNativeReflectConstruct() {
|
|
182
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
183
|
-
if (Reflect.construct.sham) return false;
|
|
184
|
-
if (typeof Proxy === "function") return true;
|
|
185
|
-
try {
|
|
186
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
187
|
-
}));
|
|
188
|
-
return true;
|
|
189
|
-
} catch (e) {
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
function _getPrototypeOf(o) {
|
|
194
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
|
|
195
|
-
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
196
|
-
};
|
|
197
|
-
return _getPrototypeOf(o);
|
|
198
|
-
}
|
|
199
|
-
function _defineProperty(obj, key, value) {
|
|
200
|
-
if (key in obj) {
|
|
201
|
-
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
202
|
-
} else {
|
|
203
|
-
obj[key] = value;
|
|
204
|
-
}
|
|
205
|
-
return obj;
|
|
206
|
-
}
|
|
207
|
-
var Collapse$1 = /* @__PURE__ */ function(_React$Component) {
|
|
208
|
-
_inherits(Collapse2, _React$Component);
|
|
209
|
-
var _super = _createSuper(Collapse2);
|
|
210
|
-
function Collapse2(props) {
|
|
211
|
-
var _this;
|
|
212
|
-
_classCallCheck(this, Collapse2);
|
|
213
|
-
_this = _super.call(this, props);
|
|
214
|
-
_defineProperty(_assertThisInitialized(_this), "timeout", void 0);
|
|
215
|
-
_defineProperty(_assertThisInitialized(_this), "container", void 0);
|
|
216
|
-
_defineProperty(_assertThisInitialized(_this), "content", void 0);
|
|
217
|
-
_defineProperty(_assertThisInitialized(_this), "onResize", function() {
|
|
218
|
-
clearTimeout(_this.timeout);
|
|
219
|
-
if (!_this.container || !_this.content) {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
var _this$props = _this.props, isOpened = _this$props.isOpened, checkTimeout = _this$props.checkTimeout;
|
|
223
|
-
var containerHeight = Math.floor(_this.container.clientHeight);
|
|
224
|
-
var contentHeight = Math.floor(_this.content.clientHeight);
|
|
225
|
-
var isFullyOpened = isOpened && Math.abs(contentHeight - containerHeight) <= 1;
|
|
226
|
-
var isFullyClosed = !isOpened && Math.abs(containerHeight) <= 1;
|
|
227
|
-
if (isFullyOpened || isFullyClosed) {
|
|
228
|
-
_this.onRest({
|
|
229
|
-
isFullyOpened,
|
|
230
|
-
isFullyClosed,
|
|
231
|
-
isOpened,
|
|
232
|
-
containerHeight,
|
|
233
|
-
contentHeight
|
|
234
|
-
});
|
|
235
|
-
} else {
|
|
236
|
-
_this.onWork({
|
|
237
|
-
isFullyOpened,
|
|
238
|
-
isFullyClosed,
|
|
239
|
-
isOpened,
|
|
240
|
-
containerHeight,
|
|
241
|
-
contentHeight
|
|
242
|
-
});
|
|
243
|
-
_this.timeout = setTimeout(function() {
|
|
244
|
-
return _this.onResize();
|
|
245
|
-
}, checkTimeout);
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
_defineProperty(_assertThisInitialized(_this), "onRest", function(_ref) {
|
|
249
|
-
var isFullyOpened = _ref.isFullyOpened, isFullyClosed = _ref.isFullyClosed, isOpened = _ref.isOpened, containerHeight = _ref.containerHeight, contentHeight = _ref.contentHeight;
|
|
250
|
-
if (!_this.container || !_this.content) {
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
var hasOpened = isOpened && _this.container.style.height === "".concat(contentHeight, "px");
|
|
254
|
-
var hasClosed = !isOpened && _this.container.style.height === "0px";
|
|
255
|
-
if (hasOpened || hasClosed) {
|
|
256
|
-
_this.container.style.overflow = isOpened ? "initial" : "hidden";
|
|
257
|
-
_this.container.style.height = isOpened ? "auto" : "0px";
|
|
258
|
-
var onRest = _this.props.onRest;
|
|
259
|
-
if (onRest) {
|
|
260
|
-
onRest({
|
|
261
|
-
isFullyOpened,
|
|
262
|
-
isFullyClosed,
|
|
263
|
-
isOpened,
|
|
264
|
-
containerHeight,
|
|
265
|
-
contentHeight
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
_defineProperty(_assertThisInitialized(_this), "onWork", function(_ref2) {
|
|
271
|
-
var isFullyOpened = _ref2.isFullyOpened, isFullyClosed = _ref2.isFullyClosed, isOpened = _ref2.isOpened, containerHeight = _ref2.containerHeight, contentHeight = _ref2.contentHeight;
|
|
272
|
-
if (!_this.container || !_this.content) {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
var isOpenining = isOpened && _this.container.style.height === "".concat(contentHeight, "px");
|
|
276
|
-
var isClosing = !isOpened && _this.container.style.height === "0px";
|
|
277
|
-
if (isOpenining || isClosing) {
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
_this.container.style.overflow = "hidden";
|
|
281
|
-
_this.container.style.height = isOpened ? "".concat(contentHeight, "px") : "0px";
|
|
282
|
-
var onWork = _this.props.onWork;
|
|
283
|
-
if (onWork) {
|
|
284
|
-
onWork({
|
|
285
|
-
isFullyOpened,
|
|
286
|
-
isFullyClosed,
|
|
287
|
-
isOpened,
|
|
288
|
-
containerHeight,
|
|
289
|
-
contentHeight
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
_defineProperty(_assertThisInitialized(_this), "onRefContainer", function(container) {
|
|
294
|
-
_this.container = container;
|
|
295
|
-
});
|
|
296
|
-
_defineProperty(_assertThisInitialized(_this), "onRefContent", function(content) {
|
|
297
|
-
_this.content = content;
|
|
298
|
-
});
|
|
299
|
-
if (props.initialStyle) {
|
|
300
|
-
_this.initialStyle = props.initialStyle;
|
|
301
|
-
} else {
|
|
302
|
-
_this.initialStyle = props.isOpened ? {
|
|
303
|
-
height: "auto",
|
|
304
|
-
overflow: "initial"
|
|
305
|
-
} : {
|
|
306
|
-
height: "0px",
|
|
307
|
-
overflow: "hidden"
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
return _this;
|
|
311
|
-
}
|
|
312
|
-
_createClass(Collapse2, [{
|
|
313
|
-
key: "componentDidMount",
|
|
314
|
-
value: function componentDidMount() {
|
|
315
|
-
this.onResize();
|
|
316
|
-
}
|
|
317
|
-
}, {
|
|
318
|
-
key: "shouldComponentUpdate",
|
|
319
|
-
value: function shouldComponentUpdate(nextProps) {
|
|
320
|
-
var _this$props2 = this.props, theme = _this$props2.theme, isOpened = _this$props2.isOpened, children = _this$props2.children;
|
|
321
|
-
return children !== nextProps.children || isOpened !== nextProps.isOpened || Object.keys(theme).some(function(c) {
|
|
322
|
-
return theme[c] !== nextProps.theme[c];
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
}, {
|
|
326
|
-
key: "getSnapshotBeforeUpdate",
|
|
327
|
-
value: function getSnapshotBeforeUpdate() {
|
|
328
|
-
if (!this.container || !this.content) {
|
|
329
|
-
return null;
|
|
330
|
-
}
|
|
331
|
-
if (this.container.style.height === "auto") {
|
|
332
|
-
var contentHeight = this.content.clientHeight;
|
|
333
|
-
this.container.style.height = "".concat(contentHeight, "px");
|
|
334
|
-
}
|
|
335
|
-
return null;
|
|
336
|
-
}
|
|
337
|
-
}, {
|
|
338
|
-
key: "componentDidUpdate",
|
|
339
|
-
value: function componentDidUpdate() {
|
|
340
|
-
this.onResize();
|
|
341
|
-
}
|
|
342
|
-
}, {
|
|
343
|
-
key: "componentWillUnmount",
|
|
344
|
-
value: function componentWillUnmount() {
|
|
345
|
-
clearTimeout(this.timeout);
|
|
346
|
-
}
|
|
347
|
-
}, {
|
|
348
|
-
key: "render",
|
|
349
|
-
value: function render() {
|
|
350
|
-
var _this$props3 = this.props, theme = _this$props3.theme, children = _this$props3.children, isOpened = _this$props3.isOpened;
|
|
351
|
-
return /* @__PURE__ */ _react["default"].createElement("div", {
|
|
352
|
-
ref: this.onRefContainer,
|
|
353
|
-
className: theme.collapse,
|
|
354
|
-
style: this.initialStyle,
|
|
355
|
-
"aria-hidden": !isOpened
|
|
356
|
-
}, /* @__PURE__ */ _react["default"].createElement("div", {
|
|
357
|
-
ref: this.onRefContent,
|
|
358
|
-
className: theme.content
|
|
359
|
-
}, children));
|
|
360
|
-
}
|
|
361
|
-
}]);
|
|
362
|
-
return Collapse2;
|
|
363
|
-
}(_react["default"].Component);
|
|
364
|
-
Collapse.Collapse = Collapse$1;
|
|
365
|
-
_defineProperty(Collapse$1, "defaultProps", {
|
|
366
|
-
theme: {
|
|
367
|
-
collapse: "ReactCollapse--collapse",
|
|
368
|
-
content: "ReactCollapse--content"
|
|
369
|
-
},
|
|
370
|
-
initialStyle: void 0,
|
|
371
|
-
onRest: void 0,
|
|
372
|
-
onWork: void 0,
|
|
373
|
-
checkTimeout: 50
|
|
374
|
-
});
|
|
375
|
-
return Collapse;
|
|
376
|
-
}
|
|
377
|
-
var UnmountClosed = {};
|
|
378
|
-
var hasRequiredUnmountClosed;
|
|
379
|
-
function requireUnmountClosed() {
|
|
380
|
-
if (hasRequiredUnmountClosed) return UnmountClosed;
|
|
381
|
-
hasRequiredUnmountClosed = 1;
|
|
382
|
-
function _typeof(obj) {
|
|
383
|
-
"@babel/helpers - typeof";
|
|
384
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
385
|
-
_typeof = function _typeof2(obj2) {
|
|
386
|
-
return typeof obj2;
|
|
387
|
-
};
|
|
388
|
-
} else {
|
|
389
|
-
_typeof = function _typeof2(obj2) {
|
|
390
|
-
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
return _typeof(obj);
|
|
394
|
-
}
|
|
395
|
-
Object.defineProperty(UnmountClosed, "__esModule", {
|
|
396
|
-
value: true
|
|
397
|
-
});
|
|
398
|
-
UnmountClosed.UnmountClosed = void 0;
|
|
399
|
-
var _react = _interopRequireDefault(React);
|
|
400
|
-
var _Collapse = requireCollapse();
|
|
401
|
-
var _excluded = ["isOpened"], _excluded2 = ["isOpened"];
|
|
402
|
-
function _interopRequireDefault(obj) {
|
|
403
|
-
return obj && obj.__esModule ? obj : { "default": obj };
|
|
404
|
-
}
|
|
405
|
-
function _extends() {
|
|
406
|
-
_extends = Object.assign || function(target) {
|
|
407
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
408
|
-
var source = arguments[i];
|
|
409
|
-
for (var key in source) {
|
|
410
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
411
|
-
target[key] = source[key];
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
return target;
|
|
416
|
-
};
|
|
417
|
-
return _extends.apply(this, arguments);
|
|
418
|
-
}
|
|
419
|
-
function ownKeys(object, enumerableOnly) {
|
|
420
|
-
var keys = Object.keys(object);
|
|
421
|
-
if (Object.getOwnPropertySymbols) {
|
|
422
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
423
|
-
if (enumerableOnly) {
|
|
424
|
-
symbols = symbols.filter(function(sym) {
|
|
425
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
keys.push.apply(keys, symbols);
|
|
429
|
-
}
|
|
430
|
-
return keys;
|
|
431
|
-
}
|
|
432
|
-
function _objectSpread(target) {
|
|
433
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
434
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
435
|
-
if (i % 2) {
|
|
436
|
-
ownKeys(Object(source), true).forEach(function(key) {
|
|
437
|
-
_defineProperty(target, key, source[key]);
|
|
438
|
-
});
|
|
439
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
440
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
441
|
-
} else {
|
|
442
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
443
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
return target;
|
|
448
|
-
}
|
|
449
|
-
function _objectWithoutProperties(source, excluded) {
|
|
450
|
-
if (source == null) return {};
|
|
451
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
452
|
-
var key, i;
|
|
453
|
-
if (Object.getOwnPropertySymbols) {
|
|
454
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
455
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
456
|
-
key = sourceSymbolKeys[i];
|
|
457
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
458
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
459
|
-
target[key] = source[key];
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
return target;
|
|
463
|
-
}
|
|
464
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
465
|
-
if (source == null) return {};
|
|
466
|
-
var target = {};
|
|
467
|
-
var sourceKeys = Object.keys(source);
|
|
468
|
-
var key, i;
|
|
469
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
470
|
-
key = sourceKeys[i];
|
|
471
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
472
|
-
target[key] = source[key];
|
|
473
|
-
}
|
|
474
|
-
return target;
|
|
475
|
-
}
|
|
476
|
-
function _classCallCheck(instance, Constructor) {
|
|
477
|
-
if (!(instance instanceof Constructor)) {
|
|
478
|
-
throw new TypeError("Cannot call a class as a function");
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
function _defineProperties(target, props) {
|
|
482
|
-
for (var i = 0; i < props.length; i++) {
|
|
483
|
-
var descriptor = props[i];
|
|
484
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
485
|
-
descriptor.configurable = true;
|
|
486
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
487
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
491
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
492
|
-
return Constructor;
|
|
493
|
-
}
|
|
494
|
-
function _inherits(subClass, superClass) {
|
|
495
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
496
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
497
|
-
}
|
|
498
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
|
|
499
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
500
|
-
}
|
|
501
|
-
function _setPrototypeOf(o, p) {
|
|
502
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
|
|
503
|
-
o2.__proto__ = p2;
|
|
504
|
-
return o2;
|
|
505
|
-
};
|
|
506
|
-
return _setPrototypeOf(o, p);
|
|
507
|
-
}
|
|
508
|
-
function _createSuper(Derived) {
|
|
509
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
510
|
-
return function _createSuperInternal() {
|
|
511
|
-
var Super = _getPrototypeOf(Derived), result;
|
|
512
|
-
if (hasNativeReflectConstruct) {
|
|
513
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
514
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
515
|
-
} else {
|
|
516
|
-
result = Super.apply(this, arguments);
|
|
517
|
-
}
|
|
518
|
-
return _possibleConstructorReturn(this, result);
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
function _possibleConstructorReturn(self, call) {
|
|
522
|
-
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
523
|
-
return call;
|
|
524
|
-
} else if (call !== void 0) {
|
|
525
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
526
|
-
}
|
|
527
|
-
return _assertThisInitialized(self);
|
|
528
|
-
}
|
|
529
|
-
function _assertThisInitialized(self) {
|
|
530
|
-
if (self === void 0) {
|
|
531
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
532
|
-
}
|
|
533
|
-
return self;
|
|
534
|
-
}
|
|
535
|
-
function _isNativeReflectConstruct() {
|
|
536
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
537
|
-
if (Reflect.construct.sham) return false;
|
|
538
|
-
if (typeof Proxy === "function") return true;
|
|
539
|
-
try {
|
|
540
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
541
|
-
}));
|
|
542
|
-
return true;
|
|
543
|
-
} catch (e) {
|
|
544
|
-
return false;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
function _getPrototypeOf(o) {
|
|
548
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
|
|
549
|
-
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
550
|
-
};
|
|
551
|
-
return _getPrototypeOf(o);
|
|
552
|
-
}
|
|
553
|
-
function _defineProperty(obj, key, value) {
|
|
554
|
-
if (key in obj) {
|
|
555
|
-
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
556
|
-
} else {
|
|
557
|
-
obj[key] = value;
|
|
558
|
-
}
|
|
559
|
-
return obj;
|
|
560
|
-
}
|
|
561
|
-
var UnmountClosed$1 = /* @__PURE__ */ function(_React$PureComponent) {
|
|
562
|
-
_inherits(UnmountClosed2, _React$PureComponent);
|
|
563
|
-
var _super = _createSuper(UnmountClosed2);
|
|
564
|
-
function UnmountClosed2(props) {
|
|
565
|
-
var _this;
|
|
566
|
-
_classCallCheck(this, UnmountClosed2);
|
|
567
|
-
_this = _super.call(this, props);
|
|
568
|
-
_defineProperty(_assertThisInitialized(_this), "onWork", function(_ref) {
|
|
569
|
-
var isOpened = _ref.isOpened, rest = _objectWithoutProperties(_ref, _excluded);
|
|
570
|
-
_this.setState({
|
|
571
|
-
isResting: false,
|
|
572
|
-
isOpened
|
|
573
|
-
});
|
|
574
|
-
var onWork = _this.props.onWork;
|
|
575
|
-
if (onWork) {
|
|
576
|
-
onWork(_objectSpread({
|
|
577
|
-
isOpened
|
|
578
|
-
}, rest));
|
|
579
|
-
}
|
|
580
|
-
});
|
|
581
|
-
_defineProperty(_assertThisInitialized(_this), "onRest", function(_ref2) {
|
|
582
|
-
var isOpened = _ref2.isOpened, rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
583
|
-
_this.setState({
|
|
584
|
-
isResting: true,
|
|
585
|
-
isOpened,
|
|
586
|
-
isInitialRender: false
|
|
587
|
-
});
|
|
588
|
-
var onRest = _this.props.onRest;
|
|
589
|
-
if (onRest) {
|
|
590
|
-
onRest(_objectSpread({
|
|
591
|
-
isOpened
|
|
592
|
-
}, rest));
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
_defineProperty(_assertThisInitialized(_this), "getInitialStyle", function() {
|
|
596
|
-
var _this$state = _this.state, isOpened = _this$state.isOpened, isInitialRender = _this$state.isInitialRender;
|
|
597
|
-
if (isInitialRender) {
|
|
598
|
-
return isOpened ? {
|
|
599
|
-
height: "auto",
|
|
600
|
-
overflow: "initial"
|
|
601
|
-
} : {
|
|
602
|
-
height: "0px",
|
|
603
|
-
overflow: "hidden"
|
|
604
|
-
};
|
|
605
|
-
}
|
|
606
|
-
return {
|
|
607
|
-
height: "0px",
|
|
608
|
-
overflow: "hidden"
|
|
609
|
-
};
|
|
610
|
-
});
|
|
611
|
-
_this.state = {
|
|
612
|
-
isResting: true,
|
|
613
|
-
isOpened: props.isOpened,
|
|
614
|
-
isInitialRender: true
|
|
615
|
-
};
|
|
616
|
-
return _this;
|
|
617
|
-
}
|
|
618
|
-
_createClass(UnmountClosed2, [{
|
|
619
|
-
key: "componentDidUpdate",
|
|
620
|
-
value: function componentDidUpdate(prevProps) {
|
|
621
|
-
var isOpened = this.props.isOpened;
|
|
622
|
-
if (prevProps.isOpened !== isOpened) {
|
|
623
|
-
this.setState({
|
|
624
|
-
isResting: false,
|
|
625
|
-
isOpened,
|
|
626
|
-
isInitialRender: false
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
}, {
|
|
631
|
-
key: "render",
|
|
632
|
-
value: function render() {
|
|
633
|
-
var _this$state2 = this.state, isResting = _this$state2.isResting, isOpened = _this$state2.isOpened;
|
|
634
|
-
return isResting && !isOpened ? null : /* @__PURE__ */ _react["default"].createElement(_Collapse.Collapse, _extends({}, this.props, {
|
|
635
|
-
initialStyle: this.getInitialStyle(),
|
|
636
|
-
onWork: this.onWork,
|
|
637
|
-
onRest: this.onRest
|
|
638
|
-
}));
|
|
639
|
-
}
|
|
640
|
-
}]);
|
|
641
|
-
return UnmountClosed2;
|
|
642
|
-
}(_react["default"].PureComponent);
|
|
643
|
-
UnmountClosed.UnmountClosed = UnmountClosed$1;
|
|
644
|
-
_defineProperty(UnmountClosed$1, "defaultProps", {
|
|
645
|
-
onWork: void 0,
|
|
646
|
-
onRest: void 0
|
|
647
|
-
});
|
|
648
|
-
return UnmountClosed;
|
|
649
|
-
}
|
|
650
|
-
var lib;
|
|
651
|
-
var hasRequiredLib;
|
|
652
|
-
function requireLib() {
|
|
653
|
-
if (hasRequiredLib) return lib;
|
|
654
|
-
hasRequiredLib = 1;
|
|
655
|
-
var _require = requireCollapse(), Collapse2 = _require.Collapse;
|
|
656
|
-
var _require2 = requireUnmountClosed(), UnmountClosed2 = _require2.UnmountClosed;
|
|
657
|
-
lib = UnmountClosed2;
|
|
658
|
-
UnmountClosed2.Collapse = Collapse2;
|
|
659
|
-
UnmountClosed2.UnmountClosed = UnmountClosed2;
|
|
660
|
-
return lib;
|
|
661
|
-
}
|
|
662
|
-
var libExports = requireLib();
|
|
663
|
-
const BaseExpand = ({ open, ...rest }) => {
|
|
664
|
-
return /* @__PURE__ */ jsx(libExports.UnmountClosed, { isOpened: open, children: /* @__PURE__ */ jsx("div", { ...rest }) });
|
|
60
|
+
|
|
61
|
+
var _excluded$6 = ["open"];
|
|
62
|
+
var BaseExpand = function BaseExpand(_ref) {
|
|
63
|
+
var open = _ref.open,
|
|
64
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
65
|
+
return React.createElement(UnmountClosed, {
|
|
66
|
+
isOpened: open
|
|
67
|
+
}, React.createElement("div", _extends({}, rest)));
|
|
665
68
|
};
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
);
|
|
69
|
+
|
|
70
|
+
var _excluded$5 = ["open", "className"];
|
|
71
|
+
var ExpandArrow = function ExpandArrow(_ref) {
|
|
72
|
+
var _ref$open = _ref.open,
|
|
73
|
+
open = _ref$open === void 0 ? false : _ref$open,
|
|
74
|
+
className = _ref.className,
|
|
75
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
76
|
+
return React.createElement(DownArrowIcon, _extends({
|
|
77
|
+
className: classNames(className, 'eds-expandable-arrow', {
|
|
78
|
+
'eds-expandable-arrow--open': open
|
|
79
|
+
})
|
|
80
|
+
}, rest, {
|
|
81
|
+
"aria-hidden": "true"
|
|
82
|
+
}));
|
|
681
83
|
};
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
{
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
id,
|
|
720
|
-
open,
|
|
721
|
-
style: contentStyle,
|
|
722
|
-
children
|
|
723
|
-
}
|
|
724
|
-
)
|
|
725
|
-
]
|
|
726
|
-
}
|
|
727
|
-
);
|
|
84
|
+
|
|
85
|
+
var _excluded$4 = ["title", "children", "className", "id", "open", "onToggle", "contentStyle", "disableAnimation"];
|
|
86
|
+
var BaseExpandablePanel = function BaseExpandablePanel(_ref) {
|
|
87
|
+
var title = _ref.title,
|
|
88
|
+
children = _ref.children,
|
|
89
|
+
className = _ref.className,
|
|
90
|
+
id = _ref.id,
|
|
91
|
+
open = _ref.open,
|
|
92
|
+
onToggle = _ref.onToggle,
|
|
93
|
+
contentStyle = _ref.contentStyle,
|
|
94
|
+
disableAnimation = _ref.disableAnimation,
|
|
95
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
96
|
+
return React.createElement("div", {
|
|
97
|
+
className: classNames('eds-expandable-panel', className, {
|
|
98
|
+
'eds-expandable-panel--disable-animation': disableAnimation
|
|
99
|
+
})
|
|
100
|
+
}, React.createElement("button", _extends({
|
|
101
|
+
type: "button",
|
|
102
|
+
className: "eds-expandable-panel__trigger",
|
|
103
|
+
onClick: onToggle,
|
|
104
|
+
"aria-expanded": open,
|
|
105
|
+
"aria-controls": open ? id : undefined
|
|
106
|
+
}, rest), React.createElement("span", {
|
|
107
|
+
className: "eds-expandable-panel__grid"
|
|
108
|
+
}, React.createElement(Heading5, {
|
|
109
|
+
margin: "none",
|
|
110
|
+
as: "span"
|
|
111
|
+
}, title), React.createElement("span", {
|
|
112
|
+
className: "eds-expandable-panel__icon-container"
|
|
113
|
+
}, React.createElement(ExpandArrow, {
|
|
114
|
+
open: open
|
|
115
|
+
})))), React.createElement(BaseExpand, {
|
|
116
|
+
className: "eds-expandable-panel__content",
|
|
117
|
+
id: id,
|
|
118
|
+
open: open,
|
|
119
|
+
style: contentStyle
|
|
120
|
+
}, children));
|
|
728
121
|
};
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
122
|
+
|
|
123
|
+
var _excluded$3 = ["defaultOpen", "id", "contentStyle"];
|
|
124
|
+
var AccordionItem = function AccordionItem(_ref) {
|
|
125
|
+
var _ref$defaultOpen = _ref.defaultOpen,
|
|
126
|
+
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
|
|
127
|
+
overrideId = _ref.id,
|
|
128
|
+
contentStyle = _ref.contentStyle,
|
|
129
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
130
|
+
var randomId = useRandomId('eds-accordion-item');
|
|
131
|
+
var id = overrideId || randomId;
|
|
132
|
+
var _useAccordion = useAccordion({
|
|
133
|
+
id: id,
|
|
134
|
+
defaultOpen: defaultOpen
|
|
135
|
+
}),
|
|
136
|
+
isOpen = _useAccordion.isOpen,
|
|
137
|
+
toggle = _useAccordion.toggle;
|
|
138
|
+
return React.createElement(BaseExpandablePanel, _extends({}, rest, {
|
|
139
|
+
contentStyle: contentStyle,
|
|
140
|
+
id: id,
|
|
141
|
+
onToggle: toggle,
|
|
142
|
+
open: isOpen
|
|
143
|
+
}));
|
|
748
144
|
};
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
145
|
+
|
|
146
|
+
var _excluded$2 = ["defaultOpen", "contentStyle"];
|
|
147
|
+
var ExpandablePanel = function ExpandablePanel(_ref) {
|
|
148
|
+
var _ref$defaultOpen = _ref.defaultOpen,
|
|
149
|
+
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
|
|
150
|
+
contentStyle = _ref.contentStyle,
|
|
151
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
152
|
+
var randomId = useRandomId('eds-expandable');
|
|
153
|
+
var _React$useState = React.useState(defaultOpen),
|
|
154
|
+
isOpen = _React$useState[0],
|
|
155
|
+
setOpen = _React$useState[1];
|
|
156
|
+
return React.createElement(BaseExpandablePanel, _extends({
|
|
157
|
+
id: randomId,
|
|
158
|
+
open: isOpen,
|
|
159
|
+
onToggle: function onToggle() {
|
|
160
|
+
return setOpen(function (prev) {
|
|
161
|
+
return !prev;
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
contentStyle: contentStyle
|
|
165
|
+
}, rest));
|
|
766
166
|
};
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
]
|
|
786
|
-
}
|
|
787
|
-
);
|
|
167
|
+
|
|
168
|
+
var _excluded$1 = ["children", "open", "onToggle", "as"];
|
|
169
|
+
var ExpandableTextButton = function ExpandableTextButton(_ref) {
|
|
170
|
+
var children = _ref.children,
|
|
171
|
+
open = _ref.open,
|
|
172
|
+
onToggle = _ref.onToggle,
|
|
173
|
+
_ref$as = _ref.as,
|
|
174
|
+
Component = _ref$as === void 0 ? Heading5 : _ref$as,
|
|
175
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
176
|
+
return React.createElement("button", _extends({
|
|
177
|
+
className: "eds-expandable-text__trigger",
|
|
178
|
+
"aria-expanded": open,
|
|
179
|
+
type: "button",
|
|
180
|
+
onClick: onToggle
|
|
181
|
+
}, rest), React.createElement(Component, null, children), React.createElement(ExpandArrow, {
|
|
182
|
+
open: open,
|
|
183
|
+
className: "eds-expandable-text__arrow"
|
|
184
|
+
}));
|
|
788
185
|
};
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
open: isOpen,
|
|
829
|
-
style: contentStyle,
|
|
830
|
-
...rest,
|
|
831
|
-
children
|
|
832
|
-
}
|
|
833
|
-
)
|
|
834
|
-
]
|
|
835
|
-
}
|
|
836
|
-
);
|
|
186
|
+
|
|
187
|
+
var _excluded = ["title", "children", "defaultOpen", "contentStyle", "titleElement", "disableAnimation", "className"];
|
|
188
|
+
var ExpandableText = function ExpandableText(_ref) {
|
|
189
|
+
var title = _ref.title,
|
|
190
|
+
children = _ref.children,
|
|
191
|
+
_ref$defaultOpen = _ref.defaultOpen,
|
|
192
|
+
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
|
|
193
|
+
contentStyle = _ref.contentStyle,
|
|
194
|
+
_ref$titleElement = _ref.titleElement,
|
|
195
|
+
titleElement = _ref$titleElement === void 0 ? 'Heading5' : _ref$titleElement,
|
|
196
|
+
disableAnimation = _ref.disableAnimation,
|
|
197
|
+
className = _ref.className,
|
|
198
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
199
|
+
var randomId = useRandomId('eds-expandable-text');
|
|
200
|
+
var _React$useState = React.useState(defaultOpen),
|
|
201
|
+
isOpen = _React$useState[0],
|
|
202
|
+
setOpen = _React$useState[1];
|
|
203
|
+
var Element = React.useMemo(function () {
|
|
204
|
+
return GetTypographyComponent(titleElement);
|
|
205
|
+
}, [titleElement]);
|
|
206
|
+
return React.createElement("div", {
|
|
207
|
+
className: classNames('eds-expandable-text', className, {
|
|
208
|
+
'eds-expandable-text--disable-animation': disableAnimation
|
|
209
|
+
})
|
|
210
|
+
}, React.createElement(ExpandableTextButton, _extends({
|
|
211
|
+
open: isOpen,
|
|
212
|
+
onToggle: function onToggle() {
|
|
213
|
+
return setOpen(function (prev) {
|
|
214
|
+
return !prev;
|
|
215
|
+
});
|
|
216
|
+
},
|
|
217
|
+
"aria-controls": isOpen ? randomId : undefined,
|
|
218
|
+
as: Element
|
|
219
|
+
}, rest), title), React.createElement(BaseExpand, _extends({
|
|
220
|
+
className: "eds-expandable-text__content",
|
|
221
|
+
id: randomId,
|
|
222
|
+
open: isOpen,
|
|
223
|
+
style: contentStyle
|
|
224
|
+
}, rest), children));
|
|
837
225
|
};
|
|
838
226
|
function GetTypographyComponent(element) {
|
|
839
227
|
switch (element) {
|
|
840
|
-
case
|
|
228
|
+
case 'Heading5':
|
|
841
229
|
return Heading5;
|
|
842
|
-
case
|
|
230
|
+
case 'Heading4':
|
|
843
231
|
return Heading4;
|
|
844
|
-
case
|
|
232
|
+
case 'Heading3':
|
|
845
233
|
return Heading3;
|
|
846
|
-
case
|
|
234
|
+
case 'Heading2':
|
|
847
235
|
return Heading2;
|
|
848
|
-
case
|
|
236
|
+
case 'Paragraph':
|
|
849
237
|
return Paragraph;
|
|
850
|
-
case
|
|
238
|
+
case 'SubParagraph':
|
|
851
239
|
return SubParagraph;
|
|
852
240
|
default:
|
|
853
241
|
return Heading5;
|
|
854
242
|
}
|
|
855
243
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
BaseExpand,
|
|
861
|
-
ExpandArrow,
|
|
862
|
-
ExpandablePanel,
|
|
863
|
-
ExpandableText,
|
|
864
|
-
ExpandableTextButton,
|
|
865
|
-
useAccordion
|
|
866
|
-
};
|
|
244
|
+
|
|
245
|
+
warnAboutMissingStyles('expand', 'typography', 'icons');
|
|
246
|
+
|
|
247
|
+
export { Accordion, AccordionItem, BaseExpand, ExpandArrow, ExpandablePanel, ExpandableText, ExpandableTextButton, useAccordion };
|
|
867
248
|
//# sourceMappingURL=expand.esm.js.map
|