@popsure/dirty-swan 0.27.13 → 0.27.15

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 (57) hide show
  1. package/dist/index.d.ts +2 -2
  2. package/dist/index.js +5462 -5523
  3. package/dist/index.js.map +1 -1
  4. package/dist/lib/components/button/index.d.ts +1 -1
  5. package/dist/lib/components/comparisonTable/components/AccordionItem/AccordionItem.d.ts +11 -0
  6. package/dist/lib/components/comparisonTable/components/AccordionItem/index.d.ts +1 -0
  7. package/dist/lib/components/comparisonTable/components/Row/index.d.ts +1 -1
  8. package/dist/lib/components/comparisonTable/components/TableArrows/index.d.ts +4 -2
  9. package/dist/lib/components/comparisonTable/hooks/useComparisonTable.d.ts +14 -0
  10. package/dist/lib/components/comparisonTable/index.d.ts +10 -4
  11. package/dist/lib/components/input/index.d.ts +1 -1
  12. package/dist/lib/index.d.ts +1 -4
  13. package/package.json +2 -1
  14. package/src/App.tsx +0 -8
  15. package/src/index.tsx +1 -7
  16. package/src/lib/components/cards/cardWithTopIcon/index.stories.mdx +8 -8
  17. package/src/lib/components/cards/cardWithTopIcon/index.tsx +1 -5
  18. package/src/lib/components/comparisonTable/components/AccordionItem/AccordionItem.module.scss +44 -0
  19. package/src/lib/components/comparisonTable/components/AccordionItem/AccordionItem.tsx +73 -0
  20. package/src/lib/components/comparisonTable/components/AccordionItem/index.tsx +1 -0
  21. package/src/lib/components/comparisonTable/components/Row/index.tsx +1 -3
  22. package/src/lib/components/comparisonTable/components/Row/style.module.scss +11 -2
  23. package/src/lib/components/comparisonTable/components/TableArrows/index.tsx +1 -3
  24. package/src/lib/components/comparisonTable/components/TableArrows/style.module.scss +1 -1
  25. package/src/lib/components/comparisonTable/hooks/useComparisonTable.ts +124 -0
  26. package/src/lib/components/comparisonTable/index.stories.mdx +226 -8
  27. package/src/lib/components/comparisonTable/index.tsx +172 -123
  28. package/src/lib/components/comparisonTable/style.module.scss +16 -6
  29. package/src/lib/components/dateSelector/datepicker.scss +2 -8
  30. package/src/lib/components/dateSelector/index.tsx +2 -0
  31. package/src/lib/index.tsx +0 -5
  32. package/dist/lib/components/comparisonTable/hooks/useActiveTableArrows.d.ts +0 -10
  33. package/dist/lib/components/downloadRing/icons/check-outside-circle.d.ts +0 -3
  34. package/dist/lib/components/downloadRing/icons/download-cloud.d.ts +0 -3
  35. package/dist/lib/components/downloadRing/index.d.ts +0 -8
  36. package/dist/lib/components/dropzone/images/error.d.ts +0 -3
  37. package/dist/lib/components/dropzone/images/file.d.ts +0 -3
  38. package/dist/lib/components/dropzone/images/upload-complete.d.ts +0 -3
  39. package/dist/lib/components/dropzone/images/upload.d.ts +0 -3
  40. package/dist/lib/components/dropzone/index.d.ts +0 -11
  41. package/dist/lib/models/downloadRing/index.d.ts +0 -1
  42. package/src/lib/components/comparisonTable/hooks/useActiveTableArrows.ts +0 -63
  43. package/src/lib/components/downloadRing/icons/check-outside-circle.tsx +0 -26
  44. package/src/lib/components/downloadRing/icons/download-cloud.tsx +0 -18
  45. package/src/lib/components/downloadRing/icons/style.module.scss +0 -7
  46. package/src/lib/components/downloadRing/index.stories.mdx +0 -35
  47. package/src/lib/components/downloadRing/index.tsx +0 -79
  48. package/src/lib/components/downloadRing/style.module.scss +0 -66
  49. package/src/lib/components/dropzone/images/error.tsx +0 -18
  50. package/src/lib/components/dropzone/images/file.tsx +0 -26
  51. package/src/lib/components/dropzone/images/style.module.scss +0 -7
  52. package/src/lib/components/dropzone/images/upload-complete.tsx +0 -24
  53. package/src/lib/components/dropzone/images/upload.tsx +0 -18
  54. package/src/lib/components/dropzone/index.stories.mdx +0 -44
  55. package/src/lib/components/dropzone/index.tsx +0 -152
  56. package/src/lib/components/dropzone/style.module.scss +0 -90
  57. package/src/lib/models/downloadRing/index.ts +0 -6
