@popsure/dirty-swan 0.66.25 → 0.66.26
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/cjs/index.js +21 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/table/utils/useTableNavigation/useTableNavigation.d.ts +3 -1
- package/dist/esm/components/table/Table.js +4 -3
- package/dist/esm/components/table/Table.js.map +1 -1
- package/dist/esm/components/table/Table.stories.js +1 -1
- package/dist/esm/components/table/Table.test.js +42 -3
- package/dist/esm/components/table/Table.test.js.map +1 -1
- package/dist/esm/components/table/utils/useTableNavigation/useTableNavigation.test.js +51 -1
- package/dist/esm/components/table/utils/useTableNavigation/useTableNavigation.test.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/lib/components/table/utils/useTableNavigation/useTableNavigation.d.ts +3 -1
- package/dist/esm/{useTableNavigation-CrxoXTVd.js → useTableNavigation-C-vb2BxI.js} +20 -5
- package/dist/esm/useTableNavigation-C-vb2BxI.js.map +1 -0
- package/package.json +1 -1
- package/src/lib/components/table/Table.test.tsx +64 -0
- package/src/lib/components/table/Table.tsx +5 -5
- package/src/lib/components/table/utils/useTableNavigation/useTableNavigation.test.tsx +58 -0
- package/src/lib/components/table/utils/useTableNavigation/useTableNavigation.ts +25 -3
- package/dist/esm/useTableNavigation-CrxoXTVd.js.map +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -22984,8 +22984,17 @@ var TableContents = function (_a) {
|
|
|
22984
22984
|
};
|
|
22985
22985
|
|
|
22986
22986
|
var useTableNavigation = function (_a) {
|
|
22987
|
-
var enabled = _a.enabled, containerRef = _a.containerRef, onSelectionChanged = _a.onSelectionChanged;
|
|
22988
|
-
var
|
|
22987
|
+
var enabled = _a.enabled, containerRef = _a.containerRef, _b = _a.initialSection, initialSection = _b === void 0 ? 0 : _b, onSelectionChanged = _a.onSelectionChanged;
|
|
22988
|
+
var _c = React.useState(initialSection), activeSection = _c[0], setActiveSection = _c[1];
|
|
22989
|
+
var activeSectionRef = React.useRef(initialSection);
|
|
22990
|
+
var skipNextReportRef = React.useRef(false);
|
|
22991
|
+
var syncActiveSection = React.useCallback(function (section) {
|
|
22992
|
+
if (section === activeSectionRef.current) {
|
|
22993
|
+
return;
|
|
22994
|
+
}
|
|
22995
|
+
skipNextReportRef.current = true;
|
|
22996
|
+
setActiveSection(section);
|
|
22997
|
+
}, []);
|
|
22989
22998
|
var handleScrollToSection = function (increase) {
|
|
22990
22999
|
if (!enabled) {
|
|
22991
23000
|
return;
|
|
@@ -23012,10 +23021,15 @@ var useTableNavigation = function (_a) {
|
|
|
23012
23021
|
return container === null || container === void 0 ? void 0 : container.removeEventListener('scroll', handleTableScroll);
|
|
23013
23022
|
}, [enabled]);
|
|
23014
23023
|
React.useEffect(function () {
|
|
23024
|
+
activeSectionRef.current = activeSection;
|
|
23025
|
+
var skipReport = skipNextReportRef.current;
|
|
23026
|
+
skipNextReportRef.current = false;
|
|
23015
23027
|
if (!enabled) {
|
|
23016
23028
|
return;
|
|
23017
23029
|
}
|
|
23018
|
-
|
|
23030
|
+
if (!skipReport) {
|
|
23031
|
+
onSelectionChanged === null || onSelectionChanged === void 0 ? void 0 : onSelectionChanged(activeSection + 1);
|
|
23032
|
+
}
|
|
23019
23033
|
if (containerRef.current) {
|
|
23020
23034
|
var containerWidth = containerRef.current.getBoundingClientRect().width;
|
|
23021
23035
|
var cellWidth = containerWidth / 2;
|
|
@@ -23030,6 +23044,7 @@ var useTableNavigation = function (_a) {
|
|
|
23030
23044
|
activeSection: activeSection + 1,
|
|
23031
23045
|
navigateTable: handleScrollToSection,
|
|
23032
23046
|
setActiveSection: setActiveSection,
|
|
23047
|
+
syncActiveSection: syncActiveSection,
|
|
23033
23048
|
};
|
|
23034
23049
|
};
|
|
23035
23050
|
|
|
@@ -23123,8 +23138,9 @@ var Table = function (_a) {
|
|
|
23123
23138
|
var _s = useTableNavigation({
|
|
23124
23139
|
enabled: isMobile,
|
|
23125
23140
|
containerRef: containerRef,
|
|
23141
|
+
initialSection: externalActiveSection ? externalActiveSection - 1 : 0,
|
|
23126
23142
|
onSelectionChanged: onSelectionChanged,
|
|
23127
|
-
}), activeSection = _s.activeSection, navigateTable = _s.navigateTable, setActiveSection = _s.setActiveSection;
|
|
23143
|
+
}), activeSection = _s.activeSection, navigateTable = _s.navigateTable, setActiveSection = _s.setActiveSection, syncActiveSection = _s.syncActiveSection;
|
|
23128
23144
|
var headerRow = (_c = (_b = tableData === null || tableData === void 0 ? void 0 : tableData[0]) === null || _b === void 0 ? void 0 : _b.rows) === null || _c === void 0 ? void 0 : _c[0];
|
|
23129
23145
|
var titleCell = __assign({ text: '' }, ((headerRow === null || headerRow === void 0 ? void 0 : headerRow[0]) || {}));
|
|
23130
23146
|
var currentActiveSection = headerRow === null || headerRow === void 0 ? void 0 : headerRow[activeSection];
|
|
@@ -23151,7 +23167,7 @@ var Table = function (_a) {
|
|
|
23151
23167
|
}, []);
|
|
23152
23168
|
React.useEffect(function () {
|
|
23153
23169
|
if (externalActiveSection && externalActiveSection !== activeSection) {
|
|
23154
|
-
|
|
23170
|
+
syncActiveSection(externalActiveSection - 1);
|
|
23155
23171
|
}
|
|
23156
23172
|
}, [externalActiveSection]);
|
|
23157
23173
|
return (jsxRuntime.jsxs("div", { className: classNames(styles$6.wrapper, 'bg-white'), children: [isMobile ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!useTabs && (titleCell === null || titleCell === void 0 ? void 0 : titleCell.text) && (jsxRuntime.jsx(TableCell, __assign({}, titleCell, { align: "left", isNavigation: true, isTopLeftCell: true, type: undefined }))), !hideTableNavigation && currentActiveSection && (useTabs ? (jsxRuntime.jsx("div", { className: classNames('bg-white', styles$6.stickyHeader), style: { top: "".concat(stickyHeaderTopOffset, "px") }, children: jsxRuntime.jsx(Tabs, { tabs: mobileTabs, activeIndex: activeSection - 1, onTabChange: function (index) { return setActiveSection(index); }, className: "mb16" }) })) : (jsxRuntime.jsx(TableControls, { activeSection: activeSection, columnsLength: columnsLength, navigateTable: navigateTable, stickyHeaderTopOffset: stickyHeaderTopOffset, children: jsxRuntime.jsx(TableCell, __assign({}, (isBaseCell(currentActiveSection)
|