@popsure/dirty-swan 0.66.25 → 0.66.27

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.
Files changed (28) hide show
  1. package/dist/cjs/index.js +27 -10
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/lib/components/table/utils/useTableNavigation/useTableNavigation.d.ts +3 -1
  4. package/dist/esm/components/table/Table.js +4 -3
  5. package/dist/esm/components/table/Table.js.map +1 -1
  6. package/dist/esm/components/table/Table.stories.js +1 -1
  7. package/dist/esm/components/table/Table.test.js +42 -3
  8. package/dist/esm/components/table/Table.test.js.map +1 -1
  9. package/dist/esm/components/table/components/TableCell/ButtonCell/ButtonCell.js +3 -3
  10. package/dist/esm/components/table/components/TableCell/ButtonCell/ButtonCell.js.map +1 -1
  11. package/dist/esm/components/table/components/TableCell/TableCell.js +3 -2
  12. package/dist/esm/components/table/components/TableCell/TableCell.js.map +1 -1
  13. package/dist/esm/components/table/utils/useTableNavigation/useTableNavigation.test.js +51 -1
  14. package/dist/esm/components/table/utils/useTableNavigation/useTableNavigation.test.js.map +1 -1
  15. package/dist/esm/index.js +1 -1
  16. package/dist/esm/lib/components/table/utils/useTableNavigation/useTableNavigation.d.ts +3 -1
  17. package/dist/esm/{useTableNavigation-CrxoXTVd.js → useTableNavigation-C-vb2BxI.js} +20 -5
  18. package/dist/esm/useTableNavigation-C-vb2BxI.js.map +1 -0
  19. package/package.json +1 -1
  20. package/src/lib/components/table/Table.test.tsx +64 -0
  21. package/src/lib/components/table/Table.tsx +5 -5
  22. package/src/lib/components/table/components/TableCell/ButtonCell/ButtonCell.module.scss +5 -0
  23. package/src/lib/components/table/components/TableCell/ButtonCell/ButtonCell.tsx +1 -0
  24. package/src/lib/components/table/components/TableCell/TableCell.module.scss +6 -0
  25. package/src/lib/components/table/components/TableCell/TableCell.tsx +1 -0
  26. package/src/lib/components/table/utils/useTableNavigation/useTableNavigation.test.tsx +58 -0
  27. package/src/lib/components/table/utils/useTableNavigation/useTableNavigation.ts +25 -3
  28. package/dist/esm/useTableNavigation-CrxoXTVd.js.map +0 -1
package/dist/cjs/index.js CHANGED
@@ -22659,8 +22659,8 @@ var Accordion = function (_a) {
22659
22659
  }) }));
22660
22660
  };
22661
22661
 
