@zohodesk/components 1.4.5 → 1.4.7
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/.cli/propValidation_report.html +1 -1
- package/README.md +10 -0
- package/es/AppContainer/AppContainer.js +1 -1
- package/es/Card/Card.js +47 -13
- package/es/Card/__tests__/Card.spec.js +81 -2
- package/es/Card/__tests__/__snapshots__/Card.spec.js.snap +44 -0
- package/es/Card/props/defaultProps.js +2 -1
- package/es/Card/props/propTypes.js +2 -1
- package/es/DropBox/DropBoxElement/css/DropBoxElement.module.css +7 -0
- package/es/Popup/Popup.js +196 -92
- package/es/Popup/Registry.js +35 -0
- package/es/Provider/Config.js +2 -2
- package/es/common/basic.module.css +0 -2
- package/es/components_layer.module.css +1 -0
- package/lib/AppContainer/AppContainer.js +1 -1
- package/lib/Card/Card.js +62 -28
- package/lib/Card/__tests__/Card.spec.js +118 -1
- package/lib/Card/__tests__/__snapshots__/Card.spec.js.snap +44 -0
- package/lib/Card/props/defaultProps.js +2 -1
- package/lib/Card/props/propTypes.js +2 -1
- package/lib/DropBox/DropBoxElement/css/DropBoxElement.module.css +7 -0
- package/lib/Popup/Popup.js +265 -147
- package/lib/Popup/Registry.js +45 -0
- package/lib/Provider/Config.js +2 -2
- package/lib/common/basic.module.css +0 -2
- package/lib/components_layer.module.css +1 -0
- package/package.json +23 -15
- package/css_error.log +0 -1
- package/install.md +0 -10
- package/postPublish.js +0 -8
- package/prePublish.js +0 -70
- package/react-cli.config.js +0 -24
- package/result.json +0 -1
- /package/.cli/{stringContains.js → themeValidate/stringContains.js} +0 -0
package/lib/Card/Card.js
CHANGED
|
@@ -175,7 +175,9 @@ var Card = /*#__PURE__*/function (_Component3) {
|
|
|
175
175
|
_this2.to = from + 3 * limit;
|
|
176
176
|
_this2.isFetching = false;
|
|
177
177
|
_this2.lastScrollTop = 0;
|
|
178
|
-
_this2.onScroll = _this2.onScroll.bind(_assertThisInitialized(_this2));
|
|
178
|
+
_this2.onScroll = _this2.onScroll.bind(_assertThisInitialized(_this2));
|
|
179
|
+
_this2.setScrollRef = _this2.setScrollRef.bind(_assertThisInitialized(_this2));
|
|
180
|
+
_this2.childEleRef = null; //this.onSetScroll = debounce(this.setScroll.bind(this, true), 10, true);
|
|
179
181
|
//this.onClearScroll = debounce(this.setScroll.bind(this, false), 500);
|
|
180
182
|
|
|
181
183
|
return _this2;
|
|
@@ -204,24 +206,35 @@ var Card = /*#__PURE__*/function (_Component3) {
|
|
|
204
206
|
noMoreData = _this$props3.noMoreData,
|
|
205
207
|
scrollAt = _this$props3.scrollAt,
|
|
206
208
|
noNeedUpScroll = _this$props3.noNeedUpScroll,
|
|
207
|
-
isPercentageScroll = _this$props3.isPercentageScroll
|
|
209
|
+
isPercentageScroll = _this$props3.isPercentageScroll,
|
|
210
|
+
scrollDirection = _this$props3.scrollDirection;
|
|
211
|
+
var scrollLimitHeight = scrollHeight - scrollAt;
|
|
212
|
+
var currentVisibleBottom = scrollTop + offsetHeight;
|
|
208
213
|
|
|
209
214
|
if (scrollTop > this.lastScrollTop) {
|
|
210
|
-
this.
|
|
215
|
+
this.scrollingDirection = 'down';
|
|
211
216
|
} else {
|
|
212
|
-
this.
|
|
217
|
+
this.scrollingDirection = 'up';
|
|
213
218
|
}
|
|
214
219
|
|
|
215
220
|
this.lastScrollTop = scrollTop;
|
|
216
221
|
|
|
217
222
|
if (fetchData && !this.isFetching) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
223
|
+
var fetchDirection = scrollDirection === 'bottomToTop' ? 'up' : 'down';
|
|
224
|
+
|
|
225
|
+
if (this.scrollingDirection === fetchDirection && !noMoreData) {
|
|
226
|
+
var prefetch = false;
|
|
227
|
+
|
|
228
|
+
if (isPercentageScroll) {
|
|
229
|
+
var scrollingPercentage = scrollDirection === 'bottomToTop' ? (scrollHeight - scrollTop) / scrollLimitHeight * 100 : currentVisibleBottom / scrollLimitHeight * 100;
|
|
230
|
+
prefetch = scrollingPercentage >= (0, _Config.getLibraryConfig)('scrollFetchLimit');
|
|
231
|
+
} else {
|
|
232
|
+
prefetch = scrollDirection === 'bottomToTop' ? scrollTop <= scrollAt : scrollLimitHeight <= currentVisibleBottom;
|
|
233
|
+
}
|
|
221
234
|
|
|
222
235
|
if (prefetch) {
|
|
223
236
|
this.isFetching = true;
|
|
224
|
-
fetchData(this.from + this.limit, this.limit + this.to, this.
|
|
237
|
+
fetchData(this.from + this.limit, this.limit + this.to, this.scrollingDirection).then(function () {
|
|
225
238
|
_this3.to = _this3.limit + _this3.to;
|
|
226
239
|
_this3.isFetching = false;
|
|
227
240
|
}, function () {
|
|
@@ -229,9 +242,11 @@ var Card = /*#__PURE__*/function (_Component3) {
|
|
|
229
242
|
});
|
|
230
243
|
}
|
|
231
244
|
} else {
|
|
232
|
-
|
|
245
|
+
var _prefetch = scrollDirection === 'bottomToTop' ? scrollLimitHeight <= currentVisibleBottom : 0 >= scrollTop - scrollAt;
|
|
246
|
+
|
|
247
|
+
if (_prefetch && this.from !== 0 && !noNeedUpScroll) {
|
|
233
248
|
this.isFetching = true;
|
|
234
|
-
fetchData(this.from - this.limit, this.to - this.limit, this.
|
|
249
|
+
fetchData(this.from - this.limit, this.to - this.limit, this.scrollingDirection).then(function () {
|
|
235
250
|
_this3.to = _this3.to - _this3.limit;
|
|
236
251
|
_this3.isFetching = false;
|
|
237
252
|
}, function () {
|
|
@@ -242,9 +257,12 @@ var Card = /*#__PURE__*/function (_Component3) {
|
|
|
242
257
|
}
|
|
243
258
|
|
|
244
259
|
if (fetchData && !noNeedUpScroll) {
|
|
245
|
-
|
|
260
|
+
var topFetch = scrollDirection === 'bottomToTop' ? !noMoreData : !noNeedUpScroll && this.from !== 0;
|
|
261
|
+
var bottomFetch = scrollDirection === 'bottomToTop' ? !noNeedUpScroll && this.from !== 0 : !noMoreData;
|
|
262
|
+
|
|
263
|
+
if (scrollTop === 0 && topFetch) {
|
|
246
264
|
scrollContainerObj.scrollTop = scrollTop + offsetHeight / 3;
|
|
247
|
-
} else if (scrollHeight ===
|
|
265
|
+
} else if (scrollHeight === currentVisibleBottom && bottomFetch) {
|
|
248
266
|
scrollContainerObj.scrollTop = scrollTop - offsetHeight / 2;
|
|
249
267
|
}
|
|
250
268
|
} // if (isScrollShadow) {
|
|
@@ -262,21 +280,36 @@ var Card = /*#__PURE__*/function (_Component3) {
|
|
|
262
280
|
// }
|
|
263
281
|
// }
|
|
264
282
|
|
|
283
|
+
}, {
|
|
284
|
+
key: "setScrollRef",
|
|
285
|
+
value: function setScrollRef(el) {
|
|
286
|
+
var _this$props4 = this.props,
|
|
287
|
+
scrollAt = _this$props4.scrollAt,
|
|
288
|
+
scrollDirection = _this$props4.scrollDirection;
|
|
289
|
+
|
|
290
|
+
if (el && scrollDirection === 'bottomToTop') {
|
|
291
|
+
requestAnimationFrame(function () {
|
|
292
|
+
el.scrollTop = el.scrollHeight + Number(scrollAt);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
this.childEleRef && this.childEleRef(el);
|
|
297
|
+
}
|
|
265
298
|
}, {
|
|
266
299
|
key: "render",
|
|
267
300
|
value: function render() {
|
|
268
301
|
var _this4 = this;
|
|
269
302
|
|
|
270
|
-
var _this$
|
|
271
|
-
onClick = _this$
|
|
272
|
-
children = _this$
|
|
273
|
-
isScrollAttribute = _this$
|
|
274
|
-
dataId = _this$
|
|
275
|
-
eleRef = _this$
|
|
276
|
-
_this$
|
|
277
|
-
customClass = _this$
|
|
278
|
-
htmlId = _this$
|
|
279
|
-
a11y = _this$
|
|
303
|
+
var _this$props5 = this.props,
|
|
304
|
+
onClick = _this$props5.onClick,
|
|
305
|
+
children = _this$props5.children,
|
|
306
|
+
isScrollAttribute = _this$props5.isScrollAttribute,
|
|
307
|
+
dataId = _this$props5.dataId,
|
|
308
|
+
eleRef = _this$props5.eleRef,
|
|
309
|
+
_this$props5$customCl = _this$props5.customClass,
|
|
310
|
+
customClass = _this$props5$customCl === void 0 ? '' : _this$props5$customCl,
|
|
311
|
+
htmlId = _this$props5.htmlId,
|
|
312
|
+
a11y = _this$props5.a11y;
|
|
280
313
|
var isScroll = this.state.isScroll;
|
|
281
314
|
var role = a11y.role;
|
|
282
315
|
return /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
@@ -295,6 +328,7 @@ var Card = /*#__PURE__*/function (_Component3) {
|
|
|
295
328
|
isScroll: isScroll
|
|
296
329
|
});
|
|
297
330
|
} else if (child.type === CardContent || _this4.props.childTypes && child.type === _this4.props.childTypes.cardContent) {
|
|
331
|
+
_this4.childEleRef = child.props.eleRef;
|
|
298
332
|
return /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
299
333
|
id: htmlId,
|
|
300
334
|
role: role,
|
|
@@ -302,7 +336,7 @@ var Card = /*#__PURE__*/function (_Component3) {
|
|
|
302
336
|
scroll: child.props.scroll,
|
|
303
337
|
preventParentScroll: child.props.preventParentScroll,
|
|
304
338
|
onScroll: _this4.onScroll,
|
|
305
|
-
eleRef:
|
|
339
|
+
eleRef: _this4.setScrollRef,
|
|
306
340
|
isScrollAttribute: child.props.isScrollAttribute,
|
|
307
341
|
dataId: child.props.dataId,
|
|
308
342
|
shrink: child.props.shrink,
|
|
@@ -344,11 +378,11 @@ var CardFooter = /*#__PURE__*/function (_Component4) {
|
|
|
344
378
|
_createClass(CardFooter, [{
|
|
345
379
|
key: "render",
|
|
346
380
|
value: function render() {
|
|
347
|
-
var _this$
|
|
348
|
-
children = _this$
|
|
349
|
-
dataId = _this$
|
|
350
|
-
customClass = _this$
|
|
351
|
-
dataSelectorId = _this$
|
|
381
|
+
var _this$props6 = this.props,
|
|
382
|
+
children = _this$props6.children,
|
|
383
|
+
dataId = _this$props6.dataId,
|
|
384
|
+
customClass = _this$props6.customClass,
|
|
385
|
+
dataSelectorId = _this$props6.dataSelectorId;
|
|
352
386
|
return /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
353
387
|
className: "".concat(customClass),
|
|
354
388
|
dataId: dataId,
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
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); }
|
|
4
|
+
|
|
3
5
|
var _react = _interopRequireDefault(require("react"));
|
|
4
6
|
|
|
5
7
|
var _react2 = require("@testing-library/react");
|
|
6
8
|
|
|
7
|
-
var _Card =
|
|
9
|
+
var _Card = _interopRequireWildcard(require("../Card"));
|
|
10
|
+
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
8
14
|
|
|
9
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
16
|
|
|
17
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
18
|
+
|
|
19
|
+
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); } }
|
|
20
|
+
|
|
21
|
+
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); }); }; }
|
|
22
|
+
|
|
11
23
|
describe('Card', function () {
|
|
12
24
|
test('rendering the defult props', function () {
|
|
13
25
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], null)),
|
|
@@ -15,4 +27,109 @@ describe('Card', function () {
|
|
|
15
27
|
|
|
16
28
|
expect(asFragment()).toMatchSnapshot();
|
|
17
29
|
});
|
|
30
|
+
test('should trigger fetch, when scroll to the bottom of the card while isRecentOnBottom = false', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
31
|
+
var mockGetNextOptions, _render2, getByTestId, asFragment, cardContent;
|
|
32
|
+
|
|
33
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
34
|
+
while (1) {
|
|
35
|
+
switch (_context.prev = _context.next) {
|
|
36
|
+
case 0:
|
|
37
|
+
mockGetNextOptions = jest.fn(function () {
|
|
38
|
+
return new Promise(function (resolve) {
|
|
39
|
+
resolve();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
_render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], {
|
|
43
|
+
from: 0,
|
|
44
|
+
limit: 10,
|
|
45
|
+
fetchData: mockGetNextOptions
|
|
46
|
+
}, /*#__PURE__*/_react["default"].createElement(_Card.CardContent, {
|
|
47
|
+
dataId: "scrollToBottomCardContent"
|
|
48
|
+
}, /*#__PURE__*/_react["default"].createElement("div", null, "Hello Zam")))), getByTestId = _render2.getByTestId, asFragment = _render2.asFragment;
|
|
49
|
+
cardContent = getByTestId('scrollToBottomCardContent');
|
|
50
|
+
Object.defineProperty(cardContent, 'scrollHeight', {
|
|
51
|
+
value: 1000,
|
|
52
|
+
writable: true
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(cardContent, 'clientHeight', {
|
|
55
|
+
value: 600,
|
|
56
|
+
writable: true
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(cardContent, 'offsetHeight', {
|
|
59
|
+
value: 600,
|
|
60
|
+
writable: true
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
_react2.fireEvent.scroll(cardContent, {
|
|
64
|
+
target: {
|
|
65
|
+
scrollTop: 401
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
_context.next = 9;
|
|
70
|
+
return (0, _react2.waitFor)(function () {
|
|
71
|
+
expect(asFragment()).toMatchSnapshot();
|
|
72
|
+
expect(mockGetNextOptions).toHaveBeenCalledWith(10, 40, 'down');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
case 9:
|
|
76
|
+
case "end":
|
|
77
|
+
return _context.stop();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}, _callee);
|
|
81
|
+
})));
|
|
82
|
+
test('should trigger fetch, when scroll to the top of the card while scrollDirection = bottomToTop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
83
|
+
var mockGetNextOptions, _render3, getByTestId, asFragment, cardContent;
|
|
84
|
+
|
|
85
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
86
|
+
while (1) {
|
|
87
|
+
switch (_context2.prev = _context2.next) {
|
|
88
|
+
case 0:
|
|
89
|
+
mockGetNextOptions = jest.fn(function () {
|
|
90
|
+
return new Promise(function (resolve) {
|
|
91
|
+
resolve();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
_render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], {
|
|
95
|
+
from: 0,
|
|
96
|
+
limit: 10,
|
|
97
|
+
scrollDirection: "bottomToTop",
|
|
98
|
+
fetchData: mockGetNextOptions
|
|
99
|
+
}, /*#__PURE__*/_react["default"].createElement(_Card.CardContent, {
|
|
100
|
+
dataId: "scrollToTopCardContent"
|
|
101
|
+
}, /*#__PURE__*/_react["default"].createElement("div", null, "Hello Zam")))), getByTestId = _render3.getByTestId, asFragment = _render3.asFragment;
|
|
102
|
+
cardContent = getByTestId('scrollToTopCardContent');
|
|
103
|
+
Object.defineProperty(cardContent, 'scrollHeight', {
|
|
104
|
+
value: 1000,
|
|
105
|
+
writable: true
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(cardContent, 'clientHeight', {
|
|
108
|
+
value: 600,
|
|
109
|
+
writable: true
|
|
110
|
+
});
|
|
111
|
+
Object.defineProperty(cardContent, 'offsetHeight', {
|
|
112
|
+
value: 600,
|
|
113
|
+
writable: true
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
_react2.fireEvent.scroll(cardContent, {
|
|
117
|
+
target: {
|
|
118
|
+
scrollTop: 0
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
_context2.next = 9;
|
|
123
|
+
return (0, _react2.waitFor)(function () {
|
|
124
|
+
expect(asFragment()).toMatchSnapshot();
|
|
125
|
+
expect(mockGetNextOptions).toHaveBeenCalledWith(10, 40, 'up');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
case 9:
|
|
129
|
+
case "end":
|
|
130
|
+
return _context2.stop();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}, _callee2);
|
|
134
|
+
})));
|
|
18
135
|
});
|
|
@@ -10,3 +10,47 @@ exports[`Card rendering the defult props 1`] = `
|
|
|
10
10
|
/>
|
|
11
11
|
</DocumentFragment>
|
|
12
12
|
`;
|
|
13
|
+
|
|
14
|
+
exports[`Card should trigger fetch, when scroll to the bottom of the card while isRecentOnBottom = false 1`] = `
|
|
15
|
+
<DocumentFragment>
|
|
16
|
+
<div
|
|
17
|
+
class="flex cover coldir"
|
|
18
|
+
data-id="containerComponent"
|
|
19
|
+
data-selector-id="container"
|
|
20
|
+
data-test-id="containerComponent"
|
|
21
|
+
>
|
|
22
|
+
<div
|
|
23
|
+
class="grow basis shrinkOff scrolly"
|
|
24
|
+
data-id="scrollToBottomCardContent"
|
|
25
|
+
data-selector-id="cardContent"
|
|
26
|
+
data-test-id="scrollToBottomCardContent"
|
|
27
|
+
>
|
|
28
|
+
<div>
|
|
29
|
+
Hello Zam
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</DocumentFragment>
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
exports[`Card should trigger fetch, when scroll to the top of the card while scrollDirection = bottomToTop 1`] = `
|
|
37
|
+
<DocumentFragment>
|
|
38
|
+
<div
|
|
39
|
+
class="flex cover coldir"
|
|
40
|
+
data-id="containerComponent"
|
|
41
|
+
data-selector-id="container"
|
|
42
|
+
data-test-id="containerComponent"
|
|
43
|
+
>
|
|
44
|
+
<div
|
|
45
|
+
class="grow basis shrinkOff scrolly"
|
|
46
|
+
data-id="scrollToTopCardContent"
|
|
47
|
+
data-selector-id="cardContent"
|
|
48
|
+
data-test-id="scrollToTopCardContent"
|
|
49
|
+
>
|
|
50
|
+
<div>
|
|
51
|
+
Hello Zam
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</DocumentFragment>
|
|
56
|
+
`;
|
|
@@ -10,7 +10,8 @@ var Card_defaultProps = {
|
|
|
10
10
|
onClick: null,
|
|
11
11
|
scrollAt: '10',
|
|
12
12
|
a11y: {},
|
|
13
|
-
isPercentageScroll: false
|
|
13
|
+
isPercentageScroll: false,
|
|
14
|
+
scrollDirection: 'topToBottom'
|
|
14
15
|
};
|
|
15
16
|
exports.Card_defaultProps = Card_defaultProps;
|
|
16
17
|
var CardHeader_defaultProps = {
|
|
@@ -50,7 +50,8 @@ var Card_propTypes = {
|
|
|
50
50
|
role: _propTypes["default"].string
|
|
51
51
|
}),
|
|
52
52
|
isPercentageScroll: _propTypes["default"].bool,
|
|
53
|
-
eleRef: _propTypes["default"].func
|
|
53
|
+
eleRef: _propTypes["default"].func,
|
|
54
|
+
scrollDirection: _propTypes["default"].oneOf(['topToBottom', 'bottomToTop'])
|
|
54
55
|
};
|
|
55
56
|
exports.Card_propTypes = Card_propTypes;
|
|
56
57
|
var CardFooter_propTypes = {
|
|
@@ -18,6 +18,11 @@
|
|
|
18
18
|
box-shadow: var(--dropbox_box_shadow);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
.defaultPalette,
|
|
22
|
+
.darkPalette {
|
|
23
|
+
/*css:theme-validation:ignore*/
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
.defaultPalette, .darkPalette {
|
|
22
27
|
background-color: var(--dropbox_bg_color);
|
|
23
28
|
}
|
|
@@ -207,6 +212,7 @@
|
|
|
207
212
|
height: var(--zd_size10) ;
|
|
208
213
|
width: var(--zd_size10) ;
|
|
209
214
|
box-shadow: 1px -1px 2px 0 var(--dropbox_arrow_box_shadow_color);
|
|
215
|
+
/*css:theme-validation:ignore*/
|
|
210
216
|
background-color: var(--dropbox_bg_color);
|
|
211
217
|
-webkit-transform: rotateZ(-45deg);
|
|
212
218
|
transform: rotateZ(-45deg);
|
|
@@ -419,6 +425,7 @@
|
|
|
419
425
|
.closeBar {
|
|
420
426
|
/* Variable:Ignore */
|
|
421
427
|
height: 6px;
|
|
428
|
+
/*css:theme-validation:ignore*/
|
|
422
429
|
width: 20% ;
|
|
423
430
|
border-radius: 5px;
|
|
424
431
|
background-color: var(--dropbox_mob_close_bg_color);
|