@@ -9,5 +9,5 @@ declare const _default: React.ForwardRefExoticComponent<Pick<{
9
9
  buttonType?: ButtonType | undefined;
10
10
  leftIcon?: Icon | undefined;
11
11
  loading?: boolean | undefined;
12
- } & Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "children">, "hidden" | "title" | "className" | "form" | "slot" | "style" | "value" | "onChange" | "dir" | "onBlur" | "onFocus" | "onKeyDown" | "tabIndex" | "onDragEnter" | "onDragOver" | "onDragLeave" | "leftIcon" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeaveCapture" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "disabled" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "type" | "loading" | "buttonTitle" | "buttonType"> & React.RefAttributes<HTMLButtonElement>>;
12
+ } & Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "children">, "className" | "form" | "slot" | "style" | "title" | "onClick" | "hidden" | "value" | "onChange" | "dir" | "onBlur" | "onFocus" | "onKeyDown" | "tabIndex" | "leftIcon" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "disabled" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "type" | "loading" | "buttonTitle" | "buttonType"> & React.RefAttributes<HTMLButtonElement>>;
13
13
  export default _default;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ export declare const AccordionItem: ({ children, className, headerClassName, iconSrc, isOpen, onOpen, onClose, title, }: {
3
+ children: React.ReactNode | string;
4
+ className?: string | undefined;
5
+ headerClassName?: string | undefined;
6
+ iconSrc?: string | undefined;
7
+ isOpen: boolean;
8
+ onOpen: () => void;
9
+ onClose: () => void;
10
+ title: string;
11
+ }) => JSX.Element;
@@ -0,0 +1 @@
1
+ export { AccordionItem } from './AccordionItem';
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { Cell } from '../../index';
2
+ import type { Cell } from '../../index';
3
3
  interface RowProps<T> {
4
4
  cell: Cell<T>;
5
5
  data: Array<T>;
@@ -1,9 +1,11 @@
1
1
  /// <reference types="react" />
2
- import { ActiveTableArrows } from '../../hooks/useActiveTableArrows';
3
2
  export declare type ArrowValues = 'prev' | 'next';
4
3
  interface TableArrowsProps {
5
4
  onClick: (value: ArrowValues) => void;
6
- active: ActiveTableArrows;
5
+ active: {
6
+ left: boolean;
7
+ right: boolean;
8
+ };
7
9
  }
8
10
  declare const TableArrows: (props: TableArrowsProps) => JSX.Element;
9
11
  export default TableArrows;
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import { ArrowValues } from '../components/TableArrows';
3
+ export declare const useComparisonTable: () => {
4
+ headerWidth: number;
5
+ contentContainerRef: import("react").MutableRefObject<HTMLDivElement | null>;
6
+ selectedSection: string;
7
+ setSelectedSection: import("react").Dispatch<import("react").SetStateAction<string>>;
8
+ selectedTabIndex: number;
9
+ setSelectedTabIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
10
+ scrollContainerCallbackRef: (node: any) => void;
11
+ handleArrowsClick: (value: ArrowValues) => void;
12
+ toggleMoreRows: () => Promise<void>;
13
+ showMore: boolean;
14
+ };
@@ -1,8 +1,8 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
+ import TableInfoButton from './components/TableInfoButton';
2
3
  import TableRating from './components/TableRating';
3
- import TableTrueFalse from './components/TableTrueFalse';
4
4
  import TableRowHeader from './components/TableRowHeader';
5
- import TableInfoButton from './components/TableInfoButton';
5
+ import TableTrueFalse from './components/TableTrueFalse';
6
6
  export interface CellBaseProps<T> {
7
7
  /** Used to display the row's title */
8
8
  label?: React.ReactNode;
@@ -34,6 +34,12 @@ export interface ComparisonTableProps<T> {
34
34
  headers: Array<TableHeader<T>>;
35
35
  data: Array<T>;
36
36
  hideDetails?: boolean;
37
+ hideScrollBars?: boolean;
38
+ collapsibleSections?: boolean;
39
+ cellWidth?: number;
40
+ firstColumnWidth?: number;
41
+ stickyHeaderTopOffset?: number;
42
+ growContent?: boolean;
37
43
  styles?: {
38
44
  header?: string;
39
45
  container?: string;
@@ -42,4 +48,4 @@ export interface ComparisonTableProps<T> {
42
48
  declare const ComparisonTable: <T extends {
43
49
  id: number;
44
50
  }>(props: ComparisonTableProps<T>) => JSX.Element;
45
- export { ComparisonTable, TableRating, TableTrueFalse, TableRowHeader, TableInfoButton, };
51
+ export { ComparisonTable, TableInfoButton, TableRating, TableRowHeader, TableTrueFalse, };
@@ -6,5 +6,5 @@ export declare type InputProps = {
6
6
  declare const _default: React.ForwardRefExoticComponent<Pick<{
7
7
  error?: string | undefined;
8
8
  prefix?: string | undefined;
9
- } & Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "enterKeyHint"> & Partial<Pick<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "enterKeyHint">>, "error" | "hidden" | "title" | "children" | "className" | "form" | "slot" | "style" | "pattern" | "value" | "onChange" | "dir" | "onBlur" | "onFocus" | "onKeyDown" | "tabIndex" | "multiple" | "onDragEnter" | "onDragOver" | "onDragLeave" | "list" | "step" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeaveCapture" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "disabled" | "enterKeyHint" | "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "max" | "maxLength" | "min" | "minLength" | "name" | "readOnly" | "required" | "size" | "src" | "type" | "width"> & React.RefAttributes<HTMLInputElement>>;
9
+ } & Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "enterKeyHint"> & Partial<Pick<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "enterKeyHint">>, "className" | "form" | "slot" | "style" | "title" | "pattern" | "children" | "onClick" | "error" | "hidden" | "value" | "onChange" | "dir" | "onBlur" | "onFocus" | "onKeyDown" | "tabIndex" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "list" | "step" | "disabled" | "enterKeyHint" | "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "max" | "maxLength" | "min" | "minLength" | "multiple" | "name" | "readOnly" | "required" | "size" | "src" | "type" | "width"> & React.RefAttributes<HTMLInputElement>>;
10
10
  export default _default;
@@ -1,10 +1,8 @@
1
1
  import DateSelector from './components/dateSelector';
2
- import Dropzone from './components/dropzone';
3
2
  import SignaturePad from './components/signaturePad';
4
3
  import AutocompleteAddress from './components/autocompleteAddress';
5
4
  import Input from './components/input';
6
5
  import MultiDropzone from './components/multiDropzone';
7
- import DownloadRing from './components/downloadRing';
8
6
  import DownloadButton from './components/downloadButton';
9
7
  import IbanInput from './components/input/iban';
10
8
  import CurrencyInput from './components/input/currency';
@@ -17,7 +15,6 @@ import AutoSuggestInput from './components/input/autoSuggestInput';
17
15
  import { ComparisonTable, TableRating, TableTrueFalse, TableRowHeader, TableInfoButton, TableHeader } from './components/comparisonTable';
18
16
  import SegmentedControl from './components/segmentedControl';
19
17
  import Markdown from './components/markdown';
20
- export { DateSelector, Dropzone, SignaturePad, AutocompleteAddress, Input, MultiDropzone, DownloadRing, DownloadButton, IbanInput, BottomModal, RegularModal, BottomOrRegularModal, CardWithTopLeftIcon, CardWithLeftIcon, CardWithTopIcon, InfoCard, CardButton, Button, CurrencyInput, AutoSuggestMultiSelect, Chip, AutoSuggestInput, ComparisonTable, TableRating, TableTrueFalse, TableRowHeader, TableInfoButton, SegmentedControl, Markdown, };
18
+ export { DateSelector, SignaturePad, AutocompleteAddress, Input, MultiDropzone, DownloadButton, IbanInput, BottomModal, RegularModal, BottomOrRegularModal, CardWithTopLeftIcon, CardWithLeftIcon, CardWithTopIcon, InfoCard, CardButton, Button, CurrencyInput, AutoSuggestMultiSelect, Chip, AutoSuggestInput, ComparisonTable, TableRating, TableTrueFalse, TableRowHeader, TableInfoButton, SegmentedControl, Markdown, };
21
19
  export type { TableHeader };
22
- export type { DownloadRingDownloadStatus } from './models/downloadRing';
23
20
  export type { DownloadStatus } from './models/download';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popsure/dirty-swan",
3
- "version": "0.27.13",
3
+ "version": "0.27.15",
4
4
  "author": "Vincent Audoire <vincent@getpopsure.com>",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -95,6 +95,7 @@
95
95
  "babel-runtime": "^6.26.0",
96
96
  "cross-env": "^7.0.3",
97
97
  "postcss": "^8.3.5",
98
+ "postcss-custom-properties": "^12.1.10",
98
99
  "prettier": "^2.3.1",
99
100
  "react": "^17.0.2",
100
101
  "react-dom": "^17.0.2",
package/src/App.tsx CHANGED
@@ -2,10 +2,8 @@ import React from 'react';
2
2
  import './lib/scss/index.scss';
3
3
 
4
4
  import DateSelector from './lib/components/dateSelector';
5
- import Dropzone from './lib/components/dropzone';
6
5
  import SignaturePad from './lib/components/signaturePad';
7
6
  import { CardWithLeftIcon } from './lib/components/cards';
8
- import AutocompleteAddress from './lib/components/autocompleteAddress';
9
7
 
10
8
  function App() {
11
9
  return (
@@ -20,12 +18,6 @@ function App() {
20
18
  malesuada laoreet nulla, non maximus ante porta sit amet. Aenean non
21
19
  ipsum nec quam gravida convallis vitae sit amet nisi.
22
20
  </div>
23
- <Dropzone
24
- uploading={true}
25
- progress={32}
26
- onSelectedFile={() => {}}
27
- // uploadedFileUrl="http://foo.com/my-file.png"
28
- />
29
21
  <div style={{ backgroundColor: 'white', padding: '24px' }}>
30
22
  <SignaturePad
31
23
  onChange={(v) => {
package/src/index.tsx CHANGED
@@ -3,12 +3,10 @@ import App from './App';
3
3
 
4
4
  export {
5
5
  DateSelector,
6
- Dropzone,
7
6
  SignaturePad,
8
7
  AutocompleteAddress,
9
8
  Input,
10
9
  MultiDropzone,
11
- DownloadRing,
12
10
  IbanInput,
13
11
  CurrencyInput,
14
12
  BottomModal,
@@ -33,10 +31,6 @@ export {
33
31
  Markdown,
34
32
  } from './lib';
35
33
 
36
- export type {
37
- TableHeader,
38
- DownloadRingDownloadStatus,
39
- DownloadStatus,
40
- } from './lib';
34
+ export type { TableHeader, DownloadStatus } from './lib';
41
35
 
42
36
  ReactDOM.render(<App />, document.getElementById('root'));
@@ -7,14 +7,14 @@ import { featherLogo } from '../icons';
7
7
 
8
8
  # Card with top icon
9
9
 
10
- | attribute | unit | description | default value | required |
11
- | ---------- | ------------------------------------------------------------------------------------ | ------------------------------------------------ | ------------- | -------- |
12
- | title | string | The title text that needs to be displayed | n/a | true |
13
- | cardSize | [Card Size (s,m,b)](?path=/story/jsx-cards-intro--page#card-size-xsmall-small-medium-big) | Size of the card | medium | false |
14
- | topIcon | [Icon](?path=/story/jsx-cards-intro--page#icon) | Icon displayed on the top of the card | n/a | true |
15
- | rightIcon | [Icon](?path=/story/jsx-cards-intro--page#icon) | Icon displayed on the right of the title | n/a | false |
16
- | state | [Card State](?path=/story/jsx-cards-intro--page#card-state) | State that describe the interation with the card | actionable | false |
17
- | dropshadow | boolean | If the card should have a box-shadow or not | true | false |
10
+ | attribute | unit | description | default value | required |
11
+ | ---------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------ | ------------- | -------- |
12
+ | title | string | The title text that needs to be displayed | n/a | true |
13
+ | cardSize | [Card Size (s,m,b)](?path=/story/jsx-cards-intro--page#card-size-xsmall-small-medium-big) | Size of the card | medium | false |
14
+ | topIcon | [Icon](?path=/story/jsx-cards-intro--page#icon) | Icon displayed on the top of the card | n/a | true |
15
+ | rightIcon | [Icon](?path=/story/jsx-cards-intro--page#icon) | Icon displayed on the right of the title | n/a | false |
16
+ | state | [Card State](?path=/story/jsx-cards-intro--page#card-state) | State that describe the interation with the card | actionable | false |
17
+ | dropshadow | boolean | If the card should have a box-shadow or not | true | false |
18
18
 
19
19
  <Preview>
20
20
  <>
@@ -1,8 +1,4 @@
1
- import {
2
- associatedClassForCardState,
3
- CardProps,
4
- headingForCardSize,
5
- } from '..';
1
+ import { associatedClassForCardState, CardProps, headingForCardSize } from '..';
6
2
  import { Icon, arrowRight, IconSize } from '../icons';
7
3
 
8
4
  import styles from './style.module.scss';
@@ -0,0 +1,44 @@
1
+ @import '../../../../scss/public/colors';
2
+
3
+ .container {
4
+ width: var(--growContent, min-content);
5
+ margin: 0 auto;
6
+ }
7
+
8
+ .container + .container {
9
+ margin-top: 8px;
10
+ }
11
+
12
+ .chevron {
13
+ transition: filter 0.3s ease-in-out, transform 0.2s ease-in-out;
14
+ }
15
+
16
+ .chevronClosed {
17
+ transform: rotate(180deg);
18
+ }
19
+
20
+ .iconAndTextContainer {
21
+ column-gap: 12px;
22
+ }
23
+
24
+ .headerButton {
25
+ border: none;
26
+ background: $ds-grey-100;
27
+ column-gap: 16px;
28
+ cursor: pointer;
29
+ font-family: inherit;
30
+ outline: none;
31
+ position: relative;
32
+ text-align: inherit;
33
+ transition: background-color 0.3s ease-in-out, transform 0.2s ease-in-out;
34
+
35
+ &:hover {
36
+ background: $ds-primary-100;
37
+ }
38
+ }
39
+
40
+ .headerButton:hover {
41
+ .chevron {
42
+ filter: brightness(0.425);
43
+ }
44
+ }
@@ -0,0 +1,73 @@
1
+ import AnimateHeight from 'react-animate-height';
2
+
3
+ import styles from './AccordionItem.module.scss';
4
+
5
+ const ChevronSVG = ({ className }: { className?: string }) => (
6
+ <svg
7
+ width="24"
8
+ height="24"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ xmlns="http://www.w3.org/2000/svg"
12
+ className={className}
13
+ >
14
+ <path
15
+ d="M18 15L12 9L6 15"
16
+ stroke="#b4b4ba"
17
+ strokeWidth="2"
18
+ strokeLinecap="round"
19
+ strokeLinejoin="round"
20
+ />
21
+ </svg>
22
+ );
23
+
24
+ export const AccordionItem = ({
25
+ children,
26
+ className = '',
27
+ headerClassName = '',
28
+ iconSrc = '',
29
+ isOpen,
30
+ onOpen,
31
+ onClose,
32
+ title,
33
+ }: {
34
+ children: React.ReactNode | string;
35
+ className?: string;
36
+ headerClassName?: string;
37
+ iconSrc?: string;
38
+ isOpen: boolean;
39
+ onOpen: () => void;
40
+ onClose: () => void;
41
+ title: string;
42
+ }) => {
43
+ const handleClick = () => {
44
+ if (!isOpen) {
45
+ onOpen();
46
+ } else {
47
+ onClose();
48
+ }
49
+ };
50
+
51
+ return (
52
+ <div className={`d-flex fd-column ${className} ${styles.container}`}>
53
+ <button
54
+ className={`d-flex ai-center jc-between ${styles.headerButton} ${headerClassName}`}
55
+ onClick={handleClick}
56
+ type="button"
57
+ >
58
+ <div className={`d-flex ai-center ${styles.iconAndTextContainer}`}>
59
+ {!!iconSrc && <img src={iconSrc} alt={`${title} icon`} />}
60
+ <h4 className="p-h4">{title}</h4>
61
+ </div>
62
+ <ChevronSVG
63
+ className={`${styles.chevron} ${!isOpen && styles.chevronClosed}`}
64
+ />
65
+ </button>
66
+ {/* Min height is 0.1 so that the scroll position is correctly synced across accordion items but is not actually shown.
67
+ If set to 0, react-animate-height will set display to "none" which means scrolling is not synced. */}
68
+ <AnimateHeight duration={300} height={isOpen ? 'auto' : 0.1}>
69
+ {children}
70
+ </AnimateHeight>
71
+ </div>
72
+ );
73
+ };
@@ -0,0 +1 @@
1
+ export { AccordionItem } from './AccordionItem';
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { Cell } from '../../index';
4
-
3
+ import type { Cell } from '../../index';
5
4
  import styles from './style.module.scss';
6
5
 
7
6
  interface RowProps<T> {
@@ -25,7 +24,6 @@ const Row = <T extends { id: number }>(props: RowProps<T>) => {
25
24
  >
26
25
  <h4
27
26
  className={`
28
- wmx4
29
27
  ${styles.cell}
30
28
  ${styles.sticky}
31
29
  ${isRowHeader ? `p-h2 p--serif ${styles.title}` : ''}
@@ -1,13 +1,14 @@
1
1
  @use "../../../../scss/public/colors" as *;
2
2
  @use "../../../../scss/public/grid" as *;
3
3
 
4
- $cell-min-width: 256px;
4
+ $cell-min-width: var(--cellWidth, 256px);
5
5
 
6
6
  .header {
7
7
  position: relative;
8
8
 
9
9
  & > div {
10
- width: 100vw;
10
+ width: var(--tableWidth);
11
+ max-width: var(--tableWidth);
11
12
 
12
13
  &:nth-child(n + 3) {
13
14
  margin: 0;
@@ -34,6 +35,7 @@ $cell-min-width: 256px;
34
35
  color: $ds-grey-700;
35
36
 
36
37
  width: 50vw;
38
+ max-width: calc(var(--tableWidth) / 2);
37
39
 
38
40
  &:first-child {
39
41
  background-color: white;
@@ -60,6 +62,13 @@ $cell-min-width: 256px;
60
62
  }
61
63
  }
62
64
 
65
+ h4.cell {
66
+ // Set the max width of the first column to the supplied firstColumnWidth (or 288px if not specified) but only
67
+ // if this value does not exceed half of the table's width.
68
+ // This is to ensure that the first column is at most as wide as half the table, which will be the case on mobile where only the first column and one other are shown.
69
+ max-width: min(var(--firstColumnWidth, 288px), calc(var(--tableWidth) / 2));
70
+ }
71
+
63
72
  .title {
64
73
  position: relative;
65
74
  color: $ds-grey-900;
@@ -2,15 +2,13 @@ import React from 'react';
2
2
  import classNames from 'classnames';
3
3
 
4
4
  import ArrowIcon from './Arrow';
5
- import { ActiveTableArrows } from '../../hooks/useActiveTableArrows';
6
-
7
5
  import styles from './style.module.scss';
8
6
 
9
7
  export type ArrowValues = 'prev' | 'next';
10
8
 
11
9
  interface TableArrowsProps {
12
10
  onClick: (value: ArrowValues) => void;
13
- active: ActiveTableArrows;
11
+ active: { left: boolean; right: boolean };
14
12
  }
15
13
 
16
14
  const TableArrows = (props: TableArrowsProps) => {
@@ -3,7 +3,7 @@
3
3
 
4
4
  .container {
5
5
  position: absolute;
6
- width: 100vw;
6
+ width: 100%;
7
7
  padding: 0 16px;
8
8
  justify-content: space-between;
9
9
  z-index: 1;
@@ -0,0 +1,124 @@
1
+ import debounce from 'lodash.debounce';
2
+ import { useCallback, useEffect, useRef, useState } from 'react';
3
+
4
+ import { ArrowValues } from '../components/TableArrows';
5
+
6
+ export const useComparisonTable = () => {
7
+ const [showMore, setShowMore] = useState<boolean>(false);
8
+ const [headerWidth, setHeaderWidth] = useState(0);
9
+
10
+ const [selectedTabIndex, setSelectedTabIndex] = useState(0);
11
+
12
+ const [selectedSection, setSelectedSection] = useState('');
13
+
14
+ const headerRef = useRef<HTMLDivElement | null>(null);
15
+ const contentContainerRef = useRef<HTMLDivElement | null>(null);
16
+ const observerRef = useRef<ResizeObserver | null>(null);
17
+
18
+ const scrollContainerCallbackRef = useCallback((node) => {
19
+ if (node) {
20
+ setHeaderWidth(node.clientWidth);
21
+ }
22
+
23
+ headerRef.current = node;
24
+ }, []);
25
+
26
+ useEffect(() => {
27
+ if (!observerRef.current) {
28
+ observerRef.current = new ResizeObserver((entries) => {
29
+ entries.forEach((entry) => {
30
+ const currentTabIndex = Math.round(
31
+ entry.target.scrollLeft / entry.contentRect.width
32
+ );
33
+
34
+ setHeaderWidth(entry.contentRect.width);
35
+
36
+ // Update selectedTabIndex to match the calculated current tab index
37
+ setSelectedTabIndex(currentTabIndex);
38
+ });
39
+ });
40
+ }
41
+
42
+ if (headerRef.current) {
43
+ observerRef.current.observe(headerRef.current);
44
+ }
45
+
46
+ return () => {
47
+ if (headerRef.current) {
48
+ observerRef.current?.unobserve(headerRef.current);
49
+ }
50
+ observerRef.current?.disconnect();
51
+ };
52
+ }, []);
53
+
54
+ const handleTableScroll = () => {
55
+ if (!headerRef.current) {
56
+ return;
57
+ }
58
+
59
+ const currentTabIndex = Math.round(
60
+ headerRef.current.scrollLeft /
61
+ headerRef.current.getBoundingClientRect().width
62
+ );
63
+
64
+ setSelectedTabIndex(currentTabIndex);
65
+ };
66
+
67
+ const debouncedTableScroll = debounce(handleTableScroll, 150);
68
+
69
+ useEffect(() => {
70
+ headerRef.current?.addEventListener('scroll', debouncedTableScroll, {
71
+ passive: true,
72
+ });
73
+
74
+ return headerRef.current?.removeEventListener('scroll', handleTableScroll);
75
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
76
+
77
+ const handleArrowsClick = (value: ArrowValues) => {
78
+ if (headerRef.current) {
79
+ const currentTabIndex = Math.round(
80
+ headerRef.current.scrollLeft / headerRef.current.clientWidth
81
+ );
82
+
83
+ const direction = value === 'next' ? 1 : -1;
84
+
85
+ const newTabIndex = currentTabIndex + direction;
86
+
87
+ headerRef.current.scroll({
88
+ top: 0,
89
+ left: headerWidth * newTabIndex,
90
+ behavior: 'smooth',
91
+ });
92
+
93
+ setSelectedTabIndex(() => {
94
+ return newTabIndex;
95
+ });
96
+ }
97
+ };
98
+
99
+ const toggleMoreRows = async () => {
100
+ if (showMore && headerRef.current && contentContainerRef.current) {
101
+ window.scroll(
102
+ 0,
103
+ window.scrollY +
104
+ (contentContainerRef.current.getBoundingClientRect().y -
105
+ headerRef.current.getBoundingClientRect().bottom)
106
+ );
107
+ }
108
+
109
+ setShowMore(!showMore);
110
+ };
111
+
112
+ return {
113
+ headerWidth,
114
+ contentContainerRef,
115
+ selectedSection,
116
+ setSelectedSection,
117
+ selectedTabIndex,
118
+ setSelectedTabIndex,
119
+ scrollContainerCallbackRef,
120
+ handleArrowsClick,
121
+ toggleMoreRows,
122
+ showMore,
123
+ };
124
+ };