@popsure/dirty-swan 0.27.14 → 0.27.16
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.js +293 -227
- package/dist/index.js.map +1 -1
- package/dist/lib/components/button/index.d.ts +1 -1
- package/dist/lib/components/comparisonTable/components/AccordionItem/AccordionItem.d.ts +10 -0
- package/dist/lib/components/comparisonTable/components/AccordionItem/index.d.ts +1 -0
- package/dist/lib/components/comparisonTable/components/Row/index.d.ts +1 -1
- package/dist/lib/components/comparisonTable/components/TableArrows/index.d.ts +4 -2
- package/dist/lib/components/comparisonTable/hooks/useComparisonTable.d.ts +14 -0
- package/dist/lib/components/comparisonTable/index.d.ts +10 -4
- package/dist/lib/components/input/index.d.ts +1 -1
- package/package.json +2 -1
- package/src/lib/components/comparisonTable/components/AccordionItem/AccordionItem.module.scss +44 -0
- package/src/lib/components/comparisonTable/components/AccordionItem/AccordionItem.tsx +74 -0
- package/src/lib/components/comparisonTable/components/AccordionItem/index.tsx +1 -0
- package/src/lib/components/comparisonTable/components/Row/index.tsx +1 -3
- package/src/lib/components/comparisonTable/components/Row/style.module.scss +11 -2
- package/src/lib/components/comparisonTable/components/TableArrows/index.tsx +1 -3
- package/src/lib/components/comparisonTable/components/TableArrows/style.module.scss +1 -1
- package/src/lib/components/comparisonTable/hooks/useComparisonTable.ts +124 -0
- package/src/lib/components/comparisonTable/index.stories.mdx +226 -8
- package/src/lib/components/comparisonTable/index.tsx +172 -123
- package/src/lib/components/comparisonTable/style.module.scss +16 -6
- package/src/lib/components/dateSelector/datepicker.scss +2 -8
- package/src/lib/components/dateSelector/index.tsx +2 -0
- package/dist/lib/components/comparisonTable/hooks/useActiveTableArrows.d.ts +0 -10
- package/src/lib/components/comparisonTable/hooks/useActiveTableArrows.ts +0 -63
|
@@ -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">, "
|
|
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,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const AccordionItem: ({ children, className, headerClassName, isOpen, onOpen, onClose, label, }: {
|
|
3
|
+
children: React.ReactNode | string;
|
|
4
|
+
className?: string | undefined;
|
|
5
|
+
headerClassName?: string | undefined;
|
|
6
|
+
isOpen: boolean;
|
|
7
|
+
onOpen: () => void;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
label: React.ReactNode;
|
|
10
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AccordionItem } from './AccordionItem';
|
|
@@ -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:
|
|
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
|
-
|
|
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
|
|
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,
|
|
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">>, "
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@popsure/dirty-swan",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.16",
|
|
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",
|
|
@@ -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,74 @@
|
|
|
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
|
+
isOpen,
|
|
29
|
+
onOpen,
|
|
30
|
+
onClose,
|
|
31
|
+
label,
|
|
32
|
+
}: {
|
|
33
|
+
children: React.ReactNode | string;
|
|
34
|
+
className?: string;
|
|
35
|
+
headerClassName?: string;
|
|
36
|
+
isOpen: boolean;
|
|
37
|
+
onOpen: () => void;
|
|
38
|
+
onClose: () => void;
|
|
39
|
+
label: React.ReactNode;
|
|
40
|
+
}) => {
|
|
41
|
+
const handleClick = () => {
|
|
42
|
+
if (!isOpen) {
|
|
43
|
+
onOpen();
|
|
44
|
+
} else {
|
|
45
|
+
onClose();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div className={`d-flex fd-column ${className} ${styles.container}`}>
|
|
51
|
+
<button
|
|
52
|
+
className={`d-flex ai-center jc-between ${styles.headerButton} ${headerClassName}`}
|
|
53
|
+
onClick={handleClick}
|
|
54
|
+
type="button"
|
|
55
|
+
>
|
|
56
|
+
<div className={`d-flex ai-center ${styles.iconAndTextContainer}`}>
|
|
57
|
+
{typeof label === 'string' ? (
|
|
58
|
+
<h4 className="p-h4">{label}</h4>
|
|
59
|
+
) : (
|
|
60
|
+
<>{label}</>
|
|
61
|
+
)}
|
|
62
|
+
</div>
|
|
63
|
+
<ChevronSVG
|
|
64
|
+
className={`${styles.chevron} ${!isOpen && styles.chevronClosed}`}
|
|
65
|
+
/>
|
|
66
|
+
</button>
|
|
67
|
+
{/* Min height is 0.1 so that the scroll position is correctly synced across accordion items but is not actually shown.
|
|
68
|
+
If set to 0, react-animate-height will set display to "none" which means scrolling is not synced. */}
|
|
69
|
+
<AnimateHeight duration={300} height={isOpen ? 'auto' : 0.1}>
|
|
70
|
+
{children}
|
|
71
|
+
</AnimateHeight>
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
@@ -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:
|
|
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:
|
|
11
|
+
active: { left: boolean; right: boolean };
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
const TableArrows = (props: TableArrowsProps) => {
|
|
@@ -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
|
+
};
|