wex-ui-lib 1.4.4 → 1.4.6
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/dist/index.cjs.js +83 -27
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +82 -26
- package/dist/index.esm.js.map +1 -1
- package/dist/types/components/Navbar/Navbar.types.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.esm.js
CHANGED
@@ -1960,11 +1960,11 @@ function Icon(props) {
|
|
1960
1960
|
icon.includes("arrow-caret") && (React__default.createElement("svg", { width: "8", height: "10", viewBox: "0 0 8 10", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
1961
1961
|
React__default.createElement("path", { d: "M1 1L6 5L1 9", stroke: "white", strokeWidth: "1.5" })))));
|
1962
1962
|
}
|
1963
|
-
var IconContainer = newStyled.div(templateObject_1$d || (templateObject_1$d = __makeTemplateObject(["\n all: unset;\n display: flex;\n align-items: center;\n justify-content: center;\n padding-top: 1px;\n width: ", ";\n height: ", ";\n border: ", ";\n border-radius: ", ";\n transition: 100ms;\n cursor: pointer;\n svg {\n transform: ", ";\n height: ", ";\n fill: ", ";\n path{\n fill: ", "
|
1963
|
+
var IconContainer = newStyled.div(templateObject_1$d || (templateObject_1$d = __makeTemplateObject(["\n all: unset;\n display: flex;\n align-items: center;\n justify-content: center;\n padding-top: 1px;\n width: ", ";\n height: ", ";\n border: ", ";\n border-radius: ", ";\n transition: 100ms;\n cursor: pointer;\n svg {\n transform: ", ";\n height: ", ";\n fill: ", ";\n stroke: ", ";\n path{\n fill: ", ";\n stroke: ", ";\n }\n }\n &:hover {\n border-color: ", ";\n svg {\n fill: ", ";\n path{\n fill: ", ";\n }\n }\n }\n"], ["\n all: unset;\n display: flex;\n align-items: center;\n justify-content: center;\n padding-top: 1px;\n width: ", ";\n height: ", ";\n border: ", ";\n border-radius: ", ";\n transition: 100ms;\n cursor: pointer;\n svg {\n transform: ", ";\n height: ", ";\n fill: ", ";\n stroke: ", ";\n path{\n fill: ", ";\n stroke: ", ";\n }\n }\n &:hover {\n border-color: ", ";\n svg {\n fill: ", ";\n path{\n fill: ", ";\n }\n }\n }\n"])), function (props) { return props.border ? props.size : "unset"; }, function (props) { return props.border ? props.size : "unset"; }, function (props) { return props.border ? "2px solid ".concat(props.color) : "unset"; }, function (props) {
|
1964
1964
|
return props.border === "rounded" ? "2px" :
|
1965
1965
|
props.border === "circle" ? "50px" :
|
1966
1966
|
"unset";
|
1967
|
-
}, function (props) { return props.icon.includes("left") ? "rotateY(180deg)" : ""; }, function (props) { return props.border ? "46%" : props.size; }, function (props) { return props.color; }, function (props) { return props.color; }, function (props) { return props.hoverColor; }, function (props) { return props.hoverColor; }, function (props) { return props.hoverColor; });
|
1967
|
+
}, function (props) { return props.icon.includes("left") ? "rotateY(180deg)" : ""; }, function (props) { return props.border ? "46%" : props.size; }, function (props) { return props.color; }, function (props) { return props.color; }, function (props) { return props.color; }, function (props) { return props.color; }, function (props) { return props.hoverColor; }, function (props) { return props.hoverColor; }, function (props) { return props.hoverColor; });
|
1968
1968
|
var templateObject_1$d;
|
1969
1969
|
|
1970
1970
|
var theme = {
|
@@ -2168,39 +2168,62 @@ var disappearAnimation = keyframes(templateObject_2$7 || (templateObject_2$7 = _
|
|
2168
2168
|
var fadeInFromLeft = keyframes(templateObject_3$6 || (templateObject_3$6 = __makeTemplateObject(["\n from {\n opacity: 0;\n transform: translateX(-20px);\n }\n to {\n opacity: 1;\n transform: translateX(0);\n }\n"], ["\n from {\n opacity: 0;\n transform: translateX(-20px);\n }\n to {\n opacity: 1;\n transform: translateX(0);\n }\n"])));
|
2169
2169
|
var fadeInFromRight = keyframes(templateObject_4$5 || (templateObject_4$5 = __makeTemplateObject(["\n from {\n opacity: 0;\n transform: translateX(20px);\n }\n to {\n opacity: 1;\n transform: translateX(0);\n }\n"], ["\n from {\n opacity: 0;\n transform: translateX(20px);\n }\n to {\n opacity: 1;\n transform: translateX(0);\n }\n"])));
|
2170
2170
|
var fadeInFromTop = keyframes(templateObject_5$5 || (templateObject_5$5 = __makeTemplateObject(["\n from {\n opacity: 0;\n transform: translateY(-20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n"], ["\n from {\n opacity: 0;\n transform: translateY(-20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n"])));
|
2171
|
-
var fadeInFromBottom = keyframes(templateObject_6$
|
2172
|
-
var templateObject_1$b, templateObject_2$7, templateObject_3$6, templateObject_4$5, templateObject_5$5, templateObject_6$
|
2171
|
+
var fadeInFromBottom = keyframes(templateObject_6$2 || (templateObject_6$2 = __makeTemplateObject(["\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n"], ["\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n"])));
|
2172
|
+
var templateObject_1$b, templateObject_2$7, templateObject_3$6, templateObject_4$5, templateObject_5$5, templateObject_6$2;
|
2173
2173
|
|
2174
2174
|
function Navbar(props) {
|
2175
2175
|
var logo = props.logo, items = props.items, button = props.button, config = props.config;
|
2176
|
+
var _a = useState(false), sideNavOpen = _a[0], setSideNavOpen = _a[1];
|
2177
|
+
var isMobile = typeof window !== 'undefined' && window.innerWidth <= 800;
|
2178
|
+
var sideNavItems = props.mobileItems || [];
|
2176
2179
|
return (React__default.createElement(React__default.Fragment, null,
|
2177
2180
|
React__default.createElement(NavbarContainer, __assign({}, props),
|
2178
2181
|
React__default.createElement(Logo$1, { src: logo === null || logo === undefined ? undefined : logo.url, width: logo === null || logo === undefined ? undefined : logo.width, onClick: logo === null || logo === undefined ? undefined : logo.onClick }),
|
2179
|
-
React__default.createElement(
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
2188
|
-
|
2189
|
-
React__default.createElement(
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2182
|
+
!isMobile ? (React__default.createElement(React__default.Fragment, null,
|
2183
|
+
React__default.createElement(ItemsContainer, null, items === null || items === undefined ? undefined : items.map(function (item) {
|
2184
|
+
var _a, _b;
|
2185
|
+
return (React__default.createElement(Item$1, { key: item.label, href: "#", onClick: function (e) {
|
2186
|
+
e.preventDefault();
|
2187
|
+
item.onClick && item.onClick();
|
2188
|
+
}, config: config, hasSubitems: ((_a = item.subitems) === null || _a === undefined ? undefined : _a.length) > 0 },
|
2189
|
+
item.label,
|
2190
|
+
item.subitems && React__default.createElement(Icon, { icon: 'arrow-caret', size: '8px' }),
|
2191
|
+
item.subitems && (React__default.createElement("div", null, (_b = item.subitems) === null || _b === undefined ? undefined : _b.map(function (subitem) {
|
2192
|
+
return (React__default.createElement(Subitem, { key: subitem.label },
|
2193
|
+
React__default.createElement("a", { href: "#", onClick: function (e) {
|
2194
|
+
e.preventDefault();
|
2195
|
+
e.stopPropagation();
|
2196
|
+
subitem.onClick && subitem.onClick();
|
2197
|
+
} }, subitem.label)));
|
2198
|
+
})))));
|
2199
|
+
})),
|
2200
|
+
button && (React__default.createElement(Button, { colors: button.colors, type: button.type, font: button.font, onClick: button.onClick, arrow: button.arrow }, button.label)))) : (React__default.createElement(Icon, { icon: 'hamburgerMenu', color: 'white', callback: function () { return setSideNavOpen(true); } }))),
|
2201
|
+
isMobile && (React__default.createElement(SideNav, { open: sideNavOpen },
|
2202
|
+
React__default.createElement(SideNavOverlay, { open: sideNavOpen, onClick: function () { return setSideNavOpen(false); } }),
|
2203
|
+
React__default.createElement(SideNavContent, { open: sideNavOpen },
|
2204
|
+
React__default.createElement(CloseButton, { onClick: function () { return setSideNavOpen(false); } }, "\u00D7"), sideNavItems === null || sideNavItems === undefined ? undefined :
|
2205
|
+
sideNavItems.map(function (item) { return (React__default.createElement(SideNavItem, { key: item.label, onClick: function () { setSideNavOpen(false); item.onClick && item.onClick(); } }, item.label)); }))))));
|
2197
2206
|
}
|
2198
|
-
var NavbarContainer = newStyled.div(templateObject_1$a || (templateObject_1$a = __makeTemplateObject(["\n background-color: ", ";\n width: 100vw;\n height: ", ";\n display: grid;\n ", ";\n ", ";\n grid-template-rows: 100%;\n position: fixed;\n top: 0;\n left: 0;\n align-items: center;\n justify-content: space-between;\n padding: 0 4vw;\n z-index: 99;\n backdrop-filter: blur(4px);\n & > button {\n margin-left: auto;\n grid-area: button;\n }\n * {\n -webkit-user-drag: none;\n -khtml-user-drag: none;\n -moz-user-drag: none;\n -o-user-drag: none;\n }\n"], ["\n background-color: ", ";\n width: 100vw;\n height: ", ";\n display: grid;\n ", ";\n ", ";\n grid-template-rows: 100%;\n position: fixed;\n top: 0;\n left: 0;\n align-items: center;\n justify-content: space-between;\n padding: 0 4vw;\n z-index: 99;\n backdrop-filter: blur(4px);\n & > button {\n margin-left: auto;\n grid-area: button;\n }\n * {\n -webkit-user-drag: none;\n -khtml-user-drag: none;\n -moz-user-drag: none;\n -o-user-drag: none;\n }\n"])), function (props) { var _a, _b; return ((_b = (_a = props.config) === null || _a === undefined ? undefined : _a.colors) === null || _b === undefined ? undefined : _b.background) || theme.black; }, function (props) { var _a; return ((_a = props.config) === null || _a === undefined ? undefined : _a.height) || '80px'; }, function (props) { var _a; return ((_a = props.button) === null || _a === undefined ? undefined : _a.label) ? "grid-template-columns: auto auto auto" : "grid-template-columns: auto auto"; }, function (props) { var _a; return ((_a = props.button) === null || _a === undefined ? undefined : _a.label) ? "grid-template-areas: \"logo items button\"" : "grid-template-areas: \"logo items\""; });
|
2207
|
+
var NavbarContainer = newStyled.div(templateObject_1$a || (templateObject_1$a = __makeTemplateObject(["\n background-color: ", ";\n width: 100vw;\n height: ", ";\n display: grid;\n ", ";\n ", ";\n grid-template-rows: 100%;\n position: fixed;\n top: 0;\n left: 0;\n align-items: center;\n justify-content: space-between;\n padding: 0 4vw;\n z-index: 99;\n backdrop-filter: blur(4px);\n & > button {\n margin-left: auto;\n grid-area: button;\n }\n * {\n -webkit-user-drag: none;\n -khtml-user-drag: none;\n -moz-user-drag: none;\n -o-user-drag: none;\n }\n @media only screen and (max-width: 1024px) {\n grid-template-columns: auto auto;\n grid-template-areas: \"logo hamburgerIcon\";\n }\n"], ["\n background-color: ", ";\n width: 100vw;\n height: ", ";\n display: grid;\n ", ";\n ", ";\n grid-template-rows: 100%;\n position: fixed;\n top: 0;\n left: 0;\n align-items: center;\n justify-content: space-between;\n padding: 0 4vw;\n z-index: 99;\n backdrop-filter: blur(4px);\n & > button {\n margin-left: auto;\n grid-area: button;\n }\n * {\n -webkit-user-drag: none;\n -khtml-user-drag: none;\n -moz-user-drag: none;\n -o-user-drag: none;\n }\n @media only screen and (max-width: 1024px) {\n grid-template-columns: auto auto;\n grid-template-areas: \"logo hamburgerIcon\";\n }\n"])), function (props) { var _a, _b; return ((_b = (_a = props.config) === null || _a === undefined ? undefined : _a.colors) === null || _b === undefined ? undefined : _b.background) || theme.black; }, function (props) { var _a; return ((_a = props.config) === null || _a === undefined ? undefined : _a.height) || '80px'; }, function (props) { var _a; return ((_a = props.button) === null || _a === undefined ? undefined : _a.label) ? "grid-template-columns: auto auto auto" : "grid-template-columns: auto auto"; }, function (props) { var _a; return ((_a = props.button) === null || _a === undefined ? undefined : _a.label) ? "grid-template-areas: \"logo items button\"" : "grid-template-areas: \"logo items\""; });
|
2199
2208
|
var ItemsContainer = newStyled.div(templateObject_2$6 || (templateObject_2$6 = __makeTemplateObject(["\n grid-area: items;\n display: flex;\n align-items: center;\n height: 100%;\n @media only screen and (max-width: 1024px) {\n display: none;\n }\n"], ["\n grid-area: items;\n display: flex;\n align-items: center;\n height: 100%;\n @media only screen and (max-width: 1024px) {\n display: none;\n }\n"])));
|
2200
2209
|
var Item$1 = newStyled.a(templateObject_3$5 || (templateObject_3$5 = __makeTemplateObject(["\n color: ", ";\n position: relative;\n display: flex;\n gap: 5px;\n align-items: center;\n justify-content: center;\n height: 100%;\n font-size: 12px;\n letter-spacing: 2px;\n font-weight: 500;\n text-transform: uppercase;\n text-decoration: none;\n padding: 6px 22px 0;\n transition: 0.3s;\n border-bottom: 4px solid transparent;\n svg {\n margin-bottom: 1px;\n transition: 300ms;\n transform: rotateZ(90deg);\n }\n & > div:nth-of-type(2) {\n z-index: 10;\n position: absolute;\n display: none;\n flex-direction: column;\n align-items: flex-start;\n width: max-content;\n top: 88%;\n left: 0;\n background-color: ", ";\n padding: 16px 14px;\n animation-name: ", ";\n animation-duration: 0.3s;\n animation-fill-mode: forwards;\n a {\n color: ", ";\n &:hover {\n color: ", ";\n }\n }\n &:hover {\n animation-name: ", ";\n display: flex;\n }\n }\n &:hover {\n border-color: ", ";\n svg {\n transform: rotateZ(90deg) rotateY(-180deg) translateX(1px);\n }\n & > div{\n animation-name: ", ";\n display: flex;\n }\n }\n"], ["\n color: ", ";\n position: relative;\n display: flex;\n gap: 5px;\n align-items: center;\n justify-content: center;\n height: 100%;\n font-size: 12px;\n letter-spacing: 2px;\n font-weight: 500;\n text-transform: uppercase;\n text-decoration: none;\n padding: 6px 22px 0;\n transition: 0.3s;\n border-bottom: 4px solid transparent;\n svg {\n margin-bottom: 1px;\n transition: 300ms;\n transform: rotateZ(90deg);\n }\n & > div:nth-of-type(2) {\n z-index: 10;\n position: absolute;\n display: none;\n flex-direction: column;\n align-items: flex-start;\n width: max-content;\n top: 88%;\n left: 0;\n background-color: ", ";\n padding: 16px 14px;\n animation-name: ", ";\n animation-duration: 0.3s;\n animation-fill-mode: forwards;\n a {\n color: ", ";\n &:hover {\n color: ", ";\n }\n }\n &:hover {\n animation-name: ", ";\n display: flex;\n }\n }\n &:hover {\n border-color: ", ";\n svg {\n transform: rotateZ(90deg) rotateY(-180deg) translateX(1px);\n }\n & > div{\n animation-name: ", ";\n display: flex;\n }\n }\n"])), function (props) { var _a, _b; return ((_b = (_a = props.config) === null || _a === undefined ? undefined : _a.colors) === null || _b === undefined ? undefined : _b.text) || theme.white; }, theme.gray, disappearAnimation, function (props) { var _a, _b; return ((_b = (_a = props.config) === null || _a === undefined ? undefined : _a.colors) === null || _b === undefined ? undefined : _b.text) || theme.white; }, function (props) { var _a, _b; return ((_b = (_a = props.config) === null || _a === undefined ? undefined : _a.colors) === null || _b === undefined ? undefined : _b.textHover) || theme.primary; }, appearAnimation, function (props) { var _a, _b; return !props.hasSubitems ? ((_b = (_a = props.config) === null || _a === undefined ? undefined : _a.colors) === null || _b === undefined ? undefined : _b.borderHover) || "white" : "transparent"; }, appearAnimation);
|
2201
2210
|
var Logo$1 = newStyled.img(templateObject_4$4 || (templateObject_4$4 = __makeTemplateObject(["\n grid-area: logo;\n cursor: pointer;\n width: ", ";\n transition: all 0.2s;\n &:hover {\n filter: brightness(1.2);\n }\n @media only screen and (max-width: 1024px) {\n width: calc(", "/1.3);\n }\n"], ["\n grid-area: logo;\n cursor: pointer;\n width: ", ";\n transition: all 0.2s;\n &:hover {\n filter: brightness(1.2);\n }\n @media only screen and (max-width: 1024px) {\n width: calc(", "/1.3);\n }\n"])), function (props) { return props.width || '130px'; }, function (props) { return props.width || '130px'; });
|
2202
2211
|
var Subitem = newStyled.div(templateObject_5$4 || (templateObject_5$4 = __makeTemplateObject(["\n width: 100%;\n cursor: pointer;\n height: 100%;\n max-height: 90px;\n text-transform: uppercase;\n display: flex;\n align-items: center;\n justify-content: flex-start;\n transition: 0.3s;\n a {\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: flex-start;\n font-size: 12px;\n letter-spacing: 2px;\n font-weight: 500;\n text-decoration: none;\n }\n &:not(:first-of-type) {\n a {\n padding-top: 9px;\n }\n }\n &:not(:last-of-type) {\n a {\n padding-bottom: 9px;\n }\n }\n"], ["\n width: 100%;\n cursor: pointer;\n height: 100%;\n max-height: 90px;\n text-transform: uppercase;\n display: flex;\n align-items: center;\n justify-content: flex-start;\n transition: 0.3s;\n a {\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: flex-start;\n font-size: 12px;\n letter-spacing: 2px;\n font-weight: 500;\n text-decoration: none;\n }\n &:not(:first-of-type) {\n a {\n padding-top: 9px;\n }\n }\n &:not(:last-of-type) {\n a {\n padding-bottom: 9px;\n }\n }\n"])));
|
2203
|
-
var
|
2212
|
+
var SideNav = newStyled.div(templateObject_6$1 || (templateObject_6$1 = __makeTemplateObject(["\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n z-index: 200;\n pointer-events: ", ";\n"], ["\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n z-index: 200;\n pointer-events: ", ";\n"])), function (_a) {
|
2213
|
+
var open = _a.open;
|
2214
|
+
return open ? 'auto' : 'none';
|
2215
|
+
});
|
2216
|
+
var SideNavOverlay = newStyled.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: rgba(0,0,0,0.4);\n opacity: ", ";\n transition: opacity 0.3s;\n"], ["\n position: absolute;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: rgba(0,0,0,0.4);\n opacity: ", ";\n transition: opacity 0.3s;\n"])), function (_a) {
|
2217
|
+
var open = _a.open;
|
2218
|
+
return open ? 1 : 0;
|
2219
|
+
});
|
2220
|
+
var SideNavContent = newStyled.div(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n right: 0;\n width: 80vw;\n max-width: 320px;\n height: 100vh;\n background: ", ";\n box-shadow: -2px 0 16px rgba(0,0,0,0.15);\n transform: ", ";\n transition: transform 0.3s;\n display: flex;\n flex-direction: column;\n padding: 32px 20px 20px 20px;\n"], ["\n position: absolute;\n top: 0;\n right: 0;\n width: 80vw;\n max-width: 320px;\n height: 100vh;\n background: ", ";\n box-shadow: -2px 0 16px rgba(0,0,0,0.15);\n transform: ", ";\n transition: transform 0.3s;\n display: flex;\n flex-direction: column;\n padding: 32px 20px 20px 20px;\n"])), theme.black2, function (_a) {
|
2221
|
+
var open = _a.open;
|
2222
|
+
return open ? 'translateX(0)' : 'translateX(100%)';
|
2223
|
+
});
|
2224
|
+
var CloseButton = newStyled.button(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n background: none;\n border: none;\n color: white;\n font-size: 2rem;\n align-self: flex-end;\n cursor: pointer;\n"], ["\n background: none;\n border: none;\n color: white;\n font-size: 2rem;\n align-self: flex-end;\n cursor: pointer;\n"])));
|
2225
|
+
var SideNavItem = newStyled.div(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n color: white;\n font-size: 1.1rem;\n padding: 16px 0;\n border-bottom: 1px solid rgba(255,255,255,0.08);\n cursor: pointer;\n &:last-of-type { border-bottom: none; }\n"], ["\n color: white;\n font-size: 1.1rem;\n padding: 16px 0;\n border-bottom: 1px solid rgba(255,255,255,0.08);\n cursor: pointer;\n &:last-of-type { border-bottom: none; }\n"])));
|
2226
|
+
var templateObject_1$a, templateObject_2$6, templateObject_3$5, templateObject_4$4, templateObject_5$4, templateObject_6$1, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
|
2204
2227
|
|
2205
2228
|
function Hero(props) {
|
2206
2229
|
var children = props.children, _a = props.imageUrls, imageUrls = _a === undefined ? [""] : _a, backgroundColor = props.backgroundColor, overlay = props.overlay, marginTop = props.marginTop, height = props.height;
|
@@ -2545,6 +2568,7 @@ var Item = newStyled.button(templateObject_4$1 || (templateObject_4$1 = __makeTe
|
|
2545
2568
|
var ItemContent = newStyled.div(templateObject_5$1 || (templateObject_5$1 = __makeTemplateObject(["\n grid-area: content;\n display: flex;\n position: relative;\n width: 100%;\n overflow: hidden;\n flex-direction: column;\n gap: 20px;\n"], ["\n grid-area: content;\n display: flex;\n position: relative;\n width: 100%;\n overflow: hidden;\n flex-direction: column;\n gap: 20px;\n"])));
|
2546
2569
|
var templateObject_1$1, templateObject_2$1, templateObject_3$1, templateObject_4$1, templateObject_5$1;
|
2547
2570
|
|
2571
|
+
var isTouchDevice = function () { return typeof window !== 'undefined' && ('ontouchstart' in window || navigator.maxTouchPoints > 0); };
|
2548
2572
|
var Tabs = function (_a) {
|
2549
2573
|
var _b, _c;
|
2550
2574
|
var tabs = _a.tabs, font = _a.font, _d = _a.displayMode, displayMode = _d === undefined ? "dark" : _d, accentColor = _a.accentColor, tabPadding = _a.tabPadding, onTabChange = _a.onTabChange, activeTabId = _a.activeTabId;
|
@@ -2553,6 +2577,9 @@ var Tabs = function (_a) {
|
|
2553
2577
|
var activeTab = isControlled ? activeTabId : internalActiveTabId;
|
2554
2578
|
var _f = useState({ left: 0, width: 0 }), indicatorStyle = _f[0], setIndicatorStyle = _f[1];
|
2555
2579
|
var tabRefs = useRef([]);
|
2580
|
+
var tabsListRef = useRef(null);
|
2581
|
+
// Drag state for mobile
|
2582
|
+
var dragState = useRef({ startX: 0, scrollLeft: 0, dragging: false });
|
2556
2583
|
useEffect(function () {
|
2557
2584
|
onTabChange && onTabChange(activeTab);
|
2558
2585
|
var updateIndicator = function () {
|
@@ -2572,14 +2599,43 @@ var Tabs = function (_a) {
|
|
2572
2599
|
}
|
2573
2600
|
onTabChange === null || onTabChange === undefined ? undefined : onTabChange(id);
|
2574
2601
|
};
|
2602
|
+
// Drag handlers
|
2603
|
+
useEffect(function () {
|
2604
|
+
var el = tabsListRef.current;
|
2605
|
+
if (!el || !isTouchDevice())
|
2606
|
+
return;
|
2607
|
+
var onTouchStart = function (e) {
|
2608
|
+
dragState.current.dragging = true;
|
2609
|
+
dragState.current.startX = e.touches[0].pageX - el.offsetLeft;
|
2610
|
+
dragState.current.scrollLeft = el.scrollLeft;
|
2611
|
+
};
|
2612
|
+
var onTouchMove = function (e) {
|
2613
|
+
if (!dragState.current.dragging)
|
2614
|
+
return;
|
2615
|
+
var x = e.touches[0].pageX - el.offsetLeft;
|
2616
|
+
var walk = dragState.current.startX - x;
|
2617
|
+
el.scrollLeft = dragState.current.scrollLeft + walk;
|
2618
|
+
};
|
2619
|
+
var onTouchEnd = function () {
|
2620
|
+
dragState.current.dragging = false;
|
2621
|
+
};
|
2622
|
+
el.addEventListener('touchstart', onTouchStart);
|
2623
|
+
el.addEventListener('touchmove', onTouchMove);
|
2624
|
+
el.addEventListener('touchend', onTouchEnd);
|
2625
|
+
return function () {
|
2626
|
+
el.removeEventListener('touchstart', onTouchStart);
|
2627
|
+
el.removeEventListener('touchmove', onTouchMove);
|
2628
|
+
el.removeEventListener('touchend', onTouchEnd);
|
2629
|
+
};
|
2630
|
+
}, [tabs]);
|
2575
2631
|
return (React__default.createElement(TabsContainer, null,
|
2576
|
-
React__default.createElement(TabsList,
|
2632
|
+
React__default.createElement(TabsList, { ref: tabsListRef },
|
2577
2633
|
tabs.map(function (tab, index) { return (React__default.createElement(Tab, { ref: function (el) { tabRefs.current[index] = el; }, key: tab.id, active: activeTab === tab.id, onClick: function () { return handleTabClick(tab.id); }, font: font, accentColor: accentColor, displayMode: displayMode, tabPadding: tabPadding }, (font === null || font === undefined ? undefined : font.casing) ? formatText(tab.label, font.casing) : tab.label)); }),
|
2578
2634
|
React__default.createElement(ActiveIndicator, { accentColor: accentColor, left: indicatorStyle.left, width: indicatorStyle.width })),
|
2579
2635
|
React__default.createElement(TabPanel, null, (_c = tabs.find(function (tab) { return tab.id === activeTab; })) === null || _c === undefined ? undefined : _c.content)));
|
2580
2636
|
};
|
2581
2637
|
var TabsContainer = newStyled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n position: relative;\n"], ["\n width: 100%;\n position: relative;\n"])));
|
2582
|
-
var TabsList = newStyled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n position: relative;\n"], ["\n display: flex;\n justify-content: center;\n position: relative;\n"])));
|
2638
|
+
var TabsList = newStyled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n position: relative;\n overflow-x: auto;\n scrollbar-width: none;\n -ms-overflow-style: none;\n &::-webkit-scrollbar { display: none; }\n width: 100%;\n scroll-behavior: smooth;\n @media (max-width: 700px) {\n justify-content: flex-start;\n cursor: grab;\n -webkit-overflow-scrolling: touch;\n }\n"], ["\n display: flex;\n justify-content: center;\n position: relative;\n overflow-x: auto;\n scrollbar-width: none;\n -ms-overflow-style: none;\n &::-webkit-scrollbar { display: none; }\n width: 100%;\n scroll-behavior: smooth;\n @media (max-width: 700px) {\n justify-content: flex-start;\n cursor: grab;\n -webkit-overflow-scrolling: touch;\n }\n"])));
|
2583
2639
|
var Tab = newStyled.button(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding: ", ";\n width: fit-content;\n border: none;\n background: ", ";\n color: ", ";\n font-size: 16px;\n cursor: pointer;\n border-bottom: 2px solid rgba(255, 255, 255, 0.1);\n outline: none;\n transition: color 0.3s;\n font-size: ", ";\n font-weight: ", ";\n letter-spacing: 1px;\n &:hover {\n background: ", "\n }\n"], ["\n padding: ", ";\n width: fit-content;\n border: none;\n background: ", ";\n color: ", ";\n font-size: 16px;\n cursor: pointer;\n border-bottom: 2px solid rgba(255, 255, 255, 0.1);\n outline: none;\n transition: color 0.3s;\n font-size: ", ";\n font-weight: ", ";\n letter-spacing: 1px;\n &:hover {\n background: ", "\n }\n"])), function (props) { return props.tabPadding || "14px 32px 12px"; }, function (props) { return props.active ? (props.displayMode === "dark" ? "rgba(255, 255, 255, 0.1)" : theme.black) : "transparent"; }, function (props) { return (props.active ? (props.displayMode === "dark" ? "white" : "black") : (props.displayMode === "dark" ? "#AEAEAE" : theme.black)); }, function (props) { var _a; return (((_a = props.font) === null || _a === undefined ? undefined : _a.size) || "12px"); }, function (props) { var _a; return (((_a = props.font) === null || _a === undefined ? undefined : _a.weight) || "12px"); }, function (props) { return props.displayMode === "dark" ? "rgba(255, 255, 255, 0.1)" : theme.black; });
|
2584
2640
|
var ActiveIndicator = newStyled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: absolute;\n bottom: 0;\n left: ", "px;\n width: ", "px;\n height: 2px;\n background: ", ";\n transition: left 0.3s ease, width 0.3s ease;\n"], ["\n position: absolute;\n bottom: 0;\n left: ", "px;\n width: ", "px;\n height: 2px;\n background: ", ";\n transition: left 0.3s ease, width 0.3s ease;\n"])), function (props) { return props.left; }, function (props) { return props.width; }, function (props) { return props.accentColor || theme.primary; });
|
2585
2641
|
var TabPanel = newStyled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding: 16px;\n font-size: 14px;\n"], ["\n padding: 16px;\n font-size: 14px;\n"])));
|