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