@popsure/dirty-swan 0.66.22 → 0.66.24

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 (27) hide show
  1. package/dist/cjs/index.js +32 -23
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/lib/components/table/Table.stories.d.ts +4 -0
  4. package/dist/cjs/lib/components/table/components/TableCell/BaseCell/BaseCell.d.ts +1 -1
  5. package/dist/esm/components/segmentedControl/index.js +4 -5
  6. package/dist/esm/components/segmentedControl/index.js.map +1 -1
  7. package/dist/esm/components/table/Table.stories.js +134 -1
  8. package/dist/esm/components/table/Table.stories.js.map +1 -1
  9. package/dist/esm/components/table/components/TableCell/BaseCell/BaseCell.js +1 -1
  10. package/dist/esm/components/table/components/TableCell/BaseCell/BaseCell.js.map +1 -1
  11. package/dist/esm/components/table/components/TableCell/TableCell.js +4 -5
  12. package/dist/esm/components/table/components/TableCell/TableCell.js.map +1 -1
  13. package/dist/esm/components/table/components/TableCell/TableCell.test.js +14 -0
  14. package/dist/esm/components/table/components/TableCell/TableCell.test.js.map +1 -1
  15. package/dist/esm/components/table/components/TableContents/Collapsible.js +23 -12
  16. package/dist/esm/components/table/components/TableContents/Collapsible.js.map +1 -1
  17. package/dist/esm/lib/components/table/Table.stories.d.ts +4 -0
  18. package/dist/esm/lib/components/table/components/TableCell/BaseCell/BaseCell.d.ts +1 -1
  19. package/package.json +1 -1
  20. package/src/lib/components/segmentedControl/index.tsx +5 -11
  21. package/src/lib/components/segmentedControl/style.module.scss +7 -3
  22. package/src/lib/components/table/Table.stories.tsx +158 -0
  23. package/src/lib/components/table/components/TableCell/BaseCell/BaseCell.tsx +10 -1
  24. package/src/lib/components/table/components/TableCell/TableCell.module.scss +4 -0
  25. package/src/lib/components/table/components/TableCell/TableCell.test.tsx +18 -0
  26. package/src/lib/components/table/components/TableCell/TableCell.tsx +3 -3
  27. package/src/lib/components/table/components/TableContents/Collapsible.tsx +23 -11
package/dist/cjs/index.js CHANGED
@@ -21968,8 +21968,8 @@ var ComparisonTable = function (props) {
21968
21968
  }), hideDetails && (jsxRuntime.jsx("div", { className: classNames(baseStyles['show-details-container'], baseStyles.sticky, 'mt48'), children: jsxRuntime.jsx("div", { children: jsxRuntime.jsxs("button", { className: classNames('w100 d-flex p-h4 c-pointer', baseStyles['show-details-button'], classNameOverrides === null || classNameOverrides === void 0 ? void 0 : classNameOverrides.hideDetailsButton), onClick: toggleMoreRows, type: "button", children: [showMore ? hideDetailsCaption : showDetailsCaption, jsxRuntime.jsx(Chevron, { className: showMore ? '' : baseStyles['icon-inverted'] })] }) }) }))] })] }) }));
21969
21969
  };
21970
21970
 
