funda-ui 1.0.578 → 1.0.600

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.
@@ -0,0 +1,2 @@
1
+ export { default as Accordion } from './Accordion';
2
+ export { default as AccordionItem } from './AccordionItem';
@@ -0,0 +1,625 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory(require("react"));
4
+ else if(typeof define === 'function' && define.amd)
5
+ define(["react"], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["RPB"] = factory(require("react"));
8
+ else
9
+ root["RPB"] = factory(root["React"]);
10
+ })(this, (__WEBPACK_EXTERNAL_MODULE__787__) => {
11
+ return /******/ (() => { // webpackBootstrap
12
+ /******/ var __webpack_modules__ = ({
13
+
14
+ /***/ 710:
15
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
16
+
17
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
18
+ var _require = __webpack_require__(711),
19
+ easeLinear = _require.easeLinear,
20
+ easeInQuad = _require.easeInQuad,
21
+ easeOutQuad = _require.easeOutQuad,
22
+ easeInOutQuad = _require.easeInOutQuad;
23
+
24
+ /**
25
+ * Element Animate
26
+ * @public
27
+ *
28
+ * @param {HTMLElement} curElement - Element of animation.
29
+ * @param {?JSON} config - Configuration of animation
30
+ * @param {?string} easeType - Types of easing animation.
31
+ */
32
+ function animateStyles(curElement, config) {
33
+ var easeType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'linear';
34
+ if (_typeof(curElement) === ( true ? "undefined" : 0)) return;
35
+
36
+ // Set a default configuration
37
+ config = setDefaultOptions({
38
+ "startHeight": 0,
39
+ // node.scrollHeight
40
+ "endHeight": 0,
41
+ "speed": 200 //ms
42
+ }, config);
43
+
44
+ //
45
+ var _endHeight = config.endHeight,
46
+ _speed = config.speed;
47
+ var _startHeight = config.startHeight;
48
+ var duration = _speed;
49
+ var start = new Date().getTime();
50
+ var from = 0;
51
+ var to = 100;
52
+ var requestId;
53
+ var loop = function loop() {
54
+ //easing
55
+ var time = new Date().getTime() - start; //Work out the elapsed time
56
+ var val;
57
+ switch (easeType) {
58
+ case "linear":
59
+ val = easeLinear(time, from, to - from, duration);
60
+ break;
61
+ case "ease-in":
62
+ val = easeInQuad(time, from, to - from, duration);
63
+ break;
64
+ case "ease-out":
65
+ val = easeOutQuad(time, from, to - from, duration);
66
+ break;
67
+ case "ease-in-out":
68
+ val = easeInOutQuad(time, from, to - from, duration);
69
+ break;
70
+ default:
71
+ val = easeLinear(time, from, to - from, duration);
72
+ }
73
+
74
+ // Elapsed time in miliseconds
75
+ var percent = val / 100;
76
+
77
+ // change height
78
+ if (curElement.clientHeight < _endHeight) {
79
+ curElement.style.height = _endHeight * percent + 'px';
80
+ } else {
81
+ if (_startHeight > 0) curElement.style.height = _startHeight - _startHeight * percent + 'px';
82
+ }
83
+
84
+ //If the elapsed time is less than the speed (ms)
85
+ if (time < duration) {
86
+ //
87
+ requestId = window.requestAnimationFrame(loop);
88
+ } else {
89
+ // change height
90
+ curElement.style.height = _endHeight + 'px';
91
+
92
+ //
93
+ window.cancelAnimationFrame(requestId);
94
+ }
95
+ };
96
+ requestId = window.requestAnimationFrame(loop);
97
+ }
98
+
99
+ /**
100
+ * Check if a string is a valid number
101
+ * @private
102
+ */
103
+ function isValidNumeric(str) {
104
+ if (typeof str != "string") return false; // we only process strings!
105
+ if (!isNaN(str) &&
106
+ // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)
107
+ !isNaN(parseFloat(str)) // ensure strings of whitespace fail
108
+ ) {
109
+ return true;
110
+ } else {
111
+ return false;
112
+ }
113
+ }
114
+
115
+ /**
116
+ * Determine whether it is in JSON format
117
+ * @private
118
+ */
119
+ function isJSON(str) {
120
+ if (typeof str === 'string' && str.length > 0) {
121
+ if (str.replace(/\"\"/g, '').replace(/\,/g, '') == '[{}]') {
122
+ return false;
123
+ } else {
124
+ if (/^[\],:{}\s]*$/.test(str.replace(/\\["\\\/bfnrtu]/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
125
+ return true;
126
+ } else {
127
+ return false;
128
+ }
129
+ }
130
+ } else {
131
+ if (_typeof(str) === 'object' && Object.prototype.toString.call(str) === '[object Object]' && !str.length) {
132
+ return true;
133
+ } else {
134
+ return false;
135
+ }
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Set a default JSON format configuration
141
+ * @private
142
+ *
143
+ * @param {JSON} props - Set some default keys and values.
144
+ * @param {JSON} options - A JSON variable passed in from outside, including key and value.
145
+ * @return {JSON} - Merge the new and old values.
146
+ */
147
+ function setDefaultOptions(props, options) {
148
+ if (_typeof(options) === ( true ? "undefined" : 0) || options === null || options === false) options = {};
149
+ //Set a default configuration
150
+ if (isJSON(props)) {
151
+ var defaultConfigValues = Object.values(props);
152
+ Object.keys(props).forEach(function (prop, index) {
153
+ // Well-formed string type
154
+ Object.keys(options).forEach(function (prop2, index2) {
155
+ if (prop2 === prop) {
156
+ var _v = options[prop2];
157
+ if (_v == 'true') _v = true;
158
+ if (_v == 'false') _v = false;
159
+ if (isValidNumeric(_v)) _v = parseFloat(_v);
160
+ if (isJSON(_v)) _v = Object.prototype.toString.call(_v) === '[object Object]' ? _v : JSON.parse(_v);
161
+ options[prop2] = _v;
162
+ }
163
+ });
164
+
165
+ //
166
+ if (_typeof(options[prop]) === ( true ? "undefined" : 0) || options[prop] === null) options[prop] = defaultConfigValues[index];
167
+ });
168
+ }
169
+ return options;
170
+ }
171
+ ;
172
+ module.exports = animateStyles;
173
+
174
+ /***/ }),
175
+
176
+ /***/ 711:
177
+ /***/ ((module) => {
178
+
179
+ /*
180
+ * All easing functions
181
+ * @link: https://easings.net
182
+ * @param {Number} t - time (Amount of time that has passed since the beginning of the animation. Usually starts at 0 and is slowly increased using a game loop or other update function.)
183
+ * @param {Number} b - beginning value (The starting point of the animation. Usually it's a static value, you can start at 0 for example.)
184
+ * @param {Number} c - change in value (The amount of change needed to go from starting point to end point. It's also usually a static value.)
185
+ * @param {Number} d - duration (Amount of time the animation will take. Usually a static value aswell.)
186
+ * @return {Number}
187
+ */
188
+ function easeLinear(t, b, c, d) {
189
+ return c * t / d + b;
190
+ }
191
+ function easeInQuad(t, b, c, d) {
192
+ return c * (t /= d) * t + b;
193
+ }
194
+ function easeOutQuad(t, b, c, d) {
195
+ return -c * (t /= d) * (t - 2) + b;
196
+ }
197
+ function easeInOutQuad(t, b, c, d) {
198
+ if ((t /= d / 2) < 1) return c / 2 * t * t + b;
199
+ return -c / 2 * (--t * (t - 2) - 1) + b;
200
+ }
201
+ function easeInSine(t, b, c, d) {
202
+ return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
203
+ }
204
+ function easeOutSine(t, b, c, d) {
205
+ return c * Math.sin(t / d * (Math.PI / 2)) + b;
206
+ }
207
+ function easeInOutSine(t, b, c, d) {
208
+ return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
209
+ }
210
+ function easeInExpo(t, b, c, d) {
211
+ return t == 0 ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
212
+ }
213
+ function easeOutExpo(t, b, c, d) {
214
+ return t == d ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
215
+ }
216
+ function easeInOutExpo(t, b, c, d) {
217
+ if (t == 0) return b;
218
+ if (t == d) return b + c;
219
+ if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
220
+ return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
221
+ }
222
+ function easeInCirc(t, b, c, d) {
223
+ return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
224
+ }
225
+ function easeOutCirc(t, b, c, d) {
226
+ return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
227
+ }
228
+ function easeInOutCirc(t, b, c, d) {
229
+ if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
230
+ return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
231
+ }
232
+ function easeInCubic(t, b, c, d) {
233
+ return c * (t /= d) * t * t + b;
234
+ }
235
+ function easeOutCubic(t, b, c, d) {
236
+ return c * ((t = t / d - 1) * t * t + 1) + b;
237
+ }
238
+ function easeInOutCubic(t, b, c, d) {
239
+ if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
240
+ return c / 2 * ((t -= 2) * t * t + 2) + b;
241
+ }
242
+ function easeInQuart(t, b, c, d) {
243
+ return c * (t /= d) * t * t * t + b;
244
+ }
245
+ function easeOutQuart(t, b, c, d) {
246
+ return -c * ((t = t / d - 1) * t * t * t - 1) + b;
247
+ }
248
+ function easeInOutQuart(t, b, c, d) {
249
+ if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
250
+ return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
251
+ }
252
+ function easeInQuint(t, b, c, d) {
253
+ return c * (t /= d) * t * t * t * t + b;
254
+ }
255
+ function easeOutQuint(t, b, c, d) {
256
+ return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
257
+ }
258
+ function easeInOutQuint(t, b, c, d) {
259
+ if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
260
+ return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
261
+ }
262
+ function easeInElastic(t, b, c, d) {
263
+ var s = 1.70158;
264
+ var p = 0;
265
+ var a = c;
266
+ if (t == 0) return b;
267
+ if ((t /= d) == 1) return b + c;
268
+ if (!p) p = d * .3;
269
+ if (a < Math.abs(c)) {
270
+ a = c;
271
+ var s = p / 4;
272
+ } else var s = p / (2 * Math.PI) * Math.asin(c / a);
273
+ return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
274
+ }
275
+ function easeOutElastic(t, b, c, d) {
276
+ var s = 1.70158;
277
+ var p = 0;
278
+ var a = c;
279
+ if (t == 0) return b;
280
+ if ((t /= d) == 1) return b + c;
281
+ if (!p) p = d * .3;
282
+ if (a < Math.abs(c)) {
283
+ a = c;
284
+ var s = p / 4;
285
+ } else var s = p / (2 * Math.PI) * Math.asin(c / a);
286
+ return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
287
+ }
288
+ function easeInOutElastic(t, b, c, d) {
289
+ var s = 1.70158;
290
+ var p = 0;
291
+ var a = c;
292
+ if (t == 0) return b;
293
+ if ((t /= d / 2) == 2) return b + c;
294
+ if (!p) p = d * (.3 * 1.5);
295
+ if (a < Math.abs(c)) {
296
+ a = c;
297
+ var s = p / 4;
298
+ } else var s = p / (2 * Math.PI) * Math.asin(c / a);
299
+ if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
300
+ return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
301
+ }
302
+ function easeInBack(t, b, c, d) {
303
+ if (s == undefined) s = 1.70158;
304
+ return c * (t /= d) * t * ((s + 1) * t - s) + b;
305
+ }
306
+ function easeOutBack(t, b, c, d) {
307
+ if (s == undefined) s = 1.70158;
308
+ return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
309
+ }
310
+ function easeInOutBack(t, b, c, d) {
311
+ if (s == undefined) s = 1.70158;
312
+ if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= 1.525) + 1) * t - s)) + b;
313
+ return c / 2 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;
314
+ }
315
+ module.exports = {
316
+ easeLinear: easeLinear,
317
+ easeInQuad: easeInQuad,
318
+ easeOutQuad: easeOutQuad,
319
+ easeInOutQuad: easeInOutQuad,
320
+ easeInSine: easeInSine,
321
+ easeOutSine: easeOutSine,
322
+ easeInOutSine: easeInOutSine,
323
+ easeInExpo: easeInExpo,
324
+ easeOutExpo: easeOutExpo,
325
+ easeInOutExpo: easeInOutExpo,
326
+ easeInCirc: easeInCirc,
327
+ easeOutCirc: easeOutCirc,
328
+ easeInOutCirc: easeInOutCirc,
329
+ easeInCubic: easeInCubic,
330
+ easeOutCubic: easeOutCubic,
331
+ easeInOutCubic: easeInOutCubic,
332
+ easeInQuart: easeInQuart,
333
+ easeOutQuart: easeOutQuart,
334
+ easeInOutQuart: easeInOutQuart,
335
+ easeInQuint: easeInQuint,
336
+ easeOutQuint: easeOutQuint,
337
+ easeInOutQuint: easeInOutQuint,
338
+ easeInElastic: easeInElastic,
339
+ easeOutElastic: easeOutElastic,
340
+ easeInOutElastic: easeInOutElastic,
341
+ easeInBack: easeInBack,
342
+ easeOutBack: easeOutBack,
343
+ easeInOutBack: easeInOutBack
344
+ };
345
+
346
+ /***/ }),
347
+
348
+ /***/ 787:
349
+ /***/ ((module) => {
350
+
351
+ "use strict";
352
+ module.exports = __WEBPACK_EXTERNAL_MODULE__787__;
353
+
354
+ /***/ })
355
+
356
+ /******/ });
357
+ /************************************************************************/
358
+ /******/ // The module cache
359
+ /******/ var __webpack_module_cache__ = {};
360
+ /******/
361
+ /******/ // The require function
362
+ /******/ function __webpack_require__(moduleId) {
363
+ /******/ // Check if module is in cache
364
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
365
+ /******/ if (cachedModule !== undefined) {
366
+ /******/ return cachedModule.exports;
367
+ /******/ }
368
+ /******/ // Create a new module (and put it into the cache)
369
+ /******/ var module = __webpack_module_cache__[moduleId] = {
370
+ /******/ // no module.id needed
371
+ /******/ // no module.loaded needed
372
+ /******/ exports: {}
373
+ /******/ };
374
+ /******/
375
+ /******/ // Execute the module function
376
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
377
+ /******/
378
+ /******/ // Return the exports of the module
379
+ /******/ return module.exports;
380
+ /******/ }
381
+ /******/
382
+ /************************************************************************/
383
+ /******/ /* webpack/runtime/compat get default export */
384
+ /******/ (() => {
385
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
386
+ /******/ __webpack_require__.n = (module) => {
387
+ /******/ var getter = module && module.__esModule ?
388
+ /******/ () => (module['default']) :
389
+ /******/ () => (module);
390
+ /******/ __webpack_require__.d(getter, { a: getter });
391
+ /******/ return getter;
392
+ /******/ };
393
+ /******/ })();
394
+ /******/
395
+ /******/ /* webpack/runtime/define property getters */
396
+ /******/ (() => {
397
+ /******/ // define getter functions for harmony exports
398
+ /******/ __webpack_require__.d = (exports, definition) => {
399
+ /******/ for(var key in definition) {
400
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
401
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
402
+ /******/ }
403
+ /******/ }
404
+ /******/ };
405
+ /******/ })();
406
+ /******/
407
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
408
+ /******/ (() => {
409
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
410
+ /******/ })();
411
+ /******/
412
+ /******/ /* webpack/runtime/make namespace object */
413
+ /******/ (() => {
414
+ /******/ // define __esModule on exports
415
+ /******/ __webpack_require__.r = (exports) => {
416
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
417
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
418
+ /******/ }
419
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
420
+ /******/ };
421
+ /******/ })();
422
+ /******/
423
+ /************************************************************************/
424
+ var __webpack_exports__ = {};
425
+ // This entry need to be wrapped in an IIFE because it need to be in strict mode.
426
+ (() => {
427
+ "use strict";
428
+ // ESM COMPAT FLAG
429
+ __webpack_require__.r(__webpack_exports__);
430
+
431
+ // EXPORTS
432
+ __webpack_require__.d(__webpack_exports__, {
433
+ "Accordion": () => (/* reexport */ src_Accordion),
434
+ "AccordionItem": () => (/* reexport */ src_AccordionItem)
435
+ });
436
+
437
+ // EXTERNAL MODULE: external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"}
438
+ var external_root_React_commonjs2_react_commonjs_react_amd_react_ = __webpack_require__(787);
439
+ var external_root_React_commonjs2_react_commonjs_react_amd_react_default = /*#__PURE__*/__webpack_require__.n(external_root_React_commonjs2_react_commonjs_react_amd_react_);
440
+ ;// CONCATENATED MODULE: ./src/AccordionItem.tsx
441
+
442
+ var AccordionItem = function AccordionItem(props) {
443
+ var index = props.index,
444
+ itemClassName = props.itemClassName,
445
+ itemContentWrapperClassName = props.itemContentWrapperClassName,
446
+ itemContentClassName = props.itemContentClassName,
447
+ itemTriggerClassName = props.itemTriggerClassName,
448
+ itemHeaderClassName = props.itemHeaderClassName,
449
+ itemTriggerIcon = props.itemTriggerIcon,
450
+ itemStyle = props.itemStyle,
451
+ defaultActive = props.defaultActive,
452
+ title = props.title,
453
+ onToggleEv = props.onToggleEv,
454
+ onTransitionEnd = props.onTransitionEnd,
455
+ triggerType = props.triggerType,
456
+ children = props.children;
457
+ var activedClassName = typeof defaultActive !== 'undefined' && defaultActive !== false ? ' active' : '';
458
+ return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
459
+ "data-index": index,
460
+ className: "custom-accordion-item ".concat(itemClassName || itemClassName === '' ? itemClassName : "accordion-item", " ").concat(activedClassName),
461
+ onClick: triggerType === 'click' ? onToggleEv : function () {},
462
+ onMouseOver: triggerType === 'click' ? function () {} : onToggleEv,
463
+ onTransitionEnd: typeof onTransitionEnd === 'function' ? onTransitionEnd : function () {},
464
+ "aria-expanded": defaultActive ? 'true' : 'false',
465
+ style: typeof itemStyle !== 'undefined' ? itemStyle : {}
466
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
467
+ className: "custom-accordion-header ".concat(itemHeaderClassName || itemHeaderClassName === '' ? itemHeaderClassName : "accordion-header position-relative"),
468
+ role: "presentation"
469
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("button", {
470
+ tabIndex: -1,
471
+ className: "custom-accordion-trigger ".concat(itemTriggerClassName || itemTriggerClassName === '' ? itemTriggerClassName : "accordion-button", " ").concat(activedClassName === '' ? 'collapsed' : 'active'),
472
+ type: "button"
473
+ }, title), itemTriggerIcon), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
474
+ className: "custom-accordion-content__wrapper ".concat(itemContentWrapperClassName || itemContentWrapperClassName === '' ? itemContentWrapperClassName : "accordion-collapse"),
475
+ role: "tabpanel",
476
+ style: {
477
+ height: defaultActive ? 'auto' : '0px',
478
+ overflow: 'hidden'
479
+ }
480
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
481
+ className: "custom-accordion-content ".concat(itemContentClassName || itemContentClassName === '' ? itemContentClassName : "accordion-body")
482
+ }, children))));
483
+ };
484
+ /* harmony default export */ const src_AccordionItem = (AccordionItem);
485
+ // EXTERNAL MODULE: ./src/utils/anim.js
486
+ var anim = __webpack_require__(710);
487
+ var anim_default = /*#__PURE__*/__webpack_require__.n(anim);
488
+ ;// CONCATENATED MODULE: ./src/Accordion.tsx
489
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
490
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
491
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
492
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
493
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
494
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
495
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
496
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
497
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
498
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
499
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
500
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
501
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
502
+
503
+
504
+
505
+
506
+ // Adapt the easing parameters of TweenMax
507
+ var EasingList = /*#__PURE__*/function (EasingList) {
508
+ EasingList["linear"] = "linear";
509
+ EasingList["easeIn"] = "ease-in";
510
+ EasingList["easeOut"] = "ease-out";
511
+ EasingList["easeInOut"] = "ease-in-out";
512
+ return EasingList;
513
+ }(EasingList || {});
514
+ var Accordion = function Accordion(props) {
515
+ var wrapperClassName = props.wrapperClassName,
516
+ triggerType = props.triggerType,
517
+ displayTheFirstItem = props.displayTheFirstItem,
518
+ duration = props.duration,
519
+ easing = props.easing,
520
+ alternateCollapse = props.alternateCollapse,
521
+ onChange = props.onChange,
522
+ children = props.children;
523
+ var easeType = typeof alternateCollapse === 'undefined' ? EasingList['linear'] : EasingList[easing];
524
+ var ALTER = typeof alternateCollapse === 'undefined' ? true : alternateCollapse;
525
+ var rootRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
526
+ var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false),
527
+ _useState2 = _slicedToArray(_useState, 2),
528
+ animOK = _useState2[0],
529
+ setAnimOK = _useState2[1];
530
+ function handleClickItem(e) {
531
+ e.preventDefault();
532
+ //Prevents further propagation of the current event in the capturing and bubbling phases(if use `e.target`).
533
+ e.stopPropagation();
534
+ if (animOK) return;
535
+
536
+ //
537
+ var reactDomEl = e.currentTarget;
538
+ var curIndex = reactDomEl.dataset.index;
539
+ var reactDomWrapperEl = rootRef.current;
540
+ var animSpeed = duration || 200;
541
+ var $li = reactDomWrapperEl.querySelectorAll('.custom-accordion-item');
542
+ var $allContent = reactDomWrapperEl.querySelectorAll('.custom-accordion-content__wrapper');
543
+ var $curContent = reactDomEl.querySelector('.custom-accordion-content__wrapper');
544
+ if (reactDomEl.getAttribute('aria-expanded') === 'false' || reactDomEl.getAttribute('aria-expanded') === null) {
545
+ var _reactDomEl$querySele, _reactDomEl$querySele2;
546
+ setAnimOK(true);
547
+ setTimeout(function () {
548
+ setAnimOK(false);
549
+ }, animSpeed);
550
+ if (ALTER) {
551
+ //Hide other all sibling <dt> of the selected element
552
+ Array.prototype.forEach.call($allContent, function (node) {
553
+ if (node.clientHeight > 0) {
554
+ anim_default()(node, {
555
+ startHeight: node.scrollHeight,
556
+ endHeight: 0,
557
+ speed: animSpeed
558
+ }, easeType);
559
+ }
560
+ });
561
+
562
+ //to open
563
+ Array.prototype.forEach.call($li, function (node) {
564
+ var _node$querySelector, _node$querySelector2;
565
+ node.classList.remove('active');
566
+ (_node$querySelector = node.querySelector('.custom-accordion-trigger')) === null || _node$querySelector === void 0 ? void 0 : _node$querySelector.classList.remove('active');
567
+ (_node$querySelector2 = node.querySelector('.custom-accordion-trigger')) === null || _node$querySelector2 === void 0 ? void 0 : _node$querySelector2.classList.add('collapsed');
568
+ node.setAttribute('aria-expanded', false);
569
+ });
570
+ }
571
+ reactDomEl.classList.add('active');
572
+ (_reactDomEl$querySele = reactDomEl.querySelector('.custom-accordion-trigger')) === null || _reactDomEl$querySele === void 0 ? void 0 : _reactDomEl$querySele.classList.add('active');
573
+ (_reactDomEl$querySele2 = reactDomEl.querySelector('.custom-accordion-trigger')) === null || _reactDomEl$querySele2 === void 0 ? void 0 : _reactDomEl$querySele2.classList.remove('collapsed');
574
+ reactDomEl.setAttribute('aria-expanded', true);
575
+ // When the height of the element is 0, the value of `offsetHeight` and `clientHeight` will be 0
576
+ anim_default()($curContent, {
577
+ startHeight: 0,
578
+ endHeight: $curContent.scrollHeight,
579
+ speed: animSpeed
580
+ }, easeType);
581
+ } else {
582
+ if (e.type == 'click') {
583
+ var _reactDomEl$querySele3, _reactDomEl$querySele4;
584
+ //to close
585
+ reactDomEl.classList.remove('active');
586
+ (_reactDomEl$querySele3 = reactDomEl.querySelector('.custom-accordion-trigger')) === null || _reactDomEl$querySele3 === void 0 ? void 0 : _reactDomEl$querySele3.classList.remove('active');
587
+ (_reactDomEl$querySele4 = reactDomEl.querySelector('.custom-accordion-trigger')) === null || _reactDomEl$querySele4 === void 0 ? void 0 : _reactDomEl$querySele4.classList.add('collapsed');
588
+ reactDomEl.setAttribute('aria-expanded', false);
589
+ anim_default()($curContent, {
590
+ startHeight: $curContent.scrollHeight,
591
+ endHeight: 0,
592
+ speed: animSpeed
593
+ }, easeType);
594
+ }
595
+ }
596
+ if (typeof onChange === 'function') {
597
+ onChange(reactDomEl, Number(curIndex));
598
+ }
599
+ }
600
+ return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
601
+ className: "custom-accordion-item ".concat(wrapperClassName || wrapperClassName === '' ? wrapperClassName : "accordion"),
602
+ role: "tablist",
603
+ ref: rootRef
604
+ }, children != null ? children.map(function (item, i) {
605
+ var childProps = _objectSpread({}, item.props);
606
+ var _defaultActive = i === 0 && displayTheFirstItem ? true : false;
607
+ return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(src_AccordionItem, _extends({
608
+ key: "item" + i,
609
+ index: i,
610
+ defaultActive: _defaultActive,
611
+ triggerType: triggerType || 'click',
612
+ onToggleEv: handleClickItem
613
+ }, childProps));
614
+ }) : null));
615
+ };
616
+ /* harmony default export */ const src_Accordion = (Accordion);
617
+ ;// CONCATENATED MODULE: ./src/index.tsx
618
+
619
+
620
+ })();
621
+
622
+ /******/ return __webpack_exports__;
623
+ /******/ })()
624
+ ;
625
+ });
package/README.md CHANGED
@@ -25,7 +25,7 @@ Here is a table of the components and their status.
25
25
 