22662
- var css_248z$b = ".TableCell-module_th__2rjCU {\n vertical-align: middle;\n scroll-snap-align: end;\n width: 50%;\n padding: 28px 24px;\n}\n@media (min-width: 34rem) {\n .TableCell-module_th__2rjCU {\n width: auto;\n scroll-snap-align: unset;\n }\n}\n.TableCell-module_thNavigation__qZ2sY {\n width: 100%;\n}\n@media (min-width: 34rem) {\n .TableCell-module_thNavigation__qZ2sY {\n width: auto;\n }\n}\n\n.TableCell-module_navigationTitle__2FiRB {\n padding-left: 0;\n}\n\n.TableCell-module_headerCell__aVTIn {\n vertical-align: top;\n}\n\n.TableCell-module_subtitleCell__1DzfG {\n vertical-align: middle;\n}\n\n.TableCell-module_fixedCell__cL3-m {\n position: sticky;\n left: 0;\n z-index: 2;\n padding-left: 0;\n}\n\n.TableCell-module_selectedColumnTop__1GcJz {\n border-radius: 16px 16px 0 0;\n}\n\n.TableCell-module_selectedColumnBottom__qiMke {\n border-radius: 0 0 16px 16px;\n}\n\n.TableCell-module_fixedCard__2LO8s {\n position: sticky;\n left: 0;\n right: 0;\n z-index: 2;\n width: 100%;\n}";
22663
- var styles$b = {"th":"TableCell-module_th__2rjCU","thNavigation":"TableCell-module_thNavigation__qZ2sY","navigationTitle":"TableCell-module_navigationTitle__2FiRB","headerCell":"TableCell-module_headerCell__aVTIn","subtitleCell":"TableCell-module_subtitleCell__1DzfG","fixedCell":"TableCell-module_fixedCell__cL3-m","selectedColumnTop":"TableCell-module_selectedColumnTop__1GcJz","selectedColumnBottom":"TableCell-module_selectedColumnBottom__qiMke","fixedCard":"TableCell-module_fixedCard__2LO8s"};
22662
+ var css_248z$b = ".TableCell-module_th__2rjCU {\n vertical-align: middle;\n scroll-snap-align: end;\n width: 50%;\n padding: 28px 24px;\n}\n@media (min-width: 34rem) {\n .TableCell-module_th__2rjCU {\n width: auto;\n scroll-snap-align: unset;\n }\n}\n.TableCell-module_thNavigation__qZ2sY {\n width: 100%;\n}\n@media (min-width: 34rem) {\n .TableCell-module_thNavigation__qZ2sY {\n width: auto;\n }\n}\n\n.TableCell-module_navigationTitle__2FiRB {\n padding-left: 0;\n}\n\n.TableCell-module_headerCell__aVTIn {\n vertical-align: top;\n}\n\n.TableCell-module_subtitleCell__1DzfG {\n vertical-align: middle;\n}\n\n.TableCell-module_fixedCell__cL3-m {\n position: sticky;\n left: 0;\n z-index: 2;\n padding-left: 0;\n}\n\n.TableCell-module_buttonCell__15CRG {\n height: 1px;\n}\n\n.TableCell-module_selectedColumnTop__1GcJz {\n border-radius: 16px 16px 0 0;\n}\n\n.TableCell-module_selectedColumnBottom__qiMke {\n border-radius: 0 0 16px 16px;\n}\n\n.TableCell-module_fixedCard__2LO8s {\n position: sticky;\n left: 0;\n right: 0;\n z-index: 2;\n width: 100%;\n}";
22663
+ var styles$b = {"th":"TableCell-module_th__2rjCU","thNavigation":"TableCell-module_thNavigation__qZ2sY","navigationTitle":"TableCell-module_navigationTitle__2FiRB","headerCell":"TableCell-module_headerCell__aVTIn","subtitleCell":"TableCell-module_subtitleCell__1DzfG","fixedCell":"TableCell-module_fixedCell__cL3-m","buttonCell":"TableCell-module_buttonCell__15CRG","selectedColumnTop":"TableCell-module_selectedColumnTop__1GcJz","selectedColumnBottom":"TableCell-module_selectedColumnBottom__qiMke","fixedCard":"TableCell-module_fixedCard__2LO8s"};
22664
22664
  styleInject(css_248z$b);
22665
22665
 
22666
22666
  var css_248z$a = "@media (max-width: 34rem) {\n .BaseCell-module_maxWidth__14Cly {\n max-width: calc(100% - 64px);\n }\n}\n\n.BaseCell-module_icon__1775U {\n margin: 2px;\n}\n\n.BaseCell-module_description__3_kfe {\n word-break: break-word;\n}";
@@ -22750,14 +22750,14 @@ var CardCell = function (_a) {
22750
22750
  return (jsxRuntime.jsx("div", { className: "ta-left", children: jsxRuntime.jsx(Card, __assign({ title: title, description: description, density: "medium", icon: renderedIcon, onClick: onClick }, (href && { href: href, as: 'a' }), { actionIcon: null, showActionIcon: false })) }));
22751
22751
  };
22752
22752
 
