@yosgo/swap-ui 1.0.130 → 1.0.132
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 +1 -1
- package/build/index.esm.js +488 -58
- package/build/index.esm.js.map +1 -1
- package/build/index.js +488 -58
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -182,46 +182,42 @@ var templateObject_1;
|
|
|
182
182
|
|
|
183
183
|
var SWAPSpace = function (_a) {
|
|
184
184
|
var size = _a.size;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
else
|
|
222
|
-
return 16;
|
|
223
|
-
});
|
|
224
|
-
var templateObject_1$1;
|
|
185
|
+
var height = function () {
|
|
186
|
+
if (size === "xxs") {
|
|
187
|
+
return 4;
|
|
188
|
+
}
|
|
189
|
+
else if (size === "xs") {
|
|
190
|
+
return 8;
|
|
191
|
+
}
|
|
192
|
+
else if (size === "s") {
|
|
193
|
+
return 12;
|
|
194
|
+
}
|
|
195
|
+
else if (size === "m") {
|
|
196
|
+
return 16;
|
|
197
|
+
}
|
|
198
|
+
else if (size === "l") {
|
|
199
|
+
return 24;
|
|
200
|
+
}
|
|
201
|
+
else if (size === "xl") {
|
|
202
|
+
return 32;
|
|
203
|
+
}
|
|
204
|
+
else if (size === "2xl") {
|
|
205
|
+
return 40;
|
|
206
|
+
}
|
|
207
|
+
else if (size === "3xl") {
|
|
208
|
+
return 48;
|
|
209
|
+
}
|
|
210
|
+
else if (size === "4xl") {
|
|
211
|
+
return 56;
|
|
212
|
+
}
|
|
213
|
+
else if (typeof size === "number") {
|
|
214
|
+
return size;
|
|
215
|
+
}
|
|
216
|
+
else
|
|
217
|
+
return 16;
|
|
218
|
+
};
|
|
219
|
+
return React__default.createElement("div", { style: { height: height() + "px" } });
|
|
220
|
+
};
|
|
225
221
|
|
|
226
222
|
var SWAPAppBar = function (_a) {
|
|
227
223
|
var logo = _a.logo, primaryButton = _a.primaryButton, secondaryButton = _a.secondaryButton, navigations = _a.navigations;
|
|
@@ -277,8 +273,8 @@ var SWAPAppBar = function (_a) {
|
|
|
277
273
|
primaryButton.title.length > 0 ? (React__default.createElement(core.MenuItem, { disabled: primaryButton.disabled, onClick: function () { return primaryButton.onClick(); } }, primaryButton.title)) : null))))),
|
|
278
274
|
React__default.createElement(SWAPSpace, { size: "s" })))))));
|
|
279
275
|
};
|
|
280
|
-
var SWAPAppBarWrap = styled.div(templateObject_1$
|
|
281
|
-
var templateObject_1$
|
|
276
|
+
var SWAPAppBarWrap = styled.div(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n .mobile_hide {\n @media screen and (max-width: 960px) {\n display: none;\n }\n }\n .mobile_show {\n display: none;\n @media screen and (max-width: 960px) {\n display: block;\n }\n }\n"], ["\n .mobile_hide {\n @media screen and (max-width: 960px) {\n display: none;\n }\n }\n .mobile_show {\n display: none;\n @media screen and (max-width: 960px) {\n display: block;\n }\n }\n"])));
|
|
277
|
+
var templateObject_1$1;
|
|
282
278
|
|
|
283
279
|
var ElementId = function (title) { return "swap_banner_" + title; };
|
|
284
280
|
var SWAPBanner = function (_a) {
|
|
@@ -320,8 +316,8 @@ var SWAPBanner = function (_a) {
|
|
|
320
316
|
React__default.createElement(core.Button, { variant: "text", onClick: function () { return secondaryButton.onClick(); }, disabled: secondaryButton.disabled }, secondaryButton.title))) : null)) : null,
|
|
321
317
|
React__default.createElement(SWAPSpace, { size: "l" })))))));
|
|
322
318
|
};
|
|
323
|
-
var SWAPBannerWrap = styled.div(templateObject_1$
|
|
324
|
-
var templateObject_1$
|
|
319
|
+
var SWAPBannerWrap = styled.div(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n .swap_banner {\n position: relative;\n overflow: hidden;\n .banner_anchor {\n position: absolute;\n top: -36px;\n left: 0;\n width: 0;\n height: 0;\n }\n .bar {\n height: 12px;\n &.s_bar {\n background: #3f51b5;\n }\n &.w_bar {\n background: #ffb11b;\n }\n &.c_bar {\n background: rgb(220, 0, 78);\n }\n }\n }\n"], ["\n .swap_banner {\n position: relative;\n overflow: hidden;\n .banner_anchor {\n position: absolute;\n top: -36px;\n left: 0;\n width: 0;\n height: 0;\n }\n .bar {\n height: 12px;\n &.s_bar {\n background: #3f51b5;\n }\n &.w_bar {\n background: #ffb11b;\n }\n &.c_bar {\n background: rgb(220, 0, 78);\n }\n }\n }\n"])));
|
|
320
|
+
var templateObject_1$2;
|
|
325
321
|
|
|
326
322
|
function unwrapExports (x) {
|
|
327
323
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -620,8 +616,8 @@ var SWAPCopyField = function (_a) {
|
|
|
620
616
|
React__default.createElement("small", null, copyButtonText)))))),
|
|
621
617
|
} }))));
|
|
622
618
|
};
|
|
623
|
-
var SWAPCopyFieldWrap = styled.div(templateObject_1$
|
|
624
|
-
var templateObject_1$
|
|
619
|
+
var SWAPCopyFieldWrap = styled.div(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n .cpy_btn_element {\n width: auto;\n min-width: 72px;\n text-align: right;\n }\n"], ["\n .cpy_btn_element {\n width: auto;\n min-width: 72px;\n text-align: right;\n }\n"])));
|
|
620
|
+
var templateObject_1$3;
|
|
625
621
|
|
|
626
622
|
var SWAPDialog = function (_a) {
|
|
627
623
|
var open = _a.open, title = _a.title, helpText = _a.helpText, children = _a.children, primaryButton = _a.primaryButton, secondaryButton = _a.secondaryButton, status = _a.status;
|
|
@@ -659,8 +655,8 @@ var SWAPDialog = function (_a) {
|
|
|
659
655
|
React__default.createElement(core.Grid, { item: true }, primaryButton && primaryButton.title ? (React__default.createElement(core.Button, { size: "large", onClick: function () { return primaryButton.onClick(); }, disabled: primaryButton.disabled }, primaryButton.title)) : null)),
|
|
660
656
|
React__default.createElement(SWAPSpace, { size: "s" }))))))))));
|
|
661
657
|
};
|
|
662
|
-
var SWAPDialogWrap = styled.div(templateObject_1$
|
|
663
|
-
var templateObject_1$
|
|
658
|
+
var SWAPDialogWrap = styled.div(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["\n box-sizing: border-box;\n position: relative;\n .bar {\n position: absolute;\n height: 12px;\n top: 0;\n left: 0;\n width: 100%;\n &.s_bar {\n background: #3f51b5;\n }\n &.w_bar {\n background: #ffb11b;\n }\n &.c_bar {\n background: rgb(220, 0, 78);\n }\n }\n .dialog_inner {\n margin-top: 12px;\n }\n"], ["\n box-sizing: border-box;\n position: relative;\n .bar {\n position: absolute;\n height: 12px;\n top: 0;\n left: 0;\n width: 100%;\n &.s_bar {\n background: #3f51b5;\n }\n &.w_bar {\n background: #ffb11b;\n }\n &.c_bar {\n background: rgb(220, 0, 78);\n }\n }\n .dialog_inner {\n margin-top: 12px;\n }\n"])));
|
|
659
|
+
var templateObject_1$4;
|
|
664
660
|
|
|
665
661
|
var ModalOpenEffect = function (props) {
|
|
666
662
|
return (React__default.createElement(React__default.Fragment, null, props.sm ? (React__default.createElement(core.Slide, { in: props.in, direction: "up", mountOnEnter: true, unmountOnExit: true, timeout: { enter: 300, exit: 300 } },
|
|
@@ -785,8 +781,8 @@ var SWAPModal = function (_a) {
|
|
|
785
781
|
React__default.createElement(core.Button, { variant: "text", size: sm ? "medium" : "large", onClick: function () { return handleStepButton("next"); } }, steps[stepIndex].nextStepText || "下一步"))))),
|
|
786
782
|
React__default.createElement(SWAPSpace, { size: "m" })))))))));
|
|
787
783
|
};
|
|
788
|
-
var SWAPModalWrap = styled.div(templateObject_1$
|
|
789
|
-
var templateObject_1$
|
|
784
|
+
var SWAPModalWrap = styled.div(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n outline: 0px;\n position: absolute;\n height: 100vh;\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n .modal_inner {\n border-radius: 9px;\n overflow: hidden;\n position: relative;\n width: 48vw;\n z-index: 2;\n .modal_inner_header {\n position: absolute;\n width: 100%;\n left: 0;\n top: 0;\n background: white;\n z-index: 1;\n }\n .modal_inner_body {\n position: relative;\n overflow-y: auto;\n z-index: 1;\n }\n .modal_inner_bottom {\n position: absolute;\n width: 100%;\n left: 0;\n bottom: 0;\n background: white;\n z-index: 1;\n }\n }\n @media screen and (max-width: 960px) {\n align-items: flex-end;\n .modal_inner {\n border-bottom-left-radius: 0px;\n border-bottom-right-radius: 0px;\n width: 100vw;\n }\n }\n"], ["\n outline: 0px;\n position: absolute;\n height: 100vh;\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n .modal_inner {\n border-radius: 9px;\n overflow: hidden;\n position: relative;\n width: 48vw;\n z-index: 2;\n .modal_inner_header {\n position: absolute;\n width: 100%;\n left: 0;\n top: 0;\n background: white;\n z-index: 1;\n }\n .modal_inner_body {\n position: relative;\n overflow-y: auto;\n z-index: 1;\n }\n .modal_inner_bottom {\n position: absolute;\n width: 100%;\n left: 0;\n bottom: 0;\n background: white;\n z-index: 1;\n }\n }\n @media screen and (max-width: 960px) {\n align-items: flex-end;\n .modal_inner {\n border-bottom-left-radius: 0px;\n border-bottom-right-radius: 0px;\n width: 100vw;\n }\n }\n"])));
|
|
785
|
+
var templateObject_1$5;
|
|
790
786
|
|
|
791
787
|
function objectToGetParams(object) {
|
|
792
788
|
var params = Object.entries(object)
|
|
@@ -1371,8 +1367,8 @@ var SWAPShare = function (_a) {
|
|
|
1371
1367
|
},
|
|
1372
1368
|
].map(function (item, index) { return (React__default.createElement("div", { key: "share_btn_" + index }, item.el)); })));
|
|
1373
1369
|
};
|
|
1374
|
-
var SWAPShareWrap = styled.div(templateObject_1$
|
|
1375
|
-
var templateObject_1$
|
|
1370
|
+
var SWAPShareWrap = styled.div(templateObject_1$6 || (templateObject_1$6 = __makeTemplateObject(["\n height: 40px;\n position: relative;\n .swap_share_icon {\n cursor: pointer;\n }\n"], ["\n height: 40px;\n position: relative;\n .swap_share_icon {\n cursor: pointer;\n }\n"])));
|
|
1371
|
+
var templateObject_1$6;
|
|
1376
1372
|
|
|
1377
1373
|
var SWAPTaxField = function (_a) {
|
|
1378
1374
|
var onChange = _a.onChange, taxDescription = _a.taxDescription;
|
|
@@ -1538,7 +1534,7 @@ var SWAPTaxField = function (_a) {
|
|
|
1538
1534
|
}
|
|
1539
1535
|
})()))) })) }))))));
|
|
1540
1536
|
};
|
|
1541
|
-
var SWAPTaxFieldWrap = styled.div(templateObject_1$
|
|
1537
|
+
var SWAPTaxFieldWrap = styled.div(templateObject_1$7 || (templateObject_1$7 = __makeTemplateObject(["\n .option_item::-webkit-scrollbar {\n width: 0 !important;\n height: 0 !important;\n }\n"], ["\n .option_item::-webkit-scrollbar {\n width: 0 !important;\n height: 0 !important;\n }\n"])));
|
|
1542
1538
|
var typeOptions = [
|
|
1543
1539
|
["文字", "1"],
|
|
1544
1540
|
["設計", "2"],
|
|
@@ -1828,7 +1824,7 @@ var SWAPTaxDescription = function (incomeCode, expenseCode) {
|
|
|
1828
1824
|
return "";
|
|
1829
1825
|
}
|
|
1830
1826
|
};
|
|
1831
|
-
var templateObject_1$
|
|
1827
|
+
var templateObject_1$7;
|
|
1832
1828
|
/**
|
|
1833
1829
|
* 邏輯設定
|
|
1834
1830
|
* 1. 所得類別為 9A, 9B 時,費用類別為必填
|
|
@@ -2165,8 +2161,8 @@ var Styles = function (_a) {
|
|
|
2165
2161
|
" ",
|
|
2166
2162
|
copySuccess ? "已複製!" : null))));
|
|
2167
2163
|
};
|
|
2168
|
-
var StylesWrap = styled.div(templateObject_1$
|
|
2169
|
-
var templateObject_1$
|
|
2164
|
+
var StylesWrap = styled.div(templateObject_1$8 || (templateObject_1$8 = __makeTemplateObject([""], [""])));
|
|
2165
|
+
var templateObject_1$8;
|
|
2170
2166
|
|
|
2171
2167
|
var Typography = function (_a) {
|
|
2172
2168
|
var variant = _a.variant, children = _a.children, mode = _a.mode, color = _a.color, style = _a.style;
|
|
@@ -2975,6 +2971,439 @@ var SegmentedTab = function (props) {
|
|
|
2975
2971
|
return (React__default.createElement(MaterialTab, __assign({}, other, { disableRipple: true, classes: { textColorInherit: classes.text }, className: classes.root })));
|
|
2976
2972
|
};
|
|
2977
2973
|
|
|
2974
|
+
var smoothscroll = createCommonjsModule(function (module, exports) {
|
|
2975
|
+
/* smoothscroll v0.4.4 - 2019 - Dustan Kasten, Jeremias Menichelli - MIT License */
|
|
2976
|
+
(function () {
|
|
2977
|
+
|
|
2978
|
+
// polyfill
|
|
2979
|
+
function polyfill() {
|
|
2980
|
+
// aliases
|
|
2981
|
+
var w = window;
|
|
2982
|
+
var d = document;
|
|
2983
|
+
|
|
2984
|
+
// return if scroll behavior is supported and polyfill is not forced
|
|
2985
|
+
if (
|
|
2986
|
+
'scrollBehavior' in d.documentElement.style &&
|
|
2987
|
+
w.__forceSmoothScrollPolyfill__ !== true
|
|
2988
|
+
) {
|
|
2989
|
+
return;
|
|
2990
|
+
}
|
|
2991
|
+
|
|
2992
|
+
// globals
|
|
2993
|
+
var Element = w.HTMLElement || w.Element;
|
|
2994
|
+
var SCROLL_TIME = 468;
|
|
2995
|
+
|
|
2996
|
+
// object gathering original scroll methods
|
|
2997
|
+
var original = {
|
|
2998
|
+
scroll: w.scroll || w.scrollTo,
|
|
2999
|
+
scrollBy: w.scrollBy,
|
|
3000
|
+
elementScroll: Element.prototype.scroll || scrollElement,
|
|
3001
|
+
scrollIntoView: Element.prototype.scrollIntoView
|
|
3002
|
+
};
|
|
3003
|
+
|
|
3004
|
+
// define timing method
|
|
3005
|
+
var now =
|
|
3006
|
+
w.performance && w.performance.now
|
|
3007
|
+
? w.performance.now.bind(w.performance)
|
|
3008
|
+
: Date.now;
|
|
3009
|
+
|
|
3010
|
+
/**
|
|
3011
|
+
* indicates if a the current browser is made by Microsoft
|
|
3012
|
+
* @method isMicrosoftBrowser
|
|
3013
|
+
* @param {String} userAgent
|
|
3014
|
+
* @returns {Boolean}
|
|
3015
|
+
*/
|
|
3016
|
+
function isMicrosoftBrowser(userAgent) {
|
|
3017
|
+
var userAgentPatterns = ['MSIE ', 'Trident/', 'Edge/'];
|
|
3018
|
+
|
|
3019
|
+
return new RegExp(userAgentPatterns.join('|')).test(userAgent);
|
|
3020
|
+
}
|
|
3021
|
+
|
|
3022
|
+
/*
|
|
3023
|
+
* IE has rounding bug rounding down clientHeight and clientWidth and
|
|
3024
|
+
* rounding up scrollHeight and scrollWidth causing false positives
|
|
3025
|
+
* on hasScrollableSpace
|
|
3026
|
+
*/
|
|
3027
|
+
var ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0;
|
|
3028
|
+
|
|
3029
|
+
/**
|
|
3030
|
+
* changes scroll position inside an element
|
|
3031
|
+
* @method scrollElement
|
|
3032
|
+
* @param {Number} x
|
|
3033
|
+
* @param {Number} y
|
|
3034
|
+
* @returns {undefined}
|
|
3035
|
+
*/
|
|
3036
|
+
function scrollElement(x, y) {
|
|
3037
|
+
this.scrollLeft = x;
|
|
3038
|
+
this.scrollTop = y;
|
|
3039
|
+
}
|
|
3040
|
+
|
|
3041
|
+
/**
|
|
3042
|
+
* returns result of applying ease math function to a number
|
|
3043
|
+
* @method ease
|
|
3044
|
+
* @param {Number} k
|
|
3045
|
+
* @returns {Number}
|
|
3046
|
+
*/
|
|
3047
|
+
function ease(k) {
|
|
3048
|
+
return 0.5 * (1 - Math.cos(Math.PI * k));
|
|
3049
|
+
}
|
|
3050
|
+
|
|
3051
|
+
/**
|
|
3052
|
+
* indicates if a smooth behavior should be applied
|
|
3053
|
+
* @method shouldBailOut
|
|
3054
|
+
* @param {Number|Object} firstArg
|
|
3055
|
+
* @returns {Boolean}
|
|
3056
|
+
*/
|
|
3057
|
+
function shouldBailOut(firstArg) {
|
|
3058
|
+
if (
|
|
3059
|
+
firstArg === null ||
|
|
3060
|
+
typeof firstArg !== 'object' ||
|
|
3061
|
+
firstArg.behavior === undefined ||
|
|
3062
|
+
firstArg.behavior === 'auto' ||
|
|
3063
|
+
firstArg.behavior === 'instant'
|
|
3064
|
+
) {
|
|
3065
|
+
// first argument is not an object/null
|
|
3066
|
+
// or behavior is auto, instant or undefined
|
|
3067
|
+
return true;
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3070
|
+
if (typeof firstArg === 'object' && firstArg.behavior === 'smooth') {
|
|
3071
|
+
// first argument is an object and behavior is smooth
|
|
3072
|
+
return false;
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
// throw error when behavior is not supported
|
|
3076
|
+
throw new TypeError(
|
|
3077
|
+
'behavior member of ScrollOptions ' +
|
|
3078
|
+
firstArg.behavior +
|
|
3079
|
+
' is not a valid value for enumeration ScrollBehavior.'
|
|
3080
|
+
);
|
|
3081
|
+
}
|
|
3082
|
+
|
|
3083
|
+
/**
|
|
3084
|
+
* indicates if an element has scrollable space in the provided axis
|
|
3085
|
+
* @method hasScrollableSpace
|
|
3086
|
+
* @param {Node} el
|
|
3087
|
+
* @param {String} axis
|
|
3088
|
+
* @returns {Boolean}
|
|
3089
|
+
*/
|
|
3090
|
+
function hasScrollableSpace(el, axis) {
|
|
3091
|
+
if (axis === 'Y') {
|
|
3092
|
+
return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;
|
|
3093
|
+
}
|
|
3094
|
+
|
|
3095
|
+
if (axis === 'X') {
|
|
3096
|
+
return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;
|
|
3097
|
+
}
|
|
3098
|
+
}
|
|
3099
|
+
|
|
3100
|
+
/**
|
|
3101
|
+
* indicates if an element has a scrollable overflow property in the axis
|
|
3102
|
+
* @method canOverflow
|
|
3103
|
+
* @param {Node} el
|
|
3104
|
+
* @param {String} axis
|
|
3105
|
+
* @returns {Boolean}
|
|
3106
|
+
*/
|
|
3107
|
+
function canOverflow(el, axis) {
|
|
3108
|
+
var overflowValue = w.getComputedStyle(el, null)['overflow' + axis];
|
|
3109
|
+
|
|
3110
|
+
return overflowValue === 'auto' || overflowValue === 'scroll';
|
|
3111
|
+
}
|
|
3112
|
+
|
|
3113
|
+
/**
|
|
3114
|
+
* indicates if an element can be scrolled in either axis
|
|
3115
|
+
* @method isScrollable
|
|
3116
|
+
* @param {Node} el
|
|
3117
|
+
* @param {String} axis
|
|
3118
|
+
* @returns {Boolean}
|
|
3119
|
+
*/
|
|
3120
|
+
function isScrollable(el) {
|
|
3121
|
+
var isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y');
|
|
3122
|
+
var isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X');
|
|
3123
|
+
|
|
3124
|
+
return isScrollableY || isScrollableX;
|
|
3125
|
+
}
|
|
3126
|
+
|
|
3127
|
+
/**
|
|
3128
|
+
* finds scrollable parent of an element
|
|
3129
|
+
* @method findScrollableParent
|
|
3130
|
+
* @param {Node} el
|
|
3131
|
+
* @returns {Node} el
|
|
3132
|
+
*/
|
|
3133
|
+
function findScrollableParent(el) {
|
|
3134
|
+
while (el !== d.body && isScrollable(el) === false) {
|
|
3135
|
+
el = el.parentNode || el.host;
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
return el;
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3141
|
+
/**
|
|
3142
|
+
* self invoked function that, given a context, steps through scrolling
|
|
3143
|
+
* @method step
|
|
3144
|
+
* @param {Object} context
|
|
3145
|
+
* @returns {undefined}
|
|
3146
|
+
*/
|
|
3147
|
+
function step(context) {
|
|
3148
|
+
var time = now();
|
|
3149
|
+
var value;
|
|
3150
|
+
var currentX;
|
|
3151
|
+
var currentY;
|
|
3152
|
+
var elapsed = (time - context.startTime) / SCROLL_TIME;
|
|
3153
|
+
|
|
3154
|
+
// avoid elapsed times higher than one
|
|
3155
|
+
elapsed = elapsed > 1 ? 1 : elapsed;
|
|
3156
|
+
|
|
3157
|
+
// apply easing to elapsed time
|
|
3158
|
+
value = ease(elapsed);
|
|
3159
|
+
|
|
3160
|
+
currentX = context.startX + (context.x - context.startX) * value;
|
|
3161
|
+
currentY = context.startY + (context.y - context.startY) * value;
|
|
3162
|
+
|
|
3163
|
+
context.method.call(context.scrollable, currentX, currentY);
|
|
3164
|
+
|
|
3165
|
+
// scroll more if we have not reached our destination
|
|
3166
|
+
if (currentX !== context.x || currentY !== context.y) {
|
|
3167
|
+
w.requestAnimationFrame(step.bind(w, context));
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3171
|
+
/**
|
|
3172
|
+
* scrolls window or element with a smooth behavior
|
|
3173
|
+
* @method smoothScroll
|
|
3174
|
+
* @param {Object|Node} el
|
|
3175
|
+
* @param {Number} x
|
|
3176
|
+
* @param {Number} y
|
|
3177
|
+
* @returns {undefined}
|
|
3178
|
+
*/
|
|
3179
|
+
function smoothScroll(el, x, y) {
|
|
3180
|
+
var scrollable;
|
|
3181
|
+
var startX;
|
|
3182
|
+
var startY;
|
|
3183
|
+
var method;
|
|
3184
|
+
var startTime = now();
|
|
3185
|
+
|
|
3186
|
+
// define scroll context
|
|
3187
|
+
if (el === d.body) {
|
|
3188
|
+
scrollable = w;
|
|
3189
|
+
startX = w.scrollX || w.pageXOffset;
|
|
3190
|
+
startY = w.scrollY || w.pageYOffset;
|
|
3191
|
+
method = original.scroll;
|
|
3192
|
+
} else {
|
|
3193
|
+
scrollable = el;
|
|
3194
|
+
startX = el.scrollLeft;
|
|
3195
|
+
startY = el.scrollTop;
|
|
3196
|
+
method = scrollElement;
|
|
3197
|
+
}
|
|
3198
|
+
|
|
3199
|
+
// scroll looping over a frame
|
|
3200
|
+
step({
|
|
3201
|
+
scrollable: scrollable,
|
|
3202
|
+
method: method,
|
|
3203
|
+
startTime: startTime,
|
|
3204
|
+
startX: startX,
|
|
3205
|
+
startY: startY,
|
|
3206
|
+
x: x,
|
|
3207
|
+
y: y
|
|
3208
|
+
});
|
|
3209
|
+
}
|
|
3210
|
+
|
|
3211
|
+
// ORIGINAL METHODS OVERRIDES
|
|
3212
|
+
// w.scroll and w.scrollTo
|
|
3213
|
+
w.scroll = w.scrollTo = function() {
|
|
3214
|
+
// avoid action when no arguments are passed
|
|
3215
|
+
if (arguments[0] === undefined) {
|
|
3216
|
+
return;
|
|
3217
|
+
}
|
|
3218
|
+
|
|
3219
|
+
// avoid smooth behavior if not required
|
|
3220
|
+
if (shouldBailOut(arguments[0]) === true) {
|
|
3221
|
+
original.scroll.call(
|
|
3222
|
+
w,
|
|
3223
|
+
arguments[0].left !== undefined
|
|
3224
|
+
? arguments[0].left
|
|
3225
|
+
: typeof arguments[0] !== 'object'
|
|
3226
|
+
? arguments[0]
|
|
3227
|
+
: w.scrollX || w.pageXOffset,
|
|
3228
|
+
// use top prop, second argument if present or fallback to scrollY
|
|
3229
|
+
arguments[0].top !== undefined
|
|
3230
|
+
? arguments[0].top
|
|
3231
|
+
: arguments[1] !== undefined
|
|
3232
|
+
? arguments[1]
|
|
3233
|
+
: w.scrollY || w.pageYOffset
|
|
3234
|
+
);
|
|
3235
|
+
|
|
3236
|
+
return;
|
|
3237
|
+
}
|
|
3238
|
+
|
|
3239
|
+
// LET THE SMOOTHNESS BEGIN!
|
|
3240
|
+
smoothScroll.call(
|
|
3241
|
+
w,
|
|
3242
|
+
d.body,
|
|
3243
|
+
arguments[0].left !== undefined
|
|
3244
|
+
? ~~arguments[0].left
|
|
3245
|
+
: w.scrollX || w.pageXOffset,
|
|
3246
|
+
arguments[0].top !== undefined
|
|
3247
|
+
? ~~arguments[0].top
|
|
3248
|
+
: w.scrollY || w.pageYOffset
|
|
3249
|
+
);
|
|
3250
|
+
};
|
|
3251
|
+
|
|
3252
|
+
// w.scrollBy
|
|
3253
|
+
w.scrollBy = function() {
|
|
3254
|
+
// avoid action when no arguments are passed
|
|
3255
|
+
if (arguments[0] === undefined) {
|
|
3256
|
+
return;
|
|
3257
|
+
}
|
|
3258
|
+
|
|
3259
|
+
// avoid smooth behavior if not required
|
|
3260
|
+
if (shouldBailOut(arguments[0])) {
|
|
3261
|
+
original.scrollBy.call(
|
|
3262
|
+
w,
|
|
3263
|
+
arguments[0].left !== undefined
|
|
3264
|
+
? arguments[0].left
|
|
3265
|
+
: typeof arguments[0] !== 'object' ? arguments[0] : 0,
|
|
3266
|
+
arguments[0].top !== undefined
|
|
3267
|
+
? arguments[0].top
|
|
3268
|
+
: arguments[1] !== undefined ? arguments[1] : 0
|
|
3269
|
+
);
|
|
3270
|
+
|
|
3271
|
+
return;
|
|
3272
|
+
}
|
|
3273
|
+
|
|
3274
|
+
// LET THE SMOOTHNESS BEGIN!
|
|
3275
|
+
smoothScroll.call(
|
|
3276
|
+
w,
|
|
3277
|
+
d.body,
|
|
3278
|
+
~~arguments[0].left + (w.scrollX || w.pageXOffset),
|
|
3279
|
+
~~arguments[0].top + (w.scrollY || w.pageYOffset)
|
|
3280
|
+
);
|
|
3281
|
+
};
|
|
3282
|
+
|
|
3283
|
+
// Element.prototype.scroll and Element.prototype.scrollTo
|
|
3284
|
+
Element.prototype.scroll = Element.prototype.scrollTo = function() {
|
|
3285
|
+
// avoid action when no arguments are passed
|
|
3286
|
+
if (arguments[0] === undefined) {
|
|
3287
|
+
return;
|
|
3288
|
+
}
|
|
3289
|
+
|
|
3290
|
+
// avoid smooth behavior if not required
|
|
3291
|
+
if (shouldBailOut(arguments[0]) === true) {
|
|
3292
|
+
// if one number is passed, throw error to match Firefox implementation
|
|
3293
|
+
if (typeof arguments[0] === 'number' && arguments[1] === undefined) {
|
|
3294
|
+
throw new SyntaxError('Value could not be converted');
|
|
3295
|
+
}
|
|
3296
|
+
|
|
3297
|
+
original.elementScroll.call(
|
|
3298
|
+
this,
|
|
3299
|
+
// use left prop, first number argument or fallback to scrollLeft
|
|
3300
|
+
arguments[0].left !== undefined
|
|
3301
|
+
? ~~arguments[0].left
|
|
3302
|
+
: typeof arguments[0] !== 'object' ? ~~arguments[0] : this.scrollLeft,
|
|
3303
|
+
// use top prop, second argument or fallback to scrollTop
|
|
3304
|
+
arguments[0].top !== undefined
|
|
3305
|
+
? ~~arguments[0].top
|
|
3306
|
+
: arguments[1] !== undefined ? ~~arguments[1] : this.scrollTop
|
|
3307
|
+
);
|
|
3308
|
+
|
|
3309
|
+
return;
|
|
3310
|
+
}
|
|
3311
|
+
|
|
3312
|
+
var left = arguments[0].left;
|
|
3313
|
+
var top = arguments[0].top;
|
|
3314
|
+
|
|
3315
|
+
// LET THE SMOOTHNESS BEGIN!
|
|
3316
|
+
smoothScroll.call(
|
|
3317
|
+
this,
|
|
3318
|
+
this,
|
|
3319
|
+
typeof left === 'undefined' ? this.scrollLeft : ~~left,
|
|
3320
|
+
typeof top === 'undefined' ? this.scrollTop : ~~top
|
|
3321
|
+
);
|
|
3322
|
+
};
|
|
3323
|
+
|
|
3324
|
+
// Element.prototype.scrollBy
|
|
3325
|
+
Element.prototype.scrollBy = function() {
|
|
3326
|
+
// avoid action when no arguments are passed
|
|
3327
|
+
if (arguments[0] === undefined) {
|
|
3328
|
+
return;
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3331
|
+
// avoid smooth behavior if not required
|
|
3332
|
+
if (shouldBailOut(arguments[0]) === true) {
|
|
3333
|
+
original.elementScroll.call(
|
|
3334
|
+
this,
|
|
3335
|
+
arguments[0].left !== undefined
|
|
3336
|
+
? ~~arguments[0].left + this.scrollLeft
|
|
3337
|
+
: ~~arguments[0] + this.scrollLeft,
|
|
3338
|
+
arguments[0].top !== undefined
|
|
3339
|
+
? ~~arguments[0].top + this.scrollTop
|
|
3340
|
+
: ~~arguments[1] + this.scrollTop
|
|
3341
|
+
);
|
|
3342
|
+
|
|
3343
|
+
return;
|
|
3344
|
+
}
|
|
3345
|
+
|
|
3346
|
+
this.scroll({
|
|
3347
|
+
left: ~~arguments[0].left + this.scrollLeft,
|
|
3348
|
+
top: ~~arguments[0].top + this.scrollTop,
|
|
3349
|
+
behavior: arguments[0].behavior
|
|
3350
|
+
});
|
|
3351
|
+
};
|
|
3352
|
+
|
|
3353
|
+
// Element.prototype.scrollIntoView
|
|
3354
|
+
Element.prototype.scrollIntoView = function() {
|
|
3355
|
+
// avoid smooth behavior if not required
|
|
3356
|
+
if (shouldBailOut(arguments[0]) === true) {
|
|
3357
|
+
original.scrollIntoView.call(
|
|
3358
|
+
this,
|
|
3359
|
+
arguments[0] === undefined ? true : arguments[0]
|
|
3360
|
+
);
|
|
3361
|
+
|
|
3362
|
+
return;
|
|
3363
|
+
}
|
|
3364
|
+
|
|
3365
|
+
// LET THE SMOOTHNESS BEGIN!
|
|
3366
|
+
var scrollableParent = findScrollableParent(this);
|
|
3367
|
+
var parentRects = scrollableParent.getBoundingClientRect();
|
|
3368
|
+
var clientRects = this.getBoundingClientRect();
|
|
3369
|
+
|
|
3370
|
+
if (scrollableParent !== d.body) {
|
|
3371
|
+
// reveal element inside parent
|
|
3372
|
+
smoothScroll.call(
|
|
3373
|
+
this,
|
|
3374
|
+
scrollableParent,
|
|
3375
|
+
scrollableParent.scrollLeft + clientRects.left - parentRects.left,
|
|
3376
|
+
scrollableParent.scrollTop + clientRects.top - parentRects.top
|
|
3377
|
+
);
|
|
3378
|
+
|
|
3379
|
+
// reveal parent in viewport unless is fixed
|
|
3380
|
+
if (w.getComputedStyle(scrollableParent).position !== 'fixed') {
|
|
3381
|
+
w.scrollBy({
|
|
3382
|
+
left: parentRects.left,
|
|
3383
|
+
top: parentRects.top,
|
|
3384
|
+
behavior: 'smooth'
|
|
3385
|
+
});
|
|
3386
|
+
}
|
|
3387
|
+
} else {
|
|
3388
|
+
// reveal element in viewport
|
|
3389
|
+
w.scrollBy({
|
|
3390
|
+
left: clientRects.left,
|
|
3391
|
+
top: clientRects.top,
|
|
3392
|
+
behavior: 'smooth'
|
|
3393
|
+
});
|
|
3394
|
+
}
|
|
3395
|
+
};
|
|
3396
|
+
}
|
|
3397
|
+
|
|
3398
|
+
{
|
|
3399
|
+
// commonjs
|
|
3400
|
+
module.exports = { polyfill: polyfill };
|
|
3401
|
+
}
|
|
3402
|
+
|
|
3403
|
+
}());
|
|
3404
|
+
});
|
|
3405
|
+
var smoothscroll_1 = smoothscroll.polyfill;
|
|
3406
|
+
|
|
2978
3407
|
var useStyles$5 = core.makeStyles(function (theme) { return ({
|
|
2979
3408
|
root: function (props) { return ({
|
|
2980
3409
|
width: props.width,
|
|
@@ -3013,6 +3442,7 @@ var SegmentedTabs = function (_a) {
|
|
|
3013
3442
|
var classes = useStyles$5(styleProps);
|
|
3014
3443
|
var tabsRef = React.useRef(null);
|
|
3015
3444
|
React.useEffect(function () {
|
|
3445
|
+
smoothscroll.polyfill();
|
|
3016
3446
|
if (tabsRef &&
|
|
3017
3447
|
tabsRef.current &&
|
|
3018
3448
|
other.variant &&
|
|
@@ -3023,8 +3453,8 @@ var SegmentedTabs = function (_a) {
|
|
|
3023
3453
|
setTimeout(function () {
|
|
3024
3454
|
el_1.scrollIntoView({
|
|
3025
3455
|
behavior: "smooth",
|
|
3026
|
-
block: "
|
|
3027
|
-
inline: "
|
|
3456
|
+
block: "nearest",
|
|
3457
|
+
inline: "center",
|
|
3028
3458
|
});
|
|
3029
3459
|
}, 1000);
|
|
3030
3460
|
}
|