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 CHANGED
@@ -2565,6 +2565,7 @@ var Item = newStyled.button(templateObject_4$1 || (templateObject_4$1 = __makeTe
2565
2565
  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"])));
2566
2566
  var templateObject_1$1, templateObject_2$1, templateObject_3$1, templateObject_4$1, templateObject_5$1;
2567
2567
 
2568
+ var isTouchDevice = function () { return typeof window !== 'undefined' && ('ontouchstart' in window || navigator.maxTouchPoints > 0); };
2568
2569
  var Tabs = function (_a) {
2569
2570
  var _b, _c;
2570
2571
  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;
@@ -2573,6 +2574,9 @@ var Tabs = function (_a) {
2573
2574
  var activeTab = isControlled ? activeTabId : internalActiveTabId;
2574
2575
  var _f = React.useState({ left: 0, width: 0 }), indicatorStyle = _f[0], setIndicatorStyle = _f[1];
2575
2576
  var tabRefs = React.useRef([]);
2577
+ var tabsListRef = React.useRef(null);
2578
+ // Drag state for mobile
2579
+ var dragState = React.useRef({ startX: 0, scrollLeft: 0, dragging: false });
2576
2580
  React.useEffect(function () {
2577
2581
  onTabChange && onTabChange(activeTab);
2578
2582
  var updateIndicator = function () {
@@ -2592,14 +2596,43 @@ var Tabs = function (_a) {
2592
2596
  }
2593
2597
  onTabChange === null || onTabChange === undefined ? undefined : onTabChange(id);
2594
2598
  };
2599
+ // Drag handlers
2600
+ React.useEffect(function () {
2601
+ var el = tabsListRef.current;
2602
+ if (!el || !isTouchDevice())
2603
+ return;
2604
+ var onTouchStart = function (e) {
2605
+ dragState.current.dragging = true;
2606
+ dragState.current.startX = e.touches[0].pageX - el.offsetLeft;
2607
+ dragState.current.scrollLeft = el.scrollLeft;
2608
+ };
2609
+ var onTouchMove = function (e) {
2610
+ if (!dragState.current.dragging)
2611
+ return;
2612
+ var x = e.touches[0].pageX - el.offsetLeft;
2613
+ var walk = dragState.current.startX - x;
2614
+ el.scrollLeft = dragState.current.scrollLeft + walk;
2615
+ };
2616
+ var onTouchEnd = function () {
2617
+ dragState.current.dragging = false;
2618
+ };
2619
+ el.addEventListener('touchstart', onTouchStart);
2620
+ el.addEventListener('touchmove', onTouchMove);
2621
+ el.addEventListener('touchend', onTouchEnd);
2622
+ return function () {
2623
+ el.removeEventListener('touchstart', onTouchStart);
2624
+ el.removeEventListener('touchmove', onTouchMove);
2625
+ el.removeEventListener('touchend', onTouchEnd);
2626
+ };
2627
+ }, [tabs]);
2595
2628
  return (React.createElement(TabsContainer, null,
2596
- React.createElement(TabsList, null,
2629
+ React.createElement(TabsList, { ref: tabsListRef },
2597
2630
  tabs.map(function (tab, index) { return (React.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)); }),
2598
2631
  React.createElement(ActiveIndicator, { accentColor: accentColor, left: indicatorStyle.left, width: indicatorStyle.width })),
2599
2632
  React.createElement(TabPanel, null, (_c = tabs.find(function (tab) { return tab.id === activeTab; })) === null || _c === undefined ? undefined : _c.content)));
2600
2633
  };
2601
2634
  var TabsContainer = newStyled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n position: relative;\n"], ["\n width: 100%;\n position: relative;\n"])));
2602
- 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"])));
2635
+ 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"])));
2603
2636
  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; });
2604
2637
  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; });
2605
2638
  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"])));