22753
- var css_248z$7 = ".ButtonCell-module_buttonCell__x4NNi {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: calc(100% + 40px);\n margin-left: -20px;\n margin-right: -20px;\n padding: 16px 24px;\n border-radius: 12px;\n border: 1px solid #e7e7ed;\n background-color: transparent;\n color: #26262e;\n cursor: pointer;\n transition: border-color 0.3s ease-in-out, background-color 0.3s ease-in-out;\n text-align: left;\n}\n.ButtonCell-module_buttonCell__x4NNi:hover:not(:disabled):not(.ButtonCell-module_selected__22pF_) {\n background-color: #FAF8F5;\n}\n.ButtonCell-module_buttonCell__x4NNi:focus-visible {\n outline: 1px solid #26262e;\n outline-offset: 0;\n}\n@media (max-width: 34rem) {\n .ButtonCell-module_buttonCell__x4NNi {\n pointer-events: none;\n }\n}\n\n.ButtonCell-module_selected__22pF_ {\n border: 1px solid #26262e;\n background-color: #FAF8F5;\n}\n\n.ButtonCell-module_disabled__1TmtK {\n background-color: #f7f7fd;\n cursor: default;\n opacity: 1;\n pointer-events: none;\n}";
22754
- var styles$7 = {"buttonCell":"ButtonCell-module_buttonCell__x4NNi","selected":"ButtonCell-module_selected__22pF_","disabled":"ButtonCell-module_disabled__1TmtK"};
22753
+ var css_248z$7 = ".ButtonCell-module_wrapper__1H62k {\n height: 100%;\n}\n\n.ButtonCell-module_buttonCell__x4NNi {\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: calc(100% + 40px);\n margin-left: -20px;\n margin-right: -20px;\n padding: 16px 24px;\n border-radius: 12px;\n border: 1px solid #e7e7ed;\n background-color: transparent;\n color: #26262e;\n cursor: pointer;\n transition: border-color 0.3s ease-in-out, background-color 0.3s ease-in-out;\n text-align: left;\n}\n.ButtonCell-module_buttonCell__x4NNi:hover:not(:disabled):not(.ButtonCell-module_selected__22pF_) {\n background-color: #FAF8F5;\n}\n.ButtonCell-module_buttonCell__x4NNi:focus-visible {\n outline: 1px solid #26262e;\n outline-offset: 0;\n}\n@media (max-width: 34rem) {\n .ButtonCell-module_buttonCell__x4NNi {\n pointer-events: none;\n }\n}\n\n.ButtonCell-module_selected__22pF_ {\n border: 1px solid #26262e;\n background-color: #FAF8F5;\n}\n\n.ButtonCell-module_disabled__1TmtK {\n background-color: #f7f7fd;\n cursor: default;\n opacity: 1;\n pointer-events: none;\n}";
22754
+ var styles$7 = {"wrapper":"ButtonCell-module_wrapper__1H62k","buttonCell":"ButtonCell-module_buttonCell__x4NNi","selected":"ButtonCell-module_selected__22pF_","disabled":"ButtonCell-module_disabled__1TmtK"};
22755
22755
  styleInject(css_248z$7);
22756
22756
 
