wex-ui-lib 1.4.4 → 1.4.5
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 +35 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +35 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -2545,6 +2545,7 @@ var Item = newStyled.button(templateObject_4$1 || (templateObject_4$1 = __makeTe
|
|
2545
2545
|
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
2546
|
var templateObject_1$1, templateObject_2$1, templateObject_3$1, templateObject_4$1, templateObject_5$1;
|
2547
2547
|
|
2548
|
+
var isTouchDevice = function () { return typeof window !== 'undefined' && ('ontouchstart' in window || navigator.maxTouchPoints > 0); };
|
2548
2549
|
var Tabs = function (_a) {
|
2549
2550
|
var _b, _c;
|
2550
2551
|
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 +2554,9 @@ var Tabs = function (_a) {
|
|
2553
2554
|
var activeTab = isControlled ? activeTabId : internalActiveTabId;
|
2554
2555
|
var _f = useState({ left: 0, width: 0 }), indicatorStyle = _f[0], setIndicatorStyle = _f[1];
|
2555
2556
|
var tabRefs = useRef([]);
|
2557
|
+
var tabsListRef = useRef(null);
|
2558
|
+
// Drag state for mobile
|
2559
|
+
var dragState = useRef({ startX: 0, scrollLeft: 0, dragging: false });
|
2556
2560
|
useEffect(function () {
|
2557
2561
|
onTabChange && onTabChange(activeTab);
|
2558
2562
|
var updateIndicator = function () {
|
@@ -2572,14 +2576,43 @@ var Tabs = function (_a) {
|
|
2572
2576
|
}
|
2573
2577
|
onTabChange === null || onTabChange === undefined ? undefined : onTabChange(id);
|
2574
2578
|
};
|
2579
|
+
// Drag handlers
|
2580
|
+
useEffect(function () {
|
2581
|
+
var el = tabsListRef.current;
|
2582
|
+
if (!el || !isTouchDevice())
|
2583
|
+
return;
|
2584
|
+
var onTouchStart = function (e) {
|
2585
|
+
dragState.current.dragging = true;
|
2586
|
+
dragState.current.startX = e.touches[0].pageX - el.offsetLeft;
|
2587
|
+
dragState.current.scrollLeft = el.scrollLeft;
|
2588
|
+
};
|
2589
|
+
var onTouchMove = function (e) {
|
2590
|
+
if (!dragState.current.dragging)
|
2591
|
+
return;
|
2592
|
+
var x = e.touches[0].pageX - el.offsetLeft;
|
2593
|
+
var walk = dragState.current.startX - x;
|
2594
|
+
el.scrollLeft = dragState.current.scrollLeft + walk;
|
2595
|
+
};
|
2596
|
+
var onTouchEnd = function () {
|
2597
|
+
dragState.current.dragging = false;
|
2598
|
+
};
|
2599
|
+
el.addEventListener('touchstart', onTouchStart);
|
2600
|
+
el.addEventListener('touchmove', onTouchMove);
|
2601
|
+
el.addEventListener('touchend', onTouchEnd);
|
2602
|
+
return function () {
|
2603
|
+
el.removeEventListener('touchstart', onTouchStart);
|
2604
|
+
el.removeEventListener('touchmove', onTouchMove);
|
2605
|
+
el.removeEventListener('touchend', onTouchEnd);
|
2606
|
+
};
|
2607
|
+
}, [tabs]);
|
2575
2608
|
return (React__default.createElement(TabsContainer, null,
|
2576
|
-
React__default.createElement(TabsList,
|
2609
|
+
React__default.createElement(TabsList, { ref: tabsListRef },
|
2577
2610
|
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
2611
|
React__default.createElement(ActiveIndicator, { accentColor: accentColor, left: indicatorStyle.left, width: indicatorStyle.width })),
|
2579
2612
|
React__default.createElement(TabPanel, null, (_c = tabs.find(function (tab) { return tab.id === activeTab; })) === null || _c === undefined ? undefined : _c.content)));
|
2580
2613
|
};
|
2581
2614
|
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"])));
|
2615
|
+
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
2616
|
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
2617
|
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
2618
|
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"])));
|