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