22757
22757
  var ButtonCell = function (_a) {
22758
22758
  var _b;
22759
22759
  var isSelected = _a.isSelected, onClick = _a.onClick, buttonCaption = _a.buttonCaption, price = _a.price, disabled = _a.disabled, className = _a.className, dataCy = _a.dataCy, dataTestId = _a.dataTestId;
22760
- return (jsxRuntime.jsx("div", { className: classNames("w100 d-flex fd-column ai-start jc-center gap8", className), "data-cy": dataCy, "data-testid": dataTestId, children: jsxRuntime.jsxs("button", { className: classNames('w100 wmx5', styles$7.buttonCell, (_b = {},
22760
+ return (jsxRuntime.jsx("div", { className: classNames("w100 d-flex fd-column ai-start jc-center gap8", styles$7.wrapper, className), "data-cy": dataCy, "data-testid": dataTestId, children: jsxRuntime.jsxs("button", { className: classNames('w100 wmx5', styles$7.buttonCell, (_b = {},
22761
22761
  _b[styles$7.selected] = isSelected,
22762
22762
  _b[styles$7.disabled] = disabled,
22763
22763
  _b)), type: "button", onClick: onClick, disabled: disabled, children: [jsxRuntime.jsxs("div", { className: "d-flex fd-column ai-start", children: [jsxRuntime.jsx("span", { className: "p-p fw-bold", children: buttonCaption }), price && jsxRuntime.jsx("span", { className: "p-p", children: price })] }), !disabled && (isSelected ? (jsxRuntime.jsx(CircleSelectedIcon, { size: 16 })) : (jsxRuntime.jsx(CircleUnselectedIcon, { size: 16 })))] }) }));
@@ -22787,6 +22787,7 @@ var TableCell = React.memo(function (_a) {
22787
22787
  _b[styles$b.navigationTitle] = isNavigation && isTopLeftCell,
22788
22788
  _b[styles$b.fixedCell] = isFirstCellInRow && colSpan < 1,
22789
22789
  _b[styles$b.fixedCard] = cellProps.type === 'CARD',
22790
+ _b[styles$b.buttonCell] = cellProps.type === 'BUTTON',
22790
22791
  _b[styles$b.selectedColumnTop] = selectedColumnPosition === 'top',
22791
22792
  _b[styles$b.selectedColumnBottom] = selectedColumnPosition === 'bottom',
22792
22793
  _b)), colSpan: isBelowDesktop && cellProps.type === 'CARD' ? 2 : colSpan, children: [!cellProps.type && (jsxRuntime.jsx(BaseCell, __assign({}, cellProps, { fontVariant: (_c = cellProps.fontVariant) !== null && _c !== void 0 ? _c : (isTopLeftCell ? 'TITLE' : 'NORMAL') }))), cellProps.type === 'CTA' && (jsxRuntime.jsx(CTACell, __assign({}, cellProps, { centered: isNavigation }))), cellProps.type === 'BUTTON' && jsxRuntime.jsx(ButtonCell, __assign({}, cellProps)), cellProps.type === 'CARD' && jsxRuntime.jsx(CardCell, __assign({}, cellProps))] })));
@@ -22984,8 +22985,17 @@ var TableContents = function (_a) {
22984
22985
  };
22985
22986
 
22986
22987
  var useTableNavigation = function (_a) {
22987
- var enabled = _a.enabled, containerRef = _a.containerRef, onSelectionChanged = _a.onSelectionChanged;
22988
- var _b = React.useState(0), activeSection = _b[0], setActiveSection = _b[1];
22988
+ var enabled = _a.enabled, containerRef = _a.containerRef, _b = _a.initialSection, initialSection = _b === void 0 ? 0 : _b, onSelectionChanged = _a.onSelectionChanged;
22989
+ var _c = React.useState(initialSection), activeSection = _c[0], setActiveSection = _c[1];
22990
+ var activeSectionRef = React.useRef(initialSection);
22991
+ var skipNextReportRef = React.useRef(false);
22992
+ var syncActiveSection = React.useCallback(function (section) {
22993
+ if (section === activeSectionRef.current) {
22994
+ return;
22995
+ }
22996
+ skipNextReportRef.current = true;
22997
+ setActiveSection(section);
22998
+ }, []);
22989
22999
  var handleScrollToSection = function (increase) {
22990
23000
  if (!enabled) {
22991
23001
  return;
@@ -23012,10 +23022,15 @@ var useTableNavigation = function (_a) {
23012
23022
  return container === null || container === void 0 ? void 0 : container.removeEventListener('scroll', handleTableScroll);
23013
23023
  }, [enabled]);
23014
23024
  React.useEffect(function () {
23025
+ activeSectionRef.current = activeSection;
23026
+ var skipReport = skipNextReportRef.current;
23027
+ skipNextReportRef.current = false;
23015
23028
  if (!enabled) {
23016
23029
  return;
23017
23030
  }
23018
- onSelectionChanged === null || onSelectionChanged === void 0 ? void 0 : onSelectionChanged(activeSection + 1);
23031
+ if (!skipReport) {
23032
+ onSelectionChanged === null || onSelectionChanged === void 0 ? void 0 : onSelectionChanged(activeSection + 1);
23033
+ }
23019
23034
  if (containerRef.current) {
23020
23035
  var containerWidth = containerRef.current.getBoundingClientRect().width;
23021
23036
  var cellWidth = containerWidth / 2;
@@ -23030,6 +23045,7 @@ var useTableNavigation = function (_a) {
23030
23045
  activeSection: activeSection + 1,
23031
23046
  navigateTable: handleScrollToSection,
23032
23047
  setActiveSection: setActiveSection,
23048
+ syncActiveSection: syncActiveSection,
23033
23049
  };
23034
23050
  };
23035
23051
 
@@ -23123,8 +23139,9 @@ var Table = function (_a) {
23123
23139
  var _s = useTableNavigation({
23124
23140
  enabled: isMobile,
23125
23141
  containerRef: containerRef,
23142
+ initialSection: externalActiveSection ? externalActiveSection - 1 : 0,
23126
23143
  onSelectionChanged: onSelectionChanged,
23127
- }), activeSection = _s.activeSection, navigateTable = _s.navigateTable, setActiveSection = _s.setActiveSection;
23144
+ }), activeSection = _s.activeSection, navigateTable = _s.navigateTable, setActiveSection = _s.setActiveSection, syncActiveSection = _s.syncActiveSection;
23128
23145
  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
23146
  var titleCell = __assign({ text: '' }, ((headerRow === null || headerRow === void 0 ? void 0 : headerRow[0]) || {}));
23130
23147
  var currentActiveSection = headerRow === null || headerRow === void 0 ? void 0 : headerRow[activeSection];
@@ -23151,7 +23168,7 @@ var Table = function (_a) {
23151
23168
  }, []);
23152
23169
  React.useEffect(function () {
23153
23170
  if (externalActiveSection && externalActiveSection !== activeSection) {
23154
- setActiveSection(externalActiveSection - 1);
23171
+ syncActiveSection(externalActiveSection - 1);
23155
23172
  }
23156
23173
  }, [externalActiveSection]);
23157
23174
  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)