26
26
  | WEB ELEMENTS | FORMS | INTERACTION | NAVIGATION |
27
27
  | --- | --- | --- | --- |
28
- | [Accordion ](packages/Accordion/README.md) | [Input ✅](packages/Input/README.md) | [Infinite Scroll ❏](packages/InfiniteScroll/README.md) |[Multilevel Dropdown Menu ✅](packages/MultilevelDropdownMenu/README.md) |
28
+ | [Accordion ](packages/Accordion/README.md) | [Input ✅](packages/Input/README.md) | [Infinite Scroll ❏](packages/InfiniteScroll/README.md) |[Multilevel Dropdown Menu ✅](packages/MultilevelDropdownMenu/README.md) |
29
29
  | [Accordion Slider ❏](packages/AccordionSlider/README.md) | [Password Input ❏](packages/PasswordInput/README.md) | [Image Perspective Hover ❏](packages/ImagePerspectiveHover/README.md) | [Dropdown Menu ✅](packages/DropdownMenu/README.md) |
30
30
  | [Back To Top ✅](packages/BackToTop/README.md) | [Merge Input ❏](packages/MergeInput/README.md) | [Mousewheel Interaction ❏](packages/MousewheelInteraction/README.md) | |
31
31
  | [Button ❏](packages/Button/README.md) | [Tag Input ✅](packages/TagInput/README.md) | [Parallax ❏](packages/Parallax/README.md) | |
package/all.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
 
2
2
  export const __esModule: true;
3
+ export const Accordion: any;
3
4
  export const BackToTop: any;
4
5
  export const CascadingSelect: any;
5
6
  export const CascadingSelectE2E: any;
package/all.js CHANGED
@@ -2,6 +2,7 @@
2
2
  "use strict";
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
  exports.__esModule = true;
5
+ exports.Accordion = _interopRequireDefault(require("./Accordion")).default;
5
6
  exports.BackToTop = _interopRequireDefault(require("./BackToTop")).default;
6
7
  exports.CascadingSelect = _interopRequireDefault(require("./CascadingSelect")).default;
7
8
  exports.CascadingSelectE2E = _interopRequireDefault(require("./CascadingSelectE2E")).default;
@@ -0,0 +1,2 @@
1
+ export { default as Accordion } from './Accordion';
2
+ export { default as AccordionItem } from './AccordionItem';