21971
- var css_248z$g = ".style-module_background-container__2Gjka {\n position: relative;\n display: inline-block;\n background-color: var(--ds-purple-100);\n border-radius: 8px;\n padding: 0 8px;\n}\n\n.style-module_chip-container__7XeKn {\n display: flex;\n align-items: center;\n}\n\n.style-module_chip__3rgLT {\n cursor: pointer;\n z-index: 2;\n padding-left: 16px;\n padding-right: 16px;\n}\n.style-module_chip__3rgLT:focus {\n outline-color: var(--ds-purple-600);\n outline-offset: 2px;\n}\n\n.style-module_select-chip-background__YCAyw {\n position: absolute;\n background-color: white;\n border-radius: 8px;\n top: 8px;\n z-index: 1;\n transition: width 0.3s, left 0.3s;\n}";
21972
- var styles$g = {"background-container":"style-module_background-container__2Gjka","chip-container":"style-module_chip-container__7XeKn","chip":"style-module_chip__3rgLT","select-chip-background":"style-module_select-chip-background__YCAyw"};
21971
+ var css_248z$g = ".style-module_background-container__2Gjka {\n position: relative;\n display: inline-block;\n background-color: var(--ds-orange-50);\n border-radius: 8px;\n padding: 0 8px;\n}\n\n.style-module_chip-container__7XeKn {\n display: flex;\n align-items: center;\n}\n\n.style-module_chip__3rgLT {\n cursor: pointer;\n z-index: 2;\n padding-left: 16px;\n padding-right: 16px;\n}\n.style-module_chip__3rgLT:focus {\n outline-color: var(--ds-primary-900);\n outline-offset: 2px;\n}\n\n.style-module_select-chip-background__YCAyw {\n position: absolute;\n background-color: var(--ds-neutral-900);\n border-radius: 8px;\n top: 8px;\n z-index: 1;\n transition: width 0.3s, left 0.3s;\n}\n\n.style-module_text-color__6bLC9 {\n transition: color 0.15s ease-in;\n}";
21972
+ var styles$g = {"background-container":"style-module_background-container__2Gjka","chip-container":"style-module_chip-container__7XeKn","chip":"style-module_chip__3rgLT","select-chip-background":"style-module_select-chip-background__YCAyw","text-color":"style-module_text-color__6bLC9"};
21973
21973
  styleInject(css_248z$g);
21974
21974
 
21975
21975
  var SegmentedControl = function (_a) {
@@ -21985,15 +21985,14 @@ var SegmentedControl = function (_a) {
21985
21985
  setSelectedChipBackgroundWidthLeft({ left: left, width: width });
21986
21986
  }, [selectedIndex]);
21987
21987
  return (jsxRuntime.jsx("div", { className: className, children: jsxRuntime.jsxs("div", { className: styles$g['background-container'], children: [jsxRuntime.jsx("div", { ref: chipContainer, className: styles$g['chip-container'], style: { height: "".concat(height, "px") }, children: values.map(function (value, index) {
21988
+ var selectedColor = selectedIndex === index ? 'tc-white' : 'tc-neutral-900';
21988
21989
  return (jsxRuntime.jsx("div", { role: "button", tabIndex: 0, onKeyDown: function (e) {
21989
21990
  if (e.key === 'Enter' || e.code === 'Space') {
21990
21991
  onChange(index);
21991
21992
  }
21992
21993
  }, onClick: function () {
21993
21994
  onChange(index);
21994
- }, className: styles$g.chip, children: typeof value === 'string' ? (jsxRuntime.jsx("div", { className: "p-h4 ta-center ".concat(selectedIndex === index ? '' : 'tc-purple-600'), children: value })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "p-h4 ta-center ".concat(selectedIndex === index ? '' : 'tc-purple-600'), children: value.title }), jsxRuntime.jsx("div", { className: "p-p--small ta-center ".concat(selectedIndex === index
21995
- ? 'tc-neutral-600'
21996
- : 'tc-purple-600'), children: value.subtitle })] })) }, typeof value === 'string' ? value : value.title));
21995
+ }, className: styles$g.chip, children: typeof value === 'string' ? (jsxRuntime.jsx("div", { className: "p-h4 ta-center ".concat(selectedColor, " ").concat(styles$g['text-color']), children: value })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "p-h4 ta-center ".concat(selectedColor, " ").concat(styles$g['text-color']), children: value.title }), jsxRuntime.jsx("div", { className: "p-p--small ta-center ".concat(selectedColor, " ").concat(styles$g['text-color']), children: value.subtitle })] })) }, typeof value === 'string' ? value : value.title));
21997
21996
  }) }), jsxRuntime.jsx("div", { className: styles$g['select-chip-background'], style: {
21998
21997
  width: "".concat(selectedChipBackgroundWidthLeft.width, "px"),
21999
21998
  height: "".concat(height - 16, "px"),
@@ -22625,8 +22624,8 @@ var Accordion = function (_a) {
22625
22624
  }) }));
