@yosgo/swap-ui 1.0.130 → 1.0.131

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/build/index.js CHANGED
@@ -2975,6 +2975,439 @@ var SegmentedTab = function (props) {
2975
2975
  return (React__default.createElement(MaterialTab, __assign({}, other, { disableRipple: true, classes: { textColorInherit: classes.text }, className: classes.root })));
2976
2976
  };
2977
2977
 
2978
+ var smoothscroll = createCommonjsModule(function (module, exports) {
2979
+ /* smoothscroll v0.4.4 - 2019 - Dustan Kasten, Jeremias Menichelli - MIT License */
2980
+ (function () {
2981
+
2982
+ // polyfill
2983
+ function polyfill() {
2984
+ // aliases
2985
+ var w = window;
2986
+ var d = document;
2987
+
2988
+ // return if scroll behavior is supported and polyfill is not forced
2989
+ if (
2990
+ 'scrollBehavior' in d.documentElement.style &&
2991
+ w.__forceSmoothScrollPolyfill__ !== true
2992
+ ) {
2993
+ return;
2994
+ }
2995
+
2996
+ // globals
2997
+ var Element = w.HTMLElement || w.Element;
2998
+ var SCROLL_TIME = 468;
2999
+
3000
+ // object gathering original scroll methods
3001
+ var original = {
3002
+ scroll: w.scroll || w.scrollTo,
3003
+ scrollBy: w.scrollBy,
3004
+ elementScroll: Element.prototype.scroll || scrollElement,
3005
+ scrollIntoView: Element.prototype.scrollIntoView
3006
+ };
3007
+
3008
+ // define timing method
3009
+ var now =
3010
+ w.performance && w.performance.now
3011
+ ? w.performance.now.bind(w.performance)
3012
+ : Date.now;
3013
+
3014
+ /**
3015
+ * indicates if a the current browser is made by Microsoft
3016
+ * @method isMicrosoftBrowser
3017
+ * @param {String} userAgent
3018
+ * @returns {Boolean}
3019
+ */
3020
+ function isMicrosoftBrowser(userAgent) {
3021
+ var userAgentPatterns = ['MSIE ', 'Trident/', 'Edge/'];
3022
+
3023
+ return new RegExp(userAgentPatterns.join('|')).test(userAgent);
3024
+ }
3025
+
3026
+ /*
3027
+ * IE has rounding bug rounding down clientHeight and clientWidth and
3028
+ * rounding up scrollHeight and scrollWidth causing false positives
3029
+ * on hasScrollableSpace
3030
+ */
3031
+ var ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0;
3032
+
3033
+ /**
3034
+ * changes scroll position inside an element
3035
+ * @method scrollElement
3036
+ * @param {Number} x
3037
+ * @param {Number} y
3038
+ * @returns {undefined}
3039
+ */
3040
+ function scrollElement(x, y) {
3041
+ this.scrollLeft = x;
3042
+ this.scrollTop = y;
3043
+ }
3044
+
3045
+ /**
3046
+ * returns result of applying ease math function to a number
3047
+ * @method ease
3048
+ * @param {Number} k
3049
+ * @returns {Number}
3050
+ */
3051
+ function ease(k) {
3052
+ return 0.5 * (1 - Math.cos(Math.PI * k));
3053
+ }
3054
+
3055
+ /**
3056
+ * indicates if a smooth behavior should be applied
3057
+ * @method shouldBailOut
3058
+ * @param {Number|Object} firstArg
3059
+ * @returns {Boolean}
3060
+ */
3061
+ function shouldBailOut(firstArg) {
3062
+ if (
3063
+ firstArg === null ||
3064
+ typeof firstArg !== 'object' ||
3065
+ firstArg.behavior === undefined ||
3066
+ firstArg.behavior === 'auto' ||
3067
+ firstArg.behavior === 'instant'
3068
+ ) {
3069
+ // first argument is not an object/null
3070
+ // or behavior is auto, instant or undefined
3071
+ return true;
3072
+ }
3073
+
3074
+ if (typeof firstArg === 'object' && firstArg.behavior === 'smooth') {
3075
+ // first argument is an object and behavior is smooth
3076
+ return false;
3077
+ }
3078
+
3079
+ // throw error when behavior is not supported
3080
+ throw new TypeError(
3081
+ 'behavior member of ScrollOptions ' +
3082
+ firstArg.behavior +
3083
+ ' is not a valid value for enumeration ScrollBehavior.'
3084
+ );
3085
+ }
3086
+
3087
+ /**
3088
+ * indicates if an element has scrollable space in the provided axis
3089
+ * @method hasScrollableSpace
3090
+ * @param {Node} el
3091
+ * @param {String} axis
3092
+ * @returns {Boolean}
3093
+ */
3094
+ function hasScrollableSpace(el, axis) {
3095
+ if (axis === 'Y') {
3096
+ return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;
3097
+ }
3098
+
3099
+ if (axis === 'X') {
3100
+ return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;
3101
+ }
3102
+ }
3103
+
3104
+ /**
3105
+ * indicates if an element has a scrollable overflow property in the axis
3106
+ * @method canOverflow
3107
+ * @param {Node} el
3108
+ * @param {String} axis
3109
+ * @returns {Boolean}
3110
+ */
3111
+ function canOverflow(el, axis) {
3112
+ var overflowValue = w.getComputedStyle(el, null)['overflow' + axis];
3113
+
3114
+ return overflowValue === 'auto' || overflowValue === 'scroll';
3115
+ }
3116
+
3117
+ /**
3118
+ * indicates if an element can be scrolled in either axis
3119
+ * @method isScrollable
3120
+ * @param {Node} el
3121
+ * @param {String} axis
3122
+ * @returns {Boolean}
3123
+ */
3124
+ function isScrollable(el) {
3125
+ var isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y');
3126
+ var isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X');
3127
+
3128
+ return isScrollableY || isScrollableX;
3129
+ }
3130
+
3131
+ /**
3132
+ * finds scrollable parent of an element
3133
+ * @method findScrollableParent
3134
+ * @param {Node} el
3135
+ * @returns {Node} el
3136
+ */
3137
+ function findScrollableParent(el) {
3138
+ while (el !== d.body && isScrollable(el) === false) {
3139
+ el = el.parentNode || el.host;
3140
+ }
3141
+
3142
+ return el;
3143
+ }
3144
+
3145
+ /**
3146
+ * self invoked function that, given a context, steps through scrolling
3147
+ * @method step
3148
+ * @param {Object} context
3149
+ * @returns {undefined}
3150
+ */
3151
+ function step(context) {
3152
+ var time = now();
3153
+ var value;
3154
+ var currentX;
3155
+ var currentY;
3156
+ var elapsed = (time - context.startTime) / SCROLL_TIME;
3157
+
3158
+ // avoid elapsed times higher than one
3159
+ elapsed = elapsed > 1 ? 1 : elapsed;
3160
+
3161
+ // apply easing to elapsed time
3162
+ value = ease(elapsed);
3163
+
3164
+ currentX = context.startX + (context.x - context.startX) * value;
3165
+ currentY = context.startY + (context.y - context.startY) * value;
3166
+
3167
+ context.method.call(context.scrollable, currentX, currentY);
3168
+
3169
+ // scroll more if we have not reached our destination
3170
+ if (currentX !== context.x || currentY !== context.y) {
3171
+ w.requestAnimationFrame(step.bind(w, context));
3172
+ }
3173
+ }
3174
+
3175
+ /**
3176
+ * scrolls window or element with a smooth behavior
3177
+ * @method smoothScroll
3178
+ * @param {Object|Node} el
3179
+ * @param {Number} x
3180
+ * @param {Number} y
3181
+ * @returns {undefined}
3182
+ */
3183
+ function smoothScroll(el, x, y) {
3184
+ var scrollable;
3185
+ var startX;
3186
+ var startY;
3187
+ var method;
3188
+ var startTime = now();
3189
+
3190
+ // define scroll context
3191
+ if (el === d.body) {
3192
+ scrollable = w;
3193
+ startX = w.scrollX || w.pageXOffset;
3194
+ startY = w.scrollY || w.pageYOffset;
3195
+ method = original.scroll;
3196
+ } else {
3197
+ scrollable = el;
3198
+ startX = el.scrollLeft;
3199
+ startY = el.scrollTop;
3200
+ method = scrollElement;
3201
+ }
3202
+
3203
+ // scroll looping over a frame
3204
+ step({
3205
+ scrollable: scrollable,
3206
+ method: method,
3207
+ startTime: startTime,
3208
+ startX: startX,
3209
+ startY: startY,
3210
+ x: x,
3211
+ y: y
3212
+ });
3213
+ }
3214
+
3215
+ // ORIGINAL METHODS OVERRIDES
3216
+ // w.scroll and w.scrollTo
3217
+ w.scroll = w.scrollTo = function() {
3218
+ // avoid action when no arguments are passed
3219
+ if (arguments[0] === undefined) {
3220
+ return;
3221
+ }
3222
+
3223
+ // avoid smooth behavior if not required
3224
+ if (shouldBailOut(arguments[0]) === true) {
3225
+ original.scroll.call(
3226
+ w,
3227
+ arguments[0].left !== undefined
3228
+ ? arguments[0].left
3229
+ : typeof arguments[0] !== 'object'
3230
+ ? arguments[0]
3231
+ : w.scrollX || w.pageXOffset,
3232
+ // use top prop, second argument if present or fallback to scrollY
3233
+ arguments[0].top !== undefined
3234
+ ? arguments[0].top
3235
+ : arguments[1] !== undefined
3236
+ ? arguments[1]
3237
+ : w.scrollY || w.pageYOffset
3238
+ );
3239
+
3240
+ return;
3241
+ }
3242
+
3243
+ // LET THE SMOOTHNESS BEGIN!
3244
+ smoothScroll.call(
3245
+ w,
3246
+ d.body,
3247
+ arguments[0].left !== undefined
3248
+ ? ~~arguments[0].left
3249
+ : w.scrollX || w.pageXOffset,
3250
+ arguments[0].top !== undefined
3251
+ ? ~~arguments[0].top
3252
+ : w.scrollY || w.pageYOffset
3253
+ );
3254
+ };
3255
+
3256
+ // w.scrollBy
3257
+ w.scrollBy = function() {
3258
+ // avoid action when no arguments are passed
3259
+ if (arguments[0] === undefined) {
3260
+ return;
3261
+ }
3262
+
3263
+ // avoid smooth behavior if not required
3264
+ if (shouldBailOut(arguments[0])) {
3265
+ original.scrollBy.call(
3266
+ w,
3267
+ arguments[0].left !== undefined
3268
+ ? arguments[0].left
3269
+ : typeof arguments[0] !== 'object' ? arguments[0] : 0,
3270
+ arguments[0].top !== undefined
3271
+ ? arguments[0].top
3272
+ : arguments[1] !== undefined ? arguments[1] : 0
3273
+ );
3274
+
3275
+ return;
3276
+ }
3277
+
3278
+ // LET THE SMOOTHNESS BEGIN!
3279
+ smoothScroll.call(
3280
+ w,
3281
+ d.body,
3282
+ ~~arguments[0].left + (w.scrollX || w.pageXOffset),
3283
+ ~~arguments[0].top + (w.scrollY || w.pageYOffset)
3284
+ );
3285
+ };
3286
+
3287
+ // Element.prototype.scroll and Element.prototype.scrollTo
3288
+ Element.prototype.scroll = Element.prototype.scrollTo = function() {
3289
+ // avoid action when no arguments are passed
3290
+ if (arguments[0] === undefined) {
3291
+ return;
3292
+ }
3293
+
3294
+ // avoid smooth behavior if not required
3295
+ if (shouldBailOut(arguments[0]) === true) {
3296
+ // if one number is passed, throw error to match Firefox implementation
3297
+ if (typeof arguments[0] === 'number' && arguments[1] === undefined) {
3298
+ throw new SyntaxError('Value could not be converted');
3299
+ }
3300
+
3301
+ original.elementScroll.call(
3302
+ this,
3303
+ // use left prop, first number argument or fallback to scrollLeft
3304
+ arguments[0].left !== undefined
3305
+ ? ~~arguments[0].left
3306
+ : typeof arguments[0] !== 'object' ? ~~arguments[0] : this.scrollLeft,
3307
+ // use top prop, second argument or fallback to scrollTop
3308
+ arguments[0].top !== undefined
3309
+ ? ~~arguments[0].top
3310
+ : arguments[1] !== undefined ? ~~arguments[1] : this.scrollTop
3311
+ );
3312
+
3313
+ return;
3314
+ }
3315
+
3316
+ var left = arguments[0].left;
3317
+ var top = arguments[0].top;
3318
+
3319
+ // LET THE SMOOTHNESS BEGIN!
3320
+ smoothScroll.call(
3321
+ this,
3322
+ this,
3323
+ typeof left === 'undefined' ? this.scrollLeft : ~~left,
3324
+ typeof top === 'undefined' ? this.scrollTop : ~~top
3325
+ );
3326
+ };
3327
+
3328
+ // Element.prototype.scrollBy
3329
+ Element.prototype.scrollBy = function() {
3330
+ // avoid action when no arguments are passed
3331
+ if (arguments[0] === undefined) {
3332
+ return;
3333
+ }
3334
+
3335
+ // avoid smooth behavior if not required
3336
+ if (shouldBailOut(arguments[0]) === true) {
3337
+ original.elementScroll.call(
3338
+ this,
3339
+ arguments[0].left !== undefined
3340
+ ? ~~arguments[0].left + this.scrollLeft
3341
+ : ~~arguments[0] + this.scrollLeft,
3342
+ arguments[0].top !== undefined
3343
+ ? ~~arguments[0].top + this.scrollTop
3344
+ : ~~arguments[1] + this.scrollTop
3345
+ );
3346
+
3347
+ return;
3348
+ }
3349
+
3350
+ this.scroll({
3351
+ left: ~~arguments[0].left + this.scrollLeft,
3352
+ top: ~~arguments[0].top + this.scrollTop,
3353
+ behavior: arguments[0].behavior
3354
+ });
3355
+ };
3356
+
3357
+ // Element.prototype.scrollIntoView
3358
+ Element.prototype.scrollIntoView = function() {
3359
+ // avoid smooth behavior if not required
3360
+ if (shouldBailOut(arguments[0]) === true) {
3361
+ original.scrollIntoView.call(
3362
+ this,
3363
+ arguments[0] === undefined ? true : arguments[0]
3364
+ );
3365
+
3366
+ return;
3367
+ }
3368
+
3369
+ // LET THE SMOOTHNESS BEGIN!
3370
+ var scrollableParent = findScrollableParent(this);
3371
+ var parentRects = scrollableParent.getBoundingClientRect();
3372
+ var clientRects = this.getBoundingClientRect();
3373
+
3374
+ if (scrollableParent !== d.body) {
3375
+ // reveal element inside parent
3376
+ smoothScroll.call(
3377
+ this,
3378
+ scrollableParent,
3379
+ scrollableParent.scrollLeft + clientRects.left - parentRects.left,
3380
+ scrollableParent.scrollTop + clientRects.top - parentRects.top
3381
+ );
3382
+
3383
+ // reveal parent in viewport unless is fixed
3384
+ if (w.getComputedStyle(scrollableParent).position !== 'fixed') {
3385
+ w.scrollBy({
3386
+ left: parentRects.left,
3387
+ top: parentRects.top,
3388
+ behavior: 'smooth'
3389
+ });
3390
+ }
3391
+ } else {
3392
+ // reveal element in viewport
3393
+ w.scrollBy({
3394
+ left: clientRects.left,
3395
+ top: clientRects.top,
3396
+ behavior: 'smooth'
3397
+ });
3398
+ }
3399
+ };
3400
+ }
3401
+
3402
+ {
3403
+ // commonjs
3404
+ module.exports = { polyfill: polyfill };
3405
+ }
3406
+
3407
+ }());
3408
+ });
3409
+ var smoothscroll_1 = smoothscroll.polyfill;
3410
+
2978
3411
  var useStyles$5 = core.makeStyles(function (theme) { return ({
2979
3412
  root: function (props) { return ({
2980
3413
  width: props.width,
@@ -3013,6 +3446,7 @@ var SegmentedTabs = function (_a) {
3013
3446
  var classes = useStyles$5(styleProps);
3014
3447
  var tabsRef = React.useRef(null);
3015
3448
  React.useEffect(function () {
3449
+ smoothscroll.polyfill();
3016
3450
  if (tabsRef &&
3017
3451
  tabsRef.current &&
3018
3452
  other.variant &&
@@ -3023,8 +3457,8 @@ var SegmentedTabs = function (_a) {
3023
3457
  setTimeout(function () {
3024
3458
  el_1.scrollIntoView({
3025
3459
  behavior: "smooth",
3026
- block: "end",
3027
- inline: "nearest",
3460
+ block: "nearest",
3461
+ inline: "center",
3028
3462
  });
3029
3463
  }, 1000);
3030
3464
  }