22626
22625
  };
22627
22626
 
22628
- 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_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}";
22629
- var styles$b = {"th":"TableCell-module_th__2rjCU","thNavigation":"TableCell-module_thNavigation__qZ2sY","navigationTitle":"TableCell-module_navigationTitle__2FiRB","headerCell":"TableCell-module_headerCell__aVTIn","fixedCell":"TableCell-module_fixedCell__cL3-m","selectedColumnTop":"TableCell-module_selectedColumnTop__1GcJz","selectedColumnBottom":"TableCell-module_selectedColumnBottom__qiMke","fixedCard":"TableCell-module_fixedCard__2LO8s"};
22627
+ 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}";
22628
+ 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"};
22630
22629
  styleInject(css_248z$b);
22631
22630
 
22632
22631
  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}";
@@ -22671,7 +22670,7 @@ var BaseCell = function (_a) {
22671
22670
  'jc-center': align === 'center',
22672
22671
  }), children: jsxRuntime.jsxs("div", { className: classNames('d-flex fd-column', alignClassName, (_b = {},
22673
22672
  _b[styles$a.maxWidth] = modalContent && align === 'center',
22674
- _b)), children: [jsxRuntime.jsxs("div", { className: "d-flex ai-center", children: [(rating === null || rating === void 0 ? void 0 : rating.value) && (jsxRuntime.jsx("span", { "data-testid": "table-cell-rating", title: "".concat(rating === null || rating === void 0 ? void 0 : rating.value, " out of 3"), children: validRatingValues.map(function (value) { return (jsxRuntime.jsx(SelectedIcon, { "aria-hidden": "true", color: value <= (rating === null || rating === void 0 ? void 0 : rating.value) ? 'neutral-900' : 'neutral-400', className: styles$a.icon, size: (rating === null || rating === void 0 ? void 0 : rating.type) === 'zap' ? 16 : 14 }, value)); }) })), checkmarkValue !== undefined && (jsxRuntime.jsx("span", { className: 'd-inline-block mx8', title: checkmarkValue ? 'Yes' : 'No', children: checkmarkValue ? (jsxRuntime.jsx(CheckThickIcon, { noMargin: true, "data-testid": "table-cell-boolean-yes", size: 24, "aria-hidden": true, color: "neutral-900" })) : (jsxRuntime.jsx(XIcon, { noMargin: true, "data-testid": "table-cell-boolean-no", size: 24, "aria-hidden": true, color: "neutral-500" })) })), jsxRuntime.jsxs("div", { className: "d-flex ai-center", children: [text && fontVariant === 'NORMAL' && (jsxRuntime.jsx("div", { className: classNames("p-p d-inline", { 'ml8': align !== 'left' }), "data-testid": "table-cell-text", children: text })), text && fontVariant === 'PRICE' && (jsxRuntime.jsx("div", { className: "p-h2 tc-neutral-900", "data-testid": "table-cell-content", children: text })), text && fontVariant === 'TITLE' && (jsxRuntime.jsx("h2", { "aria-hidden": true, className: "tc-grey-800 p-h2 p--serif", children: text })), modalContent && openModal && (jsxRuntime.jsx("span", { className: "ml8", children: jsxRuntime.jsx(TableInfoButton, { onClick: function () {
22673
+ _b)), children: [jsxRuntime.jsxs("div", { className: "d-flex ai-center", children: [(rating === null || rating === void 0 ? void 0 : rating.value) && (jsxRuntime.jsx("span", { "data-testid": "table-cell-rating", title: "".concat(rating === null || rating === void 0 ? void 0 : rating.value, " out of 3"), children: validRatingValues.map(function (value) { return (jsxRuntime.jsx(SelectedIcon, { "aria-hidden": "true", color: value <= (rating === null || rating === void 0 ? void 0 : rating.value) ? 'neutral-900' : 'neutral-400', className: styles$a.icon, size: (rating === null || rating === void 0 ? void 0 : rating.type) === 'zap' ? 16 : 14 }, value)); }) })), checkmarkValue !== undefined && (jsxRuntime.jsx("span", { className: 'd-inline-block mx8', title: checkmarkValue ? 'Yes' : 'No', children: checkmarkValue ? (jsxRuntime.jsx(CheckThickIcon, { noMargin: true, "data-testid": "table-cell-boolean-yes", size: 24, "aria-hidden": true, color: "neutral-900" })) : (jsxRuntime.jsx(XIcon, { noMargin: true, "data-testid": "table-cell-boolean-no", size: 24, "aria-hidden": true, color: "neutral-500" })) })), jsxRuntime.jsxs("div", { className: "d-flex ai-center", children: [text && fontVariant === 'NORMAL' && (jsxRuntime.jsx("div", { className: classNames("p-p d-inline", { 'ml8': align !== 'left' }), "data-testid": "table-cell-text", children: text })), text && fontVariant === 'PRICE' && (jsxRuntime.jsx("div", { className: "p-h2 tc-neutral-900", "data-testid": "table-cell-content", children: text })), text && fontVariant === 'TITLE' && (jsxRuntime.jsx("h2", { "aria-hidden": true, className: "tc-grey-800 p-h2 p--serif", children: text })), text && fontVariant === 'SUBTITLE' && (jsxRuntime.jsx("h2", { "aria-hidden": true, className: "tc-grey-800 p-h4", children: text })), modalContent && openModal && (jsxRuntime.jsx("span", { className: "ml8", children: jsxRuntime.jsx(TableInfoButton, { onClick: function () {
22675
22674
  return openModal({
22676
22675
  title: modalTitle,
22677
22676
  body: modalContent,
@@ -22748,15 +22747,14 @@ var TableCell = React.memo(function (_a) {
22748
22747
  'ta-left': isFirstCellInRow
22749
22748
  },
22750
22749
  _b[styles$b.headerCell] = isHeader,
22750
+ _b[styles$b.subtitleCell] = !cellProps.type && cellProps.fontVariant === 'SUBTITLE',
22751
22751
  _b[styles$b.thNavigation] = isNavigation,
22752
22752
  _b[styles$b.navigationTitle] = isNavigation && isTopLeftCell,
22753
22753
  _b[styles$b.fixedCell] = isFirstCellInRow && colSpan < 1,
22754
22754
  _b[styles$b.fixedCard] = cellProps.type === 'CARD',
22755
22755
  _b[styles$b.selectedColumnTop] = selectedColumnPosition === 'top',
22756
22756
  _b[styles$b.selectedColumnBottom] = selectedColumnPosition === 'bottom',
22757
- _b)), colSpan: isBelowDesktop && cellProps.type === 'CARD' ? 2 : colSpan, children: [!cellProps.type && (jsxRuntime.jsx(BaseCell, __assign({}, cellProps, { fontVariant: isTopLeftCell
22758
- ? 'TITLE'
22759
- : (_c = cellProps.fontVariant) !== null && _c !== void 0 ? _c : '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))] })));
22757
+ _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))] })));
22760
22758
  });
22761
22759
 
22762
22760
  var css_248z$6 = ".Table-module_wrapper__2MMNq {\n position: relative;\n border: 1px solid #f2f2f8;\n border-radius: 12px;\n padding: 24px;\n}\n\n.Table-module_container__3VFLP {\n overflow-x: auto;\n overflow-y: hidden;\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n -webkit-overflow-scrolling: touch;\n scroll-snap-type: x mandatory;\n}\n.Table-module_container__3VFLP::-webkit-scrollbar {\n display: none;\n}\n@media (min-width: 34rem) {\n .Table-module_container__3VFLP {\n scroll-snap-type: unset;\n }\n}\n\n.Table-module_cardButton__3aMuL div {\n background-color: #FAF8F5;\n}\n.Table-module_cardButton__3aMuL:hover div {\n border-color: transparent !important;\n outline-color: transparent !important;\n box-shadow: none !important;\n background-color: #FCF7EF !important;\n}\n.Table-module_cardButton__3aMuL:focus-visible div {\n background-color: #FCF7EF !important;\n}\n\n.Table-module_stickyHeader__2uEpP {\n display: flex;\n position: sticky;\n z-index: 9;\n}\n\n@media (max-width: 34rem) {\n .Table-module_modalContent__1PNgv {\n min-width: initial;\n }\n}";
@@ -22856,6 +22854,18 @@ var css_248z$3 = ".Collapsible-module_collapsible__2wWKs {\n display: flow-root
22856
22854
  var styles$3 = {"collapsible":"Collapsible-module_collapsible__2wWKs"};
22857
22855
  styleInject(css_248z$3);
22858
22856
 
22857
+ var measureHeight = function (element) {
22858
+ var height = 0;
22859
+ for (var _i = 0, _a = Array.from(element.children); _i < _a.length; _i++) {
22860
+ var child = _a[_i];
22861
+ var childStyles = getComputedStyle(child);
22862
+ height +=
22863
+ child.getBoundingClientRect().height +
22864
+ (parseFloat(childStyles.marginTop) || 0) +
22865
+ (parseFloat(childStyles.marginBottom) || 0);
22866
+ }
22867
+ return Math.ceil(height);
22868
+ };
22859
22869
  var Collapsible = function (_a) {
22860
22870
  var _b;
22861
22871
  var children = _a.children, isExpanded = _a.isExpanded, onTransitionEnd = _a.onTransitionEnd;
@@ -22864,24 +22874,23 @@ var Collapsible = function (_a) {
22864
22874
  var containerRef = React.useRef(null);
22865
22875
  React.useEffect(function () {
22866
22876
  if (!observerRef.current) {
22867
- observerRef.current = new ResizeObserver(function (entries) {
22868
- entries.forEach(function (entry) {
22869
- var scrollheight = entry.target.scrollHeight;
22870
- setHeight(scrollheight);
22871
- });
22877
+ observerRef.current = new ResizeObserver(function () {
22878
+ if (containerRef.current) {
22879
+ setHeight(measureHeight(containerRef.current));
22880
+ }
22872
22881
  });
22873
22882
  }
22874
22883
  if (containerRef.current) {
22875
22884
  observerRef.current.observe(containerRef.current);
22876
- var scrollheight = containerRef.current.scrollHeight;
22877
- setHeight(scrollheight);
22885
+ Array.from(containerRef.current.children).forEach(function (child) {
22886
+ var _a;
22887
+ (_a = observerRef.current) === null || _a === void 0 ? void 0 : _a.observe(child);
22888
+ });
22889
+ setHeight(measureHeight(containerRef.current));
22878
22890
  }
22879
22891
  return function () {
22880
- var _a, _b;
22881
- if (containerRef.current) {
22882
- (_a = observerRef.current) === null || _a === void 0 ? void 0 : _a.unobserve(containerRef.current);
22883
- }
22884
- (_b = observerRef.current) === null || _b === void 0 ? void 0 : _b.disconnect();
22892
+ var _a;
22893
+ (_a = observerRef.current) === null || _a === void 0 ? void 0 : _a.disconnect();
22885
22894
  };
22886
22895
  }, [containerRef.current]);
22887
22896
  return (jsxRuntime.jsx("div", { className: classNames(styles$3.collapsible, (_b = {},