@popsure/dirty-swan 0.57.8 → 0.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +98 -63
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/input/checkbox/index.d.ts +2 -1
- package/dist/cjs/lib/components/input/checkbox/index.stories.d.ts +11 -7
- package/dist/cjs/lib/components/input/radio/index.d.ts +3 -1
- package/dist/cjs/lib/components/input/radio/index.stories.d.ts +10 -2
- package/dist/cjs/lib/components/multiDropzone/utils/index.d.ts +9 -2
- package/dist/esm/{TableSection-a26ba0c5.js → TableSection-ebace923.js} +1 -1
- package/dist/esm/{TableSection-a26ba0c5.js.map → TableSection-ebace923.js.map} +1 -1
- package/dist/esm/components/chip/index.js +2 -2
- package/dist/esm/components/chip/index.js.map +1 -1
- package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js +1 -1
- package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js.map +1 -1
- package/dist/esm/components/input/checkbox/index.js +19 -16
- package/dist/esm/components/input/checkbox/index.js.map +1 -1
- package/dist/esm/components/input/checkbox/index.stories.js +24 -20
- package/dist/esm/components/input/checkbox/index.stories.js.map +1 -1
- package/dist/esm/components/input/index.js +1 -1
- package/dist/esm/components/input/index.js.map +1 -1
- package/dist/esm/components/input/radio/index.js +23 -21
- package/dist/esm/components/input/radio/index.js.map +1 -1
- package/dist/esm/components/input/radio/index.stories.js +12 -3
- package/dist/esm/components/input/radio/index.stories.js.map +1 -1
- package/dist/esm/components/input/radio/index.test.js +1 -0
- package/dist/esm/components/input/radio/index.test.js.map +1 -1
- package/dist/esm/components/multiDropzone/UploadFileCell/index.js +6 -7
- package/dist/esm/components/multiDropzone/UploadFileCell/index.js.map +1 -1
- package/dist/esm/components/multiDropzone/index.js +51 -17
- package/dist/esm/components/multiDropzone/index.js.map +1 -1
- package/dist/esm/components/multiDropzone/index.stories.js +1 -0
- package/dist/esm/components/multiDropzone/index.stories.js.map +1 -1
- package/dist/esm/components/multiDropzone/index.test.js +1 -0
- package/dist/esm/components/multiDropzone/index.test.js.map +1 -1
- package/dist/esm/components/table/Table.js +1 -1
- package/dist/esm/components/table/Table.stories.js +1 -1
- package/dist/esm/components/table/Table.test.js +1 -1
- package/dist/esm/components/table/components/TableContents/TableContents.js +1 -1
- package/dist/esm/components/table/components/TableContents/TableContents.test.js +1 -1
- package/dist/esm/components/table/components/TableSection/TableSection.js +1 -1
- package/dist/esm/components/table/components/TableSection/TableSection.test.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/lib/components/input/checkbox/index.d.ts +2 -1
- package/dist/esm/lib/components/input/checkbox/index.stories.d.ts +11 -7
- package/dist/esm/lib/components/input/radio/index.d.ts +3 -1
- package/dist/esm/lib/components/input/radio/index.stories.d.ts +10 -2
- package/dist/esm/lib/components/multiDropzone/utils/index.d.ts +9 -2
- package/package.json +1 -1
- package/src/lib/components/chip/index.tsx +1 -0
- package/src/lib/components/chip/style.module.scss +5 -0
- package/src/lib/components/comparisonTable/components/TableInfoButton/index.tsx +2 -0
- package/src/lib/components/input/checkbox/index.stories.tsx +81 -58
- package/src/lib/components/input/checkbox/index.tsx +11 -2
- package/src/lib/components/input/checkbox/styles.module.scss +4 -0
- package/src/lib/components/input/index.tsx +2 -0
- package/src/lib/components/input/radio/index.stories.tsx +17 -2
- package/src/lib/components/input/radio/index.tsx +11 -2
- package/src/lib/components/input/radio/styles.module.scss +5 -1
- package/src/lib/components/multiDropzone/UploadFileCell/index.tsx +25 -19
- package/src/lib/components/multiDropzone/UploadFileCell/style.module.scss +11 -29
- package/src/lib/components/multiDropzone/index.tsx +17 -5
- package/src/lib/components/multiDropzone/style.module.scss +12 -9
- package/src/lib/components/multiDropzone/utils/index.test.ts +128 -45
- package/src/lib/components/multiDropzone/utils/index.ts +89 -36
|
@@ -16,5 +16,6 @@ export interface CheckboxProps<ValueType extends string> {
|
|
|
16
16
|
label?: string;
|
|
17
17
|
option?: string;
|
|
18
18
|
};
|
|
19
|
+
fieldLegend?: string;
|
|
19
20
|
}
|
|
20
|
-
export declare const Checkbox: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, bordered, classNames: classNamesObj, }: CheckboxProps<ValueType> & {}) => JSX.Element;
|
|
21
|
+
export declare const Checkbox: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, bordered, classNames: classNamesObj, fieldLegend, }: CheckboxProps<ValueType> & {}) => JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CheckboxProps } from '.';
|
|
2
2
|
declare const story: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, bordered, classNames: classNamesObj, }: CheckboxProps<ValueType>) => JSX.Element;
|
|
4
|
+
component: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, bordered, classNames: classNamesObj, fieldLegend, }: CheckboxProps<ValueType>) => JSX.Element;
|
|
5
5
|
argTypes: {
|
|
6
6
|
options: {
|
|
7
7
|
description: string;
|
|
@@ -9,6 +9,9 @@ declare const story: {
|
|
|
9
9
|
value: {
|
|
10
10
|
description: string;
|
|
11
11
|
};
|
|
12
|
+
fieldLegend: {
|
|
13
|
+
description: string;
|
|
14
|
+
};
|
|
12
15
|
onChange: {
|
|
13
16
|
description: string;
|
|
14
17
|
action: boolean;
|
|
@@ -46,6 +49,7 @@ declare const story: {
|
|
|
46
49
|
description: string;
|
|
47
50
|
};
|
|
48
51
|
};
|
|
52
|
+
fieldLegend: string;
|
|
49
53
|
wide: boolean;
|
|
50
54
|
bordered: boolean;
|
|
51
55
|
inlineLayout: boolean;
|
|
@@ -59,12 +63,12 @@ declare const story: {
|
|
|
59
63
|
};
|
|
60
64
|
};
|
|
61
65
|
export declare const CheckboxStory: {
|
|
62
|
-
({ onChange, options, wide, bordered, classNames, inlineLayout, }: CheckboxProps<string>): JSX.Element;
|
|
66
|
+
({ onChange, options, wide, bordered, classNames, inlineLayout, fieldLegend, }: CheckboxProps<string>): JSX.Element;
|
|
63
67
|
storyName: string;
|
|
64
68
|
};
|
|
65
|
-
export declare const CheckboxWithCustomWrapperStyles: ({ onChange }: CheckboxProps<string>) => JSX.Element;
|
|
66
|
-
export declare const CheckboxWithCustomOptionStyles: ({ onChange }: CheckboxProps<string>) => JSX.Element;
|
|
67
|
-
export declare const CheckboxWithCustomLabelStyles: ({ onChange }: CheckboxProps<string>) => JSX.Element;
|
|
68
|
-
export declare const CheckboxWithInlineLayout: ({ onChange }: CheckboxProps<string>) => JSX.Element;
|
|
69
|
-
export declare const CheckboxWithCustomLabel: ({ onChange, wide, classNames, inlineLayout }: CheckboxProps<string>) => JSX.Element;
|
|
69
|
+
export declare const CheckboxWithCustomWrapperStyles: ({ onChange, }: CheckboxProps<string>) => JSX.Element;
|
|
70
|
+
export declare const CheckboxWithCustomOptionStyles: ({ onChange, }: CheckboxProps<string>) => JSX.Element;
|
|
71
|
+
export declare const CheckboxWithCustomLabelStyles: ({ onChange, }: CheckboxProps<string>) => JSX.Element;
|
|
72
|
+
export declare const CheckboxWithInlineLayout: ({ onChange, }: CheckboxProps<string>) => JSX.Element;
|
|
73
|
+
export declare const CheckboxWithCustomLabel: ({ onChange, wide, classNames, inlineLayout, }: CheckboxProps<string>) => JSX.Element;
|
|
70
74
|
export default story;
|
|
@@ -19,5 +19,7 @@ export interface RadioProps<ValueType extends string> {
|
|
|
19
19
|
};
|
|
20
20
|
bordered?: boolean;
|
|
21
21
|
disabled?: boolean;
|
|
22
|
+
fieldLegend?: string;
|
|
23
|
+
groupName?: string;
|
|
22
24
|
}
|
|
23
|
-
export declare const Radio: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, inlineIcon, classNames: classNamesObj, bordered, disabled, }: RadioProps<ValueType>) => JSX.Element;
|
|
25
|
+
export declare const Radio: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, inlineIcon, classNames: classNamesObj, bordered, disabled, fieldLegend, groupName, }: RadioProps<ValueType>) => JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RadioProps } from '.';
|
|
2
2
|
declare const story: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, inlineIcon, classNames: classNamesObj, bordered, disabled, }: RadioProps<ValueType>) => JSX.Element;
|
|
4
|
+
component: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, inlineIcon, classNames: classNamesObj, bordered, disabled, fieldLegend, groupName, }: RadioProps<ValueType>) => JSX.Element;
|
|
5
5
|
argTypes: {
|
|
6
6
|
options: {
|
|
7
7
|
description: string;
|
|
@@ -9,6 +9,12 @@ declare const story: {
|
|
|
9
9
|
value: {
|
|
10
10
|
description: string;
|
|
11
11
|
};
|
|
12
|
+
fieldLegend: {
|
|
13
|
+
description: string;
|
|
14
|
+
};
|
|
15
|
+
groupName: {
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
12
18
|
onChange: {
|
|
13
19
|
description: string;
|
|
14
20
|
action: boolean;
|
|
@@ -50,6 +56,8 @@ declare const story: {
|
|
|
50
56
|
description: string;
|
|
51
57
|
};
|
|
52
58
|
};
|
|
59
|
+
fieldLegend: string;
|
|
60
|
+
groupName: string;
|
|
53
61
|
value: string;
|
|
54
62
|
wide: boolean;
|
|
55
63
|
classNames: {
|
|
@@ -64,7 +72,7 @@ declare const story: {
|
|
|
64
72
|
};
|
|
65
73
|
};
|
|
66
74
|
export declare const RadioStory: {
|
|
67
|
-
({ onChange, options, wide, classNames, inlineLayout, bordered, disabled, }: RadioProps<string>): JSX.Element;
|
|
75
|
+
({ onChange, options, wide, classNames, inlineLayout, bordered, disabled, fieldLegend, groupName, }: RadioProps<string>): JSX.Element;
|
|
68
76
|
storyName: string;
|
|
69
77
|
};
|
|
70
78
|
export declare const RadioWithCustomWrapperStyles: ({ onChange, }: RadioProps<string>) => JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Accept, FileError } from
|
|
2
|
-
import { AcceptType, TextOverrides, UploadStatus } from
|
|
1
|
+
import { Accept, FileError, FileRejection } from 'react-dropzone';
|
|
2
|
+
import { AcceptType, TextOverrides, UploadStatus } from '../types';
|
|
3
3
|
export declare const getUploadStatus: (progress: number, error?: string) => UploadStatus;
|
|
4
4
|
export declare const DOCUMENT_FILES_ACCEPT: Accept;
|
|
5
5
|
export declare const IMAGE_FILES_ACCEPT: Accept;
|
|
@@ -11,3 +11,10 @@ export declare const getErrorMessage: ({ code, message }: FileError, { fileList,
|
|
|
11
11
|
fileList?: string;
|
|
12
12
|
maxSize?: number;
|
|
13
13
|
}, textOverrides?: TextOverrides) => string;
|
|
14
|
+
export declare const getStatusMessage: ({ acceptedFiles, filesRejected, fileList, maxSize, textOverrides, }: {
|
|
15
|
+
acceptedFiles: File[];
|
|
16
|
+
filesRejected: FileRejection[];
|
|
17
|
+
fileList?: string;
|
|
18
|
+
maxSize?: number;
|
|
19
|
+
textOverrides?: TextOverrides;
|
|
20
|
+
}) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableSection-a26ba0c5.js","sources":["../../../src/lib/components/table/types.ts","../../../src/lib/hooks/useMediaQuery.ts","../../../src/lib/components/table/components/TableSection/TableSection.tsx"],"sourcesContent":["import { ReactNode } from 'react';\nimport { BaseCellProps } from './components/TableCell/BaseCell/BaseCell';\nimport { CTACellProps } from './components/TableCell/CTACell/CTACell';\nimport { ButtonCellProps } from './components/TableCell/ButtonCell/ButtonCell';\nimport { CardCellProps } from './components/TableCell/CardCell/CardCell';\n\ntype DefaultCellProps = {\n cellId?: string;\n colSpan?: number;\n modalTitle?: ReactNode;\n};\n\ntype BaseCellData = BaseCellProps & { type?: undefined } & DefaultCellProps;\ntype CTACellData = CTACellProps & { type: 'CTA' } & DefaultCellProps;\ntype ButtonCellData = ButtonCellProps & { type: 'BUTTON' } & DefaultCellProps;\ntype CardCellData = CardCellProps & { type: 'CARD' } & DefaultCellProps;\n\nexport type TableCellData =\n | BaseCellData\n | CTACellData\n | ButtonCellData\n | CardCellData;\n\nexport const isBaseCell = (\n tableCellData: TableCellData\n): tableCellData is BaseCellData => {\n return !tableCellData.type;\n};\n\nexport type TableSectionType = {\n title?: string;\n icon?: ReactNode;\n};\n\nexport type ModalData = {\n title?: ReactNode;\n body?: ReactNode;\n};\n\nexport type TableCellRowData = TableCellData[];\n\nexport type TableSectionData = {\n section?: TableSectionType;\n rows: TableCellRowData[];\n};\n\nexport type TableData = TableSectionData[];\n\nexport type ModalFunction = (modalData: ModalData) => void;\n\nexport type CellReplacements = Record<string, Partial<TableCellData>>;\n","import { useEffect, useState } from 'react';\n\n// USAGE:\n// const isMobile = useMediaQuery('BELOW_MOBILE');\n\nexport const breakpointsArray = [\n 'ABOVE_MOBILE',\n 'ABOVE_TABLET',\n 'ABOVE_DESKTOP',\n 'BELOW_MOBILE',\n 'BELOW_TABLET',\n 'BELOW_DESKTOP',\n] as const;\n\nexport type Breakpoint = typeof breakpointsArray[number];\nexport type BreakpointData = { initialValue: boolean; queryString: string };\n\nexport const breakpointLookup = (breakpoint: Breakpoint): BreakpointData => {\n if (typeof window === 'undefined') {\n return {\n initialValue: false,\n queryString: '',\n };\n }\n\n switch (breakpoint) {\n case 'BELOW_TABLET':\n return {\n initialValue: window.innerWidth <= 720, // 45rem = 720px = tablet breakpoint\n queryString: '(max-width: 45rem)',\n };\n case 'BELOW_DESKTOP':\n return {\n initialValue: window.innerWidth <= 1024, // 64rem = 1024px = desktop breakpoint\n queryString: '(max-width: 64rem)',\n };\n case 'ABOVE_MOBILE':\n return {\n initialValue: window.innerWidth >= 544, // 34rem = 544px = mobile breakpoint}\n queryString: '(min-width: 34rem)',\n };\n case 'ABOVE_TABLET':\n return {\n initialValue: window.innerWidth >= 720, // 45rem = 720px = tablet breakpoint\n queryString: '(min-width: 45rem)',\n };\n case 'ABOVE_DESKTOP':\n return {\n initialValue: window.innerWidth >= 1024, // 64rem = 1024px = desktop breakpoint\n queryString: '(min-width: 64rem)',\n };\n case 'BELOW_MOBILE':\n default:\n return {\n initialValue: window.innerWidth <= 544, // 34rem = 544px = mobile breakpoint}\n queryString: '(max-width: 34rem)',\n };\n }\n};\n\nexport const useMediaQuery = (breakpoint: Breakpoint) => {\n const { initialValue, queryString } = breakpointLookup(breakpoint);\n\n const [matchesBreakpoint, setMatchesBreakpoint] = useState(initialValue);\n\n useEffect(() => {\n const mediaQuery = window.matchMedia(queryString);\n\n const updateMediaQuery = (e: MediaQueryListEvent) =>\n setMatchesBreakpoint(e.matches);\n\n mediaQuery.addEventListener('change', updateMediaQuery);\n\n return () => {\n mediaQuery.removeEventListener('change', updateMediaQuery);\n };\n }, [queryString]);\n\n return matchesBreakpoint;\n};\n","import classNames from 'classnames';\n\nimport styles from './TableSection.module.scss';\nimport { TableCell } from '../TableCell/TableCell';\nimport {\n CellReplacements,\n isBaseCell,\n ModalFunction,\n TableCellData,\n TableCellRowData,\n} from '../../types';\nimport { useCallback } from 'react';\nimport { useMediaQuery } from '../../../../hooks/useMediaQuery';\n\nexport interface TableSectionProps {\n className?: string;\n tableCellRows: TableCellRowData[];\n hideColumns?: number[];\n hideHeader?: boolean;\n openModal?: ModalFunction;\n title: string;\n width?: number | string;\n cellReplacements?: CellReplacements;\n imageComponent?: (args: any) => JSX.Element;\n}\n\nconst TableSection = ({\n className,\n tableCellRows,\n hideColumns = [],\n hideHeader,\n openModal,\n title,\n width,\n cellReplacements,\n imageComponent,\n}: TableSectionProps) => {\n const headerRow = tableCellRows?.[0];\n const isBelowDesktop = useMediaQuery('BELOW_DESKTOP');\n\n const getModalTitleFromColumnHeader = (cellIndex: number) => {\n const firstCellInColumn = tableCellRows?.[0]?.[cellIndex];\n let titleFromColumn;\n\n switch (firstCellInColumn.type) {\n case 'BUTTON':\n titleFromColumn = firstCellInColumn.buttonCaption;\n break;\n case 'CTA':\n titleFromColumn = firstCellInColumn.title;\n break;\n case undefined:\n titleFromColumn = firstCellInColumn.text || '';\n break;\n }\n\n return titleFromColumn;\n };\n\n const getModalTitleFromRowHeader = (currentRow: TableCellRowData) => {\n const firstCellInRow = currentRow?.[0];\n const titleFromRow =\n (isBaseCell(firstCellInRow) && firstCellInRow.text) || '';\n\n return titleFromRow;\n };\n\n const isVisibleColumn = useCallback(\n (cellIndex: number) => !hideColumns.includes(cellIndex),\n [hideColumns]\n );\n\n return (\n <table\n className={classNames(className, 'w100', styles.table)}\n width={width}\n >\n <caption className=\"sr-only\">{title}</caption>\n\n {headerRow && (\n <thead className={hideHeader ? 'sr-only' : ''}>\n <tr>\n {headerRow.map((tableCellData, cellIndex) => {\n const isFirstCellInRow = cellIndex === 0;\n const cellReplacementData =\n (tableCellData.cellId &&\n cellReplacements?.[tableCellData.cellId]) ||\n {};\n\n const cellProps = {\n ...tableCellData,\n ...cellReplacementData,\n ...{\n openModal,\n modalTitle:\n (isBaseCell(tableCellData) && tableCellData.text) ||\n getModalTitleFromColumnHeader(cellIndex),\n align: isFirstCellInRow ? 'left' : 'center',\n },\n } as TableCellData;\n\n return (\n isVisibleColumn(cellIndex) && (\n <TableCell\n key={cellIndex}\n isBelowDesktop={isBelowDesktop}\n isHeader\n isFirstCellInRow={isFirstCellInRow}\n isTopLeftCell={isFirstCellInRow}\n {...cellProps}\n imageComponent={imageComponent}\n />\n )\n );\n })}\n </tr>\n </thead>\n )}\n\n <tbody>\n {tableCellRows.map(\n (row, rowIndex) =>\n rowIndex > 0 && (\n <tr key={rowIndex} className={styles.tr}>\n {row.map((tableCellData, cellIndex) => {\n const key = `${rowIndex}-${cellIndex}`;\n const isFirstCellInRow = cellIndex === 0;\n const titleFromRow = getModalTitleFromRowHeader(row);\n\n const cellReplacementData =\n (tableCellData.cellId &&\n cellReplacements?.[tableCellData.cellId]) ||\n {};\n\n const cellProps = {\n ...tableCellData,\n ...cellReplacementData,\n ...{\n openModal,\n modalTitle: tableCellData?.modalTitle || titleFromRow,\n align: isFirstCellInRow ? 'left' : 'center',\n },\n } as TableCellData;\n\n return (\n !hideColumns.includes(cellIndex) && (\n <TableCell\n isBelowDesktop={isBelowDesktop}\n isFirstCellInRow={isFirstCellInRow}\n key={key}\n {...cellProps}\n imageComponent={imageComponent}\n />\n )\n );\n })}\n </tr>\n )\n )}\n </tbody>\n </table>\n );\n};\n\nexport { TableSection };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;IAuBa,UAAU,GAAG,UACxB,aAA4B;IAE5B,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC;AAC7B;;ACVO,IAAM,gBAAgB,GAAG,UAAC,UAAsB;IACrD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO;YACL,YAAY,EAAE,KAAK;YACnB,WAAW,EAAE,EAAE;SAChB,CAAC;KACH;IAED,QAAQ,UAAU;QAChB,KAAK,cAAc;YACjB,OAAO;gBACL,YAAY,EAAE,MAAM,CAAC,UAAU,IAAI,GAAG;gBACtC,WAAW,EAAE,oBAAoB;aAClC,CAAC;QACJ,KAAK,eAAe;YAClB,OAAO;gBACL,YAAY,EAAE,MAAM,CAAC,UAAU,IAAI,IAAI;gBACvC,WAAW,EAAE,oBAAoB;aAClC,CAAC;QACJ,KAAK,cAAc;YACjB,OAAO;gBACL,YAAY,EAAE,MAAM,CAAC,UAAU,IAAI,GAAG;gBACtC,WAAW,EAAE,oBAAoB;aAClC,CAAC;QACJ,KAAK,cAAc;YACjB,OAAO;gBACL,YAAY,EAAE,MAAM,CAAC,UAAU,IAAI,GAAG;gBACtC,WAAW,EAAE,oBAAoB;aAClC,CAAC;QACJ,KAAK,eAAe;YAClB,OAAO;gBACL,YAAY,EAAE,MAAM,CAAC,UAAU,IAAI,IAAI;gBACvC,WAAW,EAAE,oBAAoB;aAClC,CAAC;QACJ,KAAK,cAAc,CAAC;QACpB;YACE,OAAO;gBACL,YAAY,EAAE,MAAM,CAAC,UAAU,IAAI,GAAG;gBACtC,WAAW,EAAE,oBAAoB;aAClC,CAAC;KACL;AACH,CAAC,CAAC;IAEW,aAAa,GAAG,UAAC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AE,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,IAE9B,SAAS,IACb,cAAc,EAAE,cAAc,KAFzB,GAAG,CAGR,CACH,EACD;yBACH,CAAC,IAhCK,QAAQ,CAiCZ,CACN;iBAAA,CACJ,GACK,IACF,EACR;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"TableSection-ebace923.js","sources":["../../../src/lib/components/table/types.ts","../../../src/lib/hooks/useMediaQuery.ts","../../../src/lib/components/table/components/TableSection/TableSection.tsx"],"sourcesContent":["import { ReactNode } from 'react';\nimport { BaseCellProps } from './components/TableCell/BaseCell/BaseCell';\nimport { CTACellProps } from './components/TableCell/CTACell/CTACell';\nimport { ButtonCellProps } from './components/TableCell/ButtonCell/ButtonCell';\nimport { CardCellProps } from './components/TableCell/CardCell/CardCell';\n\ntype DefaultCellProps = {\n cellId?: string;\n colSpan?: number;\n modalTitle?: ReactNode;\n};\n\ntype BaseCellData = BaseCellProps & { type?: undefined } & DefaultCellProps;\ntype CTACellData = CTACellProps & { type: 'CTA' } & DefaultCellProps;\ntype ButtonCellData = ButtonCellProps & { type: 'BUTTON' } & DefaultCellProps;\ntype CardCellData = CardCellProps & { type: 'CARD' } & DefaultCellProps;\n\nexport type TableCellData =\n | BaseCellData\n | CTACellData\n | ButtonCellData\n | CardCellData;\n\nexport const isBaseCell = (\n tableCellData: TableCellData\n): tableCellData is BaseCellData => {\n return !tableCellData.type;\n};\n\nexport type TableSectionType = {\n title?: string;\n icon?: ReactNode;\n};\n\nexport type ModalData = {\n title?: ReactNode;\n body?: ReactNode;\n};\n\nexport type TableCellRowData = TableCellData[];\n\nexport type TableSectionData = {\n section?: TableSectionType;\n rows: TableCellRowData[];\n};\n\nexport type TableData = TableSectionData[];\n\nexport type ModalFunction = (modalData: ModalData) => void;\n\nexport type CellReplacements = Record<string, Partial<TableCellData>>;\n","import { useEffect, useState } from 'react';\n\n// USAGE:\n// const isMobile = useMediaQuery('BELOW_MOBILE');\n\nexport const breakpointsArray = [\n 'ABOVE_MOBILE',\n 'ABOVE_TABLET',\n 'ABOVE_DESKTOP',\n 'BELOW_MOBILE',\n 'BELOW_TABLET',\n 'BELOW_DESKTOP',\n] as const;\n\nexport type Breakpoint = typeof breakpointsArray[number];\nexport type BreakpointData = { initialValue: boolean; queryString: string };\n\nexport const breakpointLookup = (breakpoint: Breakpoint): BreakpointData => {\n if (typeof window === 'undefined') {\n return {\n initialValue: false,\n queryString: '',\n };\n }\n\n switch (breakpoint) {\n case 'BELOW_TABLET':\n return {\n initialValue: window.innerWidth <= 720, // 45rem = 720px = tablet breakpoint\n queryString: '(max-width: 45rem)',\n };\n case 'BELOW_DESKTOP':\n return {\n initialValue: window.innerWidth <= 1024, // 64rem = 1024px = desktop breakpoint\n queryString: '(max-width: 64rem)',\n };\n case 'ABOVE_MOBILE':\n return {\n initialValue: window.innerWidth >= 544, // 34rem = 544px = mobile breakpoint}\n queryString: '(min-width: 34rem)',\n };\n case 'ABOVE_TABLET':\n return {\n initialValue: window.innerWidth >= 720, // 45rem = 720px = tablet breakpoint\n queryString: '(min-width: 45rem)',\n };\n case 'ABOVE_DESKTOP':\n return {\n initialValue: window.innerWidth >= 1024, // 64rem = 1024px = desktop breakpoint\n queryString: '(min-width: 64rem)',\n };\n case 'BELOW_MOBILE':\n default:\n return {\n initialValue: window.innerWidth <= 544, // 34rem = 544px = mobile breakpoint}\n queryString: '(max-width: 34rem)',\n };\n }\n};\n\nexport const useMediaQuery = (breakpoint: Breakpoint) => {\n const { initialValue, queryString } = breakpointLookup(breakpoint);\n\n const [matchesBreakpoint, setMatchesBreakpoint] = useState(initialValue);\n\n useEffect(() => {\n const mediaQuery = window.matchMedia(queryString);\n\n const updateMediaQuery = (e: MediaQueryListEvent) =>\n setMatchesBreakpoint(e.matches);\n\n mediaQuery.addEventListener('change', updateMediaQuery);\n\n return () => {\n mediaQuery.removeEventListener('change', updateMediaQuery);\n };\n }, [queryString]);\n\n return matchesBreakpoint;\n};\n","import classNames from 'classnames';\n\nimport styles from './TableSection.module.scss';\nimport { TableCell } from '../TableCell/TableCell';\nimport {\n CellReplacements,\n isBaseCell,\n ModalFunction,\n TableCellData,\n TableCellRowData,\n} from '../../types';\nimport { useCallback } from 'react';\nimport { useMediaQuery } from '../../../../hooks/useMediaQuery';\n\nexport interface TableSectionProps {\n className?: string;\n tableCellRows: TableCellRowData[];\n hideColumns?: number[];\n hideHeader?: boolean;\n openModal?: ModalFunction;\n title: string;\n width?: number | string;\n cellReplacements?: CellReplacements;\n imageComponent?: (args: any) => JSX.Element;\n}\n\nconst TableSection = ({\n className,\n tableCellRows,\n hideColumns = [],\n hideHeader,\n openModal,\n title,\n width,\n cellReplacements,\n imageComponent,\n}: TableSectionProps) => {\n const headerRow = tableCellRows?.[0];\n const isBelowDesktop = useMediaQuery('BELOW_DESKTOP');\n\n const getModalTitleFromColumnHeader = (cellIndex: number) => {\n const firstCellInColumn = tableCellRows?.[0]?.[cellIndex];\n let titleFromColumn;\n\n switch (firstCellInColumn.type) {\n case 'BUTTON':\n titleFromColumn = firstCellInColumn.buttonCaption;\n break;\n case 'CTA':\n titleFromColumn = firstCellInColumn.title;\n break;\n case undefined:\n titleFromColumn = firstCellInColumn.text || '';\n break;\n }\n\n return titleFromColumn;\n };\n\n const getModalTitleFromRowHeader = (currentRow: TableCellRowData) => {\n const firstCellInRow = currentRow?.[0];\n const titleFromRow =\n (isBaseCell(firstCellInRow) && firstCellInRow.text) || '';\n\n return titleFromRow;\n };\n\n const isVisibleColumn = useCallback(\n (cellIndex: number) => !hideColumns.includes(cellIndex),\n [hideColumns]\n );\n\n return (\n <table\n className={classNames(className, 'w100', styles.table)}\n width={width}\n >\n <caption className=\"sr-only\">{title}</caption>\n\n {headerRow && (\n <thead className={hideHeader ? 'sr-only' : ''}>\n <tr>\n {headerRow.map((tableCellData, cellIndex) => {\n const isFirstCellInRow = cellIndex === 0;\n const cellReplacementData =\n (tableCellData.cellId &&\n cellReplacements?.[tableCellData.cellId]) ||\n {};\n\n const cellProps = {\n ...tableCellData,\n ...cellReplacementData,\n ...{\n openModal,\n modalTitle:\n (isBaseCell(tableCellData) && tableCellData.text) ||\n getModalTitleFromColumnHeader(cellIndex),\n align: isFirstCellInRow ? 'left' : 'center',\n },\n } as TableCellData;\n\n return (\n isVisibleColumn(cellIndex) && (\n <TableCell\n key={cellIndex}\n isBelowDesktop={isBelowDesktop}\n isHeader\n isFirstCellInRow={isFirstCellInRow}\n isTopLeftCell={isFirstCellInRow}\n {...cellProps}\n imageComponent={imageComponent}\n />\n )\n );\n })}\n </tr>\n </thead>\n )}\n\n <tbody>\n {tableCellRows.map(\n (row, rowIndex) =>\n rowIndex > 0 && (\n <tr key={rowIndex} className={styles.tr}>\n {row.map((tableCellData, cellIndex) => {\n const key = `${rowIndex}-${cellIndex}`;\n const isFirstCellInRow = cellIndex === 0;\n const titleFromRow = getModalTitleFromRowHeader(row);\n\n const cellReplacementData =\n (tableCellData.cellId &&\n cellReplacements?.[tableCellData.cellId]) ||\n {};\n\n const cellProps = {\n ...tableCellData,\n ...cellReplacementData,\n ...{\n openModal,\n modalTitle: tableCellData?.modalTitle || titleFromRow,\n align: isFirstCellInRow ? 'left' : 'center',\n },\n } as TableCellData;\n\n return (\n !hideColumns.includes(cellIndex) && (\n <TableCell\n isBelowDesktop={isBelowDesktop}\n isFirstCellInRow={isFirstCellInRow}\n key={key}\n {...cellProps}\n imageComponent={imageComponent}\n />\n )\n );\n })}\n </tr>\n )\n )}\n </tbody>\n </table>\n );\n};\n\nexport { TableSection };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;IAuBa,UAAU,GAAG,UACxB,aAA4B;IAE5B,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC;AAC7B;;ACVO,IAAM,gBAAgB,GAAG,UAAC,UAAsB;IACrD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO;YACL,YAAY,EAAE,KAAK;YACnB,WAAW,EAAE,EAAE;SAChB,CAAC;KACH;IAED,QAA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ACZ,OAAA,QAAQ,GAAG,CAAC,KACVA,YAAmB,SAAS,EAAE,MAAM,CAAC,EAAE,YACpC,GAAG,CAAC,GAAG,CAAC,UAAC,aAAa,EAAE,SAAS;4BAChC,IAAM,GAAG,GAAG,UAAG,QAAQ,cAAI,SAAS,CAAE,CAAC;4BACvC,IAAM,gBAAgB,GAAG,SAAS,KAAK,CAAC,CAAC;4BACzC,IAAM,YAAY,GAAG,0BAA0B,CAAC,GAAG,CAAC,CAAC;4BAErD,IAAM,mBAAmB,GACvB,CAAC,aAAa,CAAC,MAAM;iCACnB,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAG,aAAa,CAAC,MAAM,CAAC,CAAA;gCAC1C,EAAE,CAAC;4BAEL,IAAM,SAAS,GAAG,+BACb,aAAa,GACb,mBAAmB,GACnB;gCACD,SAAS,WAAA;gCACT,UAAU,EAAE,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,UAAU,KAAI,YAAY;gCACrD,KAAK,EAAE,gBAAgB,GAAG,MAAM,GAAG,QAAQ;6BAC5C,CACe,CAAC;4BAEnB,QACE,CAAC,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,KAC9BA,IAAC,SAAS,aACR,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,IAE9B,SAAS,IACb,cAAc,EAAE,cAAc,KAFzB,GAAG,CAGR,CACH,EACD;yBACH,CAAC,IAhCK,QAAQ,CAiCZ,CACN;iBAAA,CACJ,GACK,IACF,EACR;AACJ;;;;"}
|
|
@@ -6,13 +6,13 @@ import '../icon/IconWrapper/IconWrapper.js';
|
|
|
6
6
|
import '../../tslib.es6-a39f91fc.js';
|
|
7
7
|
import '../../index-6ea95111.js';
|
|
8
8
|
|
|
9
|
-
var css_248z = ".style-module_chip__3LMgV {\n background: var(--ds-primary-100);\n border: 2px solid var(--ds-primary-100);\n border-radius: 8px;\n padding: 4px 8px;\n width: fit-content;\n width: -moz-fit-content;\n display: flex;\n align-items: center;\n animation-name: style-module_appearInAnimation__33Ebn;\n animation-duration: 0.5s;\n animation-fill-mode: both;\n}\n\n.style-module_chip__3LMgV:hover {\n transition: 0.2s ease-in;\n border: 2px solid var(--ds-primary-500);\n}\n\n.style-module_chip-image__2vVqF {\n width: 24px;\n height: 14px;\n}\n\n.style-module_chip-button-container__3gSRY {\n color: #b1b0f5;\n position: relative;\n width: 16px;\n height: 16px;\n background: none;\n border: none;\n padding: 0;\n margin: 0;\n text-align: inherit;\n outline: none;\n box-shadow: none;\n appearance: none;\n -webkit-appearance: none;\n -moz-appearance: none;\n cursor: pointer;\n}\n.style-module_chip-button-container__3gSRY:hover {\n color: #8e8cee;\n}\n\n.style-module_chip-remove-button__3LK7e {\n margin: 0;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.style-module_chip-remove-button__3LK7e svg {\n vertical-align: top;\n}\n\n@keyframes style-module_appearInAnimation__33Ebn {\n from {\n opacity: 0;\n transform: translateX(16px);\n }\n to {\n opacity: 1;\n }\n}";
|
|
9
|
+
var css_248z = ".style-module_chip__3LMgV {\n background: var(--ds-primary-100);\n border: 2px solid var(--ds-primary-100);\n border-radius: 8px;\n padding: 4px 8px;\n width: fit-content;\n width: -moz-fit-content;\n display: flex;\n align-items: center;\n animation-name: style-module_appearInAnimation__33Ebn;\n animation-duration: 0.5s;\n animation-fill-mode: both;\n}\n\n.style-module_chip__3LMgV:hover {\n transition: 0.2s ease-in;\n border: 2px solid var(--ds-primary-500);\n}\n\n.style-module_chip-image__2vVqF {\n width: 24px;\n height: 14px;\n}\n\n.style-module_chip-button-container__3gSRY {\n color: #b1b0f5;\n position: relative;\n width: 16px;\n height: 16px;\n background: none;\n border: none;\n padding: 0;\n margin: 0;\n text-align: inherit;\n outline: none;\n box-shadow: none;\n appearance: none;\n -webkit-appearance: none;\n -moz-appearance: none;\n cursor: pointer;\n}\n.style-module_chip-button-container__3gSRY:hover {\n color: #8e8cee;\n}\n.style-module_chip-button-container__3gSRY:focus-visible {\n outline: 2px solid var(--ds-primary-500);\n border-radius: 2px;\n}\n\n.style-module_chip-remove-button__3LK7e {\n margin: 0;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.style-module_chip-remove-button__3LK7e svg {\n vertical-align: top;\n}\n\n@keyframes style-module_appearInAnimation__33Ebn {\n from {\n opacity: 0;\n transform: translateX(16px);\n }\n to {\n opacity: 1;\n }\n}";
|
|
10
10
|
var styles = {"chip":"style-module_chip__3LMgV","appearInAnimation":"style-module_appearInAnimation__33Ebn","chip-image":"style-module_chip-image__2vVqF","chip-button-container":"style-module_chip-button-container__3gSRY","chip-remove-button":"style-module_chip-remove-button__3LK7e"};
|
|
11
11
|
styleInject(css_248z);
|
|
12
12
|
|
|
13
13
|
var Chip = (function (_a) {
|
|
14
14
|
var className = _a.className, value = _a.value, onRemove = _a.onRemove;
|
|
15
|
-
return (jsxs("div", { className: "p-p mr8 mb8 d-flex ".concat(className, " ").concat(styles['chip']), children: [value.leftIcon && (jsx("img", { className: "mr8 ".concat(styles['chip-image']), src: value.leftIcon, alt: value.value })), jsx("div", { className: "mr8", children: value.value }), jsx("button", { className: "c-pointer ".concat(styles['chip-button-container']), type: "button", onClick: function () { return onRemove(value); }, children: jsx(XIcon, { className: styles['chip-remove-button'] }) })] }));
|
|
15
|
+
return (jsxs("div", { className: "p-p mr8 mb8 d-flex ".concat(className, " ").concat(styles['chip']), children: [value.leftIcon && (jsx("img", { className: "mr8 ".concat(styles['chip-image']), src: value.leftIcon, alt: value.value })), jsx("div", { className: "mr8", children: value.value }), jsx("button", { className: "c-pointer ".concat(styles['chip-button-container']), type: "button", onClick: function () { return onRemove(value); }, "aria-label": "Remove ".concat(value.value, " option"), children: jsx(XIcon, { className: styles['chip-remove-button'] }) })] }));
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
export default Chip;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/lib/components/chip/index.tsx"],"sourcesContent":["import { Option } from '../../models/autoSuggestInput';\nimport { XIcon } from '../icon/icons';\n\nimport styles from './style.module.scss';\n\nexport interface ChipProps {\n value: Option;\n onRemove: (value: Option) => void;\n className?: string;\n}\n\nexport default ({\n className,\n value,\n onRemove,\n}: ChipProps) => (\n <div className={`p-p mr8 mb8 d-flex ${className} ${styles['chip']}`}>\n {value.leftIcon && (\n <img\n className={`mr8 ${styles['chip-image']}`}\n src={value.leftIcon}\n alt={value.value}\n />\n )}\n <div className=\"mr8\">{value.value}</div>\n <button\n className={`c-pointer ${styles['chip-button-container']}`}\n type=\"button\"\n onClick={() => onRemove(value)}\n >\n <XIcon className={styles['chip-remove-button']} />\n </button>\n </div>\n);\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;AAWA,YAAe,UAAC,EAIJ;QAHV,SAAS,eAAA,EACT,KAAK,WAAA,EACL,QAAQ,cAAA;IACO,QACfA,cAAK,SAAS,EAAE,6BAAsB,SAAS,cAAI,MAAM,CAAC,MAAM,CAAC,CAAE,aAChE,KAAK,CAAC,QAAQ,KACbC,aACE,SAAS,EAAE,cAAO,MAAM,CAAC,YAAY,CAAC,CAAE,EACxC,GAAG,EAAE,KAAK,CAAC,QAAQ,EACnB,GAAG,EAAE,KAAK,CAAC,KAAK,GAChB,CACH,EACDA,aAAK,SAAS,EAAC,KAAK,YAAE,KAAK,CAAC,KAAK,GAAO,EACxCA,gBACE,SAAS,EAAE,oBAAa,MAAM,CAAC,uBAAuB,CAAC,CAAE,EACzD,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,cAAM,OAAA,QAAQ,CAAC,KAAK,CAAC,GAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/lib/components/chip/index.tsx"],"sourcesContent":["import { Option } from '../../models/autoSuggestInput';\nimport { XIcon } from '../icon/icons';\n\nimport styles from './style.module.scss';\n\nexport interface ChipProps {\n value: Option;\n onRemove: (value: Option) => void;\n className?: string;\n}\n\nexport default ({\n className,\n value,\n onRemove,\n}: ChipProps) => (\n <div className={`p-p mr8 mb8 d-flex ${className} ${styles['chip']}`}>\n {value.leftIcon && (\n <img\n className={`mr8 ${styles['chip-image']}`}\n src={value.leftIcon}\n alt={value.value}\n />\n )}\n <div className=\"mr8\">{value.value}</div>\n <button\n className={`c-pointer ${styles['chip-button-container']}`}\n type=\"button\"\n onClick={() => onRemove(value)}\n aria-label={`Remove ${value.value} option`}\n >\n <XIcon className={styles['chip-remove-button']} />\n </button>\n </div>\n);\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;AAWA,YAAe,UAAC,EAIJ;QAHV,SAAS,eAAA,EACT,KAAK,WAAA,EACL,QAAQ,cAAA;IACO,QACfA,cAAK,SAAS,EAAE,6BAAsB,SAAS,cAAI,MAAM,CAAC,MAAM,CAAC,CAAE,aAChE,KAAK,CAAC,QAAQ,KACbC,aACE,SAAS,EAAE,cAAO,MAAM,CAAC,YAAY,CAAC,CAAE,EACxC,GAAG,EAAE,KAAK,CAAC,QAAQ,EACnB,GAAG,EAAE,KAAK,CAAC,KAAK,GAChB,CACH,EACDA,aAAK,SAAS,EAAC,KAAK,YAAE,KAAK,CAAC,KAAK,GAAO,EACxCA,gBACE,SAAS,EAAE,oBAAa,MAAM,CAAC,uBAAuB,CAAC,CAAE,EACzD,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,cAAM,OAAA,QAAQ,CAAC,KAAK,CAAC,GAAA,gBAClB,iBAAU,KAAK,CAAC,KAAK,YAAS,YAE1CA,IAAC,KAAK,IAAC,SAAS,EAAE,MAAM,CAAC,oBAAoB,CAAC,GAAI,GAC3C,IACL;AAlBS,CAmBhB;;;;"}
|
|
@@ -12,7 +12,7 @@ styleInject(css_248z);
|
|
|
12
12
|
|
|
13
13
|
var TableInfoButton = function (_a) {
|
|
14
14
|
var onClick = _a.onClick, _b = _a.className, className = _b === void 0 ? '' : _b;
|
|
15
|
-
return (jsx("button", { className: "p-btn--secondary ".concat(styles.button, " ").concat(className), type: "button", "data-testid": "ds-table-info-button", onClick: onClick, children: jsx(Info, { size: 20 }) }));
|
|
15
|
+
return (jsx("button", { className: "p-btn--secondary ".concat(styles.button, " ").concat(className), type: "button", "data-testid": "ds-table-info-button", onClick: onClick, "aria-label": "View more information", title: "View more information", children: jsx(Info, { size: 20 }) }));
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export default TableInfoButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../../src/lib/components/comparisonTable/components/TableInfoButton/index.tsx"],"sourcesContent":["import Info from '../../../icon/icons/Info';\nimport styles from './style.module.scss';\n\nconst TableInfoButton = ({\n onClick,\n className = '',\n}: {\n onClick: () => void;\n className?: string;\n}) => (\n <button\n className={`p-btn--secondary ${styles.button} ${className}`}\n type=\"button\"\n data-testid=\"ds-table-info-button\"\n onClick={onClick}\n >\n <Info size={20} />\n </button>\n);\n\nexport default TableInfoButton;\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;IAGM,eAAe,GAAG,UAAC,EAMxB;QALC,OAAO,aAAA,EACP,iBAAc,EAAd,SAAS,mBAAG,EAAE,KAAA;IAIV,QACJA,gBACE,SAAS,EAAE,2BAAoB,MAAM,CAAC,MAAM,cAAI,SAAS,CAAE,EAC3D,IAAI,EAAC,QAAQ,iBACD,sBAAsB,EAClC,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../../src/lib/components/comparisonTable/components/TableInfoButton/index.tsx"],"sourcesContent":["import Info from '../../../icon/icons/Info';\nimport styles from './style.module.scss';\n\nconst TableInfoButton = ({\n onClick,\n className = '',\n}: {\n onClick: () => void;\n className?: string;\n}) => (\n <button\n className={`p-btn--secondary ${styles.button} ${className}`}\n type=\"button\"\n data-testid=\"ds-table-info-button\"\n onClick={onClick}\n aria-label=\"View more information\"\n title=\"View more information\"\n >\n <Info size={20} />\n </button>\n);\n\nexport default TableInfoButton;\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;IAGM,eAAe,GAAG,UAAC,EAMxB;QALC,OAAO,aAAA,EACP,iBAAc,EAAd,SAAS,mBAAG,EAAE,KAAA;IAIV,QACJA,gBACE,SAAS,EAAE,2BAAoB,MAAM,CAAC,MAAM,cAAI,SAAS,CAAE,EAC3D,IAAI,EAAC,QAAQ,iBACD,sBAAsB,EAClC,OAAO,EAAE,OAAO,gBACL,uBAAuB,EAClC,KAAK,EAAC,uBAAuB,YAE7BA,IAAC,IAAI,IAAC,IAAI,EAAE,EAAE,GAAI,GACX;AAVL;;;;"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { _ as __spreadArray } from '../../../tslib.es6-a39f91fc.js';
|
|
2
|
-
import {
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { c as classNames } from '../../../index-6ea95111.js';
|
|
4
4
|
import { s as styleInject } from '../../../style-inject.es-1f59c1d0.js';
|
|
5
5
|
|
|
6
|
-
var css_248z = ".styles-module_container__3zJJC {\n max-width: 100%;\n}\n\n.styles-module_narrow__2p34b {\n max-width: 424px;\n}";
|
|
6
|
+
var css_248z = ".styles-module_container__3zJJC {\n max-width: 100%;\n border: 0;\n margin: 0;\n min-width: 0;\n padding: 0.01em 0 0 0;\n}\n\n.styles-module_narrow__2p34b {\n max-width: 424px;\n}";
|
|
7
7
|
var styles = {"container":"styles-module_container__3zJJC","narrow":"styles-module_narrow__2p34b"};
|
|
8
8
|
styleInject(css_248z);
|
|
9
9
|
|
|
10
10
|
var Checkbox = function (_a) {
|
|
11
11
|
var _b;
|
|
12
|
-
var options = _a.options, _c = _a.value, value = _c === void 0 ? [] : _c, onChange = _a.onChange, _d = _a.wide, wide = _d === void 0 ? false : _d, _e = _a.inlineLayout, inlineLayout = _e === void 0 ? false : _e, _f = _a.bordered, bordered = _f === void 0 ? true : _f, classNamesObj = _a.classNames;
|
|
12
|
+
var options = _a.options, _c = _a.value, value = _c === void 0 ? [] : _c, onChange = _a.onChange, _d = _a.wide, wide = _d === void 0 ? false : _d, _e = _a.inlineLayout, inlineLayout = _e === void 0 ? false : _e, _f = _a.bordered, bordered = _f === void 0 ? true : _f, classNamesObj = _a.classNames, fieldLegend = _a.fieldLegend;
|
|
13
13
|
var hasNoneValue = Object.keys(options).includes('NONE');
|
|
14
14
|
var handleOnChange = function (newValue) {
|
|
15
15
|
if (value === null || value === void 0 ? void 0 : value.includes(newValue)) {
|
|
@@ -34,23 +34,26 @@ var Checkbox = function (_a) {
|
|
|
34
34
|
var isCheckboxLabelObject = function (label) {
|
|
35
35
|
return label.title !== undefined;
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
var legend = fieldLegend !== null && fieldLegend !== void 0 ? fieldLegend : (Object.keys(options).length > 1
|
|
38
|
+
? 'Select one or more options'
|
|
39
|
+
: 'You may select this option');
|
|
40
|
+
return (jsxs("fieldset", { className: classNames(classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.container, styles.container, 'd-flex gap8', (_b = {},
|
|
38
41
|
_b[styles.narrow] = !wide,
|
|
39
42
|
_b['fd-row'] = inlineLayout,
|
|
40
43
|
_b['f-wrap'] = inlineLayout,
|
|
41
44
|
_b['fd-column'] = !inlineLayout,
|
|
42
|
-
_b)), children: entries.map(function (_a) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
_b)), children: [jsx("legend", { className: "sr-only", children: legend }), entries.map(function (_a) {
|
|
46
|
+
var currentValue = _a[0], label = _a[1];
|
|
47
|
+
var checked = value === null || value === void 0 ? void 0 : value.includes(currentValue);
|
|
48
|
+
var customIcon = label === null || label === void 0 ? void 0 : label.icon;
|
|
49
|
+
return (jsxs("div", { className: classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.option, children: [jsx("input", { className: classNames('p-checkbox', {
|
|
50
|
+
'p-checkbox--no-icon': customIcon,
|
|
51
|
+
}), id: currentValue, type: "checkbox", value: currentValue, onChange: function () { return handleOnChange(currentValue); }, checked: checked, "data-testid": "checkbox-input-".concat(currentValue) }), jsxs("label", { htmlFor: currentValue, className: classNames(classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.label, 'p-label pr16', {
|
|
52
|
+
'p-label--bordered': bordered,
|
|
53
|
+
'jc-center': customIcon,
|
|
54
|
+
'fd-column': customIcon,
|
|
55
|
+
}), "data-cy": "checkbox-".concat(currentValue), "data-testid": "checkbox-".concat(currentValue), children: [customIcon && jsx("div", { className: "mt8", children: customIcon === null || customIcon === void 0 ? void 0 : customIcon(checked) }), isCheckboxLabelObject(label) ? (jsxs("div", { children: [jsx("p", { className: "p-p", children: label.title }), jsx("span", { className: "d-block p-p p-p--small tc-grey-600", children: label.description })] })) : (label)] })] }, currentValue));
|
|
56
|
+
})] }));
|
|
54
57
|
};
|
|
55
58
|
|
|
56
59
|
export { Checkbox };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../src/lib/components/input/checkbox/index.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { ReactNode } from 'react';\n\nimport styles from './styles.module.scss';\nexport interface CheckboxWithDescription {\n title: ReactNode;\n description?: string;\n icon?: (selected: boolean) => ReactNode;\n}\n\nexport interface CheckboxProps<ValueType extends string> {\n options: Record<ValueType, ReactNode | CheckboxWithDescription>;\n value?: ValueType[];\n onChange: (value: ValueType[]) => void;\n wide?: boolean;\n inlineLayout?: boolean;\n bordered?: Boolean;\n classNames?: {\n container?: string;\n label?: string;\n option?: string;\n };\n}\n\nexport const Checkbox = <ValueType extends string>({\n options,\n value = [],\n onChange,\n wide = false,\n inlineLayout = false,\n bordered = true,\n classNames: classNamesObj,\n}: CheckboxProps<ValueType> & {}) => {\n const hasNoneValue = Object.keys(options).includes('NONE');\n\n const handleOnChange = (newValue: ValueType) => {\n if (value?.includes(newValue)) {\n const filteredCheckboxValues = value.filter(\n (selectedValue) => selectedValue !== newValue\n );\n\n onChange(filteredCheckboxValues);\n return;\n }\n\n if (hasNoneValue && newValue === 'NONE') {\n onChange([newValue]);\n return;\n }\n\n if (hasNoneValue && newValue !== 'NONE') {\n const newValues = value\n ? [...value.filter((v) => v !== 'NONE'), newValue]\n : [newValue];\n onChange(newValues);\n return;\n }\n\n const newValues = value ? [...value, newValue] : [newValue];\n onChange(newValues);\n };\n\n const entries = Object.entries(options) as [\n ValueType,\n ReactNode | CheckboxWithDescription\n ][];\n\n const isCheckboxLabelObject = (\n label: ReactNode | CheckboxWithDescription\n ): label is CheckboxWithDescription => {\n return (label as CheckboxWithDescription).title !== undefined;\n };\n\n return (\n <
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/lib/components/input/checkbox/index.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { ReactNode } from 'react';\n\nimport styles from './styles.module.scss';\nexport interface CheckboxWithDescription {\n title: ReactNode;\n description?: string;\n icon?: (selected: boolean) => ReactNode;\n}\n\nexport interface CheckboxProps<ValueType extends string> {\n options: Record<ValueType, ReactNode | CheckboxWithDescription>;\n value?: ValueType[];\n onChange: (value: ValueType[]) => void;\n wide?: boolean;\n inlineLayout?: boolean;\n bordered?: Boolean;\n classNames?: {\n container?: string;\n label?: string;\n option?: string;\n };\n fieldLegend?: string;\n}\n\nexport const Checkbox = <ValueType extends string>({\n options,\n value = [],\n onChange,\n wide = false,\n inlineLayout = false,\n bordered = true,\n classNames: classNamesObj,\n fieldLegend,\n}: CheckboxProps<ValueType> & {}) => {\n const hasNoneValue = Object.keys(options).includes('NONE');\n\n const handleOnChange = (newValue: ValueType) => {\n if (value?.includes(newValue)) {\n const filteredCheckboxValues = value.filter(\n (selectedValue) => selectedValue !== newValue\n );\n\n onChange(filteredCheckboxValues);\n return;\n }\n\n if (hasNoneValue && newValue === 'NONE') {\n onChange([newValue]);\n return;\n }\n\n if (hasNoneValue && newValue !== 'NONE') {\n const newValues = value\n ? [...value.filter((v) => v !== 'NONE'), newValue]\n : [newValue];\n onChange(newValues);\n return;\n }\n\n const newValues = value ? [...value, newValue] : [newValue];\n onChange(newValues);\n };\n\n const entries = Object.entries(options) as [\n ValueType,\n ReactNode | CheckboxWithDescription\n ][];\n\n const isCheckboxLabelObject = (\n label: ReactNode | CheckboxWithDescription\n ): label is CheckboxWithDescription => {\n return (label as CheckboxWithDescription).title !== undefined;\n };\n\n const legend =\n fieldLegend ??\n (Object.keys(options).length > 1\n ? 'Select one or more options'\n : 'You may select this option');\n\n return (\n <fieldset\n className={classNames(\n classNamesObj?.container,\n styles.container,\n 'd-flex gap8',\n {\n [styles.narrow]: !wide,\n 'fd-row': inlineLayout,\n 'f-wrap': inlineLayout,\n 'fd-column': !inlineLayout,\n }\n )}\n >\n <legend className=\"sr-only\">{legend}</legend>\n {entries.map(([currentValue, label]) => {\n const checked = value?.includes(currentValue);\n const customIcon = (label as CheckboxWithDescription)?.icon;\n\n return (\n <div className={classNamesObj?.option} key={currentValue}>\n <input\n className={classNames('p-checkbox', {\n 'p-checkbox--no-icon': customIcon,\n })}\n id={currentValue}\n type=\"checkbox\"\n value={currentValue}\n onChange={() => handleOnChange(currentValue)}\n checked={checked}\n data-testid={`checkbox-input-${currentValue}`}\n />\n\n <label\n htmlFor={currentValue}\n className={classNames(classNamesObj?.label, 'p-label pr16', {\n 'p-label--bordered': bordered,\n 'jc-center': customIcon,\n 'fd-column': customIcon,\n })}\n data-cy={`checkbox-${currentValue}`}\n data-testid={`checkbox-${currentValue}`}\n >\n {customIcon && <div className=\"mt8\">{customIcon?.(checked)}</div>}\n\n {isCheckboxLabelObject(label) ? (\n <div>\n <p className=\"p-p\">{label.title}</p>\n <span className=\"d-block p-p p-p--small tc-grey-600\">\n {label.description}\n </span>\n </div>\n ) : (\n label\n )}\n </label>\n </div>\n );\n })}\n </fieldset>\n );\n};\n"],"names":["_jsxs","_jsx"],"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FD,gBACE,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,UAAU,CAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,KAAK,EAAE,cAAc,EAAE;gCAC1D,mBAAmB,EAAE,QAAQ;gCAC7B,WAAW,EAAE,UAAU;gCACvB,WAAW,EAAE,UAAU;6BACxB,CAAC,aACO,mBAAY,YAAY,CAAE,iBACtB,mBAAY,YAAY,CAAE,aAEtC,UAAU,IAAIC,aAAK,SAAS,EAAC,KAAK,YAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,OAAO,CAAC,GAAO,EAEhE,qBAAqB,CAAC,KAAK,CAAC,IAC3BD,yBACEC,WAAG,SAAS,EAAC,KAAK,YAAE,KAAK,CAAC,KAAK,GAAK,EACpCA,cAAM,SAAS,EAAC,oCAAoC,YACjD,KAAK,CAAC,WAAW,GACb,IACH,KAEN,KAAK,CACN,IACK,KAnCkC,YAAY,CAoClD,EACN;aACH,CAAC,IACO,EACX;AACJ;;;;"}
|
|
@@ -16,16 +16,19 @@ var story = {
|
|
|
16
16
|
value: {
|
|
17
17
|
description: 'Current checked values.',
|
|
18
18
|
},
|
|
19
|
+
fieldLegend: {
|
|
20
|
+
description: 'Accessibility property that describes the purpose of a group of checkbox buttons, read aloud by screen readers to provide context.',
|
|
21
|
+
},
|
|
19
22
|
onChange: {
|
|
20
23
|
description: 'Function called everytime a value changes.',
|
|
21
24
|
action: true,
|
|
22
25
|
table: {
|
|
23
|
-
category:
|
|
26
|
+
category: 'Callbacks',
|
|
24
27
|
},
|
|
25
28
|
},
|
|
26
29
|
wide: {
|
|
27
30
|
description: 'Property that defines if options should fill 100% of available horizontal space',
|
|
28
|
-
defaultValue: false
|
|
31
|
+
defaultValue: false,
|
|
29
32
|
},
|
|
30
33
|
bordered: {
|
|
31
34
|
control: 'boolean',
|
|
@@ -42,37 +45,38 @@ var story = {
|
|
|
42
45
|
options: {
|
|
43
46
|
CAT: {
|
|
44
47
|
title: 'Cat',
|
|
45
|
-
description: 'At least 1'
|
|
48
|
+
description: 'At least 1',
|
|
46
49
|
},
|
|
47
50
|
DOG: {
|
|
48
51
|
title: 'Dog',
|
|
49
|
-
description: 'At least 2'
|
|
52
|
+
description: 'At least 2',
|
|
50
53
|
},
|
|
51
54
|
NONE: {
|
|
52
55
|
title: 'None',
|
|
53
|
-
description: 'No pets'
|
|
54
|
-
}
|
|
56
|
+
description: 'No pets',
|
|
57
|
+
},
|
|
55
58
|
},
|
|
59
|
+
fieldLegend: 'Owned pets',
|
|
56
60
|
wide: false,
|
|
57
61
|
bordered: true,
|
|
58
62
|
inlineLayout: false,
|
|
59
63
|
classNames: {
|
|
60
64
|
container: '',
|
|
61
65
|
label: '',
|
|
62
|
-
option: ''
|
|
66
|
+
option: '',
|
|
63
67
|
},
|
|
64
68
|
value: [],
|
|
65
|
-
className: ''
|
|
66
|
-
}
|
|
69
|
+
className: '',
|
|
70
|
+
},
|
|
67
71
|
};
|
|
68
72
|
var CheckboxStory = function (_a) {
|
|
69
|
-
var onChange = _a.onChange, options = _a.options, wide = _a.wide, bordered = _a.bordered, classNames = _a.classNames, inlineLayout = _a.inlineLayout;
|
|
73
|
+
var onChange = _a.onChange, options = _a.options, wide = _a.wide, bordered = _a.bordered, classNames = _a.classNames, inlineLayout = _a.inlineLayout, fieldLegend = _a.fieldLegend;
|
|
70
74
|
var _b = useState([]), checkedValues = _b[0], setCheckedValues = _b[1];
|
|
71
75
|
var handleOnChange = function (newValue) {
|
|
72
76
|
setCheckedValues(newValue);
|
|
73
77
|
onChange(newValue);
|
|
74
78
|
};
|
|
75
|
-
return (jsx(Checkbox, { wide: wide, options: options, onChange: handleOnChange, value: checkedValues, bordered: bordered, classNames: classNames, inlineLayout: inlineLayout }));
|
|
79
|
+
return (jsx(Checkbox, { wide: wide, options: options, onChange: handleOnChange, value: checkedValues, bordered: bordered, classNames: classNames, inlineLayout: inlineLayout, fieldLegend: fieldLegend }));
|
|
76
80
|
};
|
|
77
81
|
var CheckboxWithCustomWrapperStyles = function (_a) {
|
|
78
82
|
var onChange = _a.onChange;
|
|
@@ -85,7 +89,7 @@ var CheckboxWithCustomWrapperStyles = function (_a) {
|
|
|
85
89
|
return (jsx(Checkbox, { onChange: handleOnChange, value: checkedValues, options: {
|
|
86
90
|
CAT1: 'Cat',
|
|
87
91
|
DOG1: 'Dog',
|
|
88
|
-
}, classNames: { container:
|
|
92
|
+
}, classNames: { container: 'p32 bg-primary-300 br24 bs-lg' } }));
|
|
89
93
|
};
|
|
90
94
|
var CheckboxWithCustomOptionStyles = function (_a) {
|
|
91
95
|
var onChange = _a.onChange;
|
|
@@ -98,7 +102,7 @@ var CheckboxWithCustomOptionStyles = function (_a) {
|
|
|
98
102
|
return (jsx(Checkbox, { onChange: handleOnChange, value: checkedValues, options: {
|
|
99
103
|
CAT2: 'Cat',
|
|
100
104
|
DOG2: 'Dog',
|
|
101
|
-
}, classNames: { option:
|
|
105
|
+
}, classNames: { option: 'mb32 p24 bg-green-100 br12 bs-lg' } }));
|
|
102
106
|
};
|
|
103
107
|
var CheckboxWithCustomLabelStyles = function (_a) {
|
|
104
108
|
var onChange = _a.onChange;
|
|
@@ -111,7 +115,7 @@ var CheckboxWithCustomLabelStyles = function (_a) {
|
|
|
111
115
|
return (jsx(Checkbox, { onChange: handleOnChange, value: checkedValues, options: {
|
|
112
116
|
CAT3: 'Cat',
|
|
113
117
|
DOG3: 'Dog',
|
|
114
|
-
}, classNames: { label:
|
|
118
|
+
}, classNames: { label: 'bg-grey-900 tc-white' } }));
|
|
115
119
|
};
|
|
116
120
|
var CheckboxWithInlineLayout = function (_a) {
|
|
117
121
|
var onChange = _a.onChange;
|
|
@@ -128,7 +132,7 @@ var CheckboxWithInlineLayout = function (_a) {
|
|
|
128
132
|
RABBIT: 'Rabbit',
|
|
129
133
|
RAT: 'Rat',
|
|
130
134
|
ANOTHER: 'Other',
|
|
131
|
-
}, classNames: { option:
|
|
135
|
+
}, classNames: { option: 'w30' }, inlineLayout: true, wide: true }));
|
|
132
136
|
};
|
|
133
137
|
var CheckboxWithCustomLabel = function (_a) {
|
|
134
138
|
var onChange = _a.onChange; _a.wide; _a.classNames; _a.inlineLayout;
|
|
@@ -140,18 +144,18 @@ var CheckboxWithCustomLabel = function (_a) {
|
|
|
140
144
|
};
|
|
141
145
|
return (jsx(Checkbox, { options: {
|
|
142
146
|
BIGDOG: {
|
|
143
|
-
icon: function () { return jsx("img", { src: images.bigDog, alt:
|
|
147
|
+
icon: function () { return jsx("img", { src: images.bigDog, alt: "" }); },
|
|
144
148
|
title: 'Dog',
|
|
145
149
|
},
|
|
146
150
|
FISH: {
|
|
147
|
-
icon: function () { return jsx("img", { src: images.brokenAquarium, alt:
|
|
151
|
+
icon: function () { return jsx("img", { src: images.brokenAquarium, alt: "" }); },
|
|
148
152
|
title: 'Fish',
|
|
149
153
|
},
|
|
150
154
|
OTHER: {
|
|
151
|
-
icon: function () { return jsx("img", { src: images.brokenGlass, alt:
|
|
155
|
+
icon: function () { return jsx("img", { src: images.brokenGlass, alt: "" }); },
|
|
152
156
|
title: 'Other',
|
|
153
|
-
}
|
|
154
|
-
}, onChange: handleOnChange, value: checkedValues, classNames: { option:
|
|
157
|
+
},
|
|
158
|
+
}, onChange: handleOnChange, value: checkedValues, classNames: { option: 'w30' }, inlineLayout: true }));
|
|
155
159
|
};
|
|
156
160
|
CheckboxStory.storyName = 'Checkbox';
|
|
157
161
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.stories.js","sources":["../../../../../../src/lib/components/input/checkbox/index.stories.tsx"],"sourcesContent":["\nimport { useState } from 'react';\nimport { Checkbox, CheckboxProps } from '.';\nimport { images } from '../../../util/images';\nimport classNames from 'classnames';\n\nconst story = {\n title: 'JSX/Inputs/Checkbox',\n component: Checkbox,\n argTypes: {\n options: {\n description: 'Object that contains the possible options for rendering in the input.',\n },\n value: {\n description: 'Current checked values.',\n },\n onChange: {\n description: 'Function called everytime a value changes.',\n action: true,\n table: {\n category: \"Callbacks\",\n },\n },\n wide: {\n description: 'Property that defines if options should fill 100% of available horizontal space',\n defaultValue: false\n },\n bordered: {\n control: 'boolean',\n description: 'Property that defines if checkbox should show the border around each label',\n },\n inlineLayout: {\n description: 'Property that defines if options should show inline instead of block. Check inline checkbox options story for examples.',\n },\n className: {\n description: 'ClassNames for custom styling',\n },\n },\n args: {\n options: {\n CAT:{\n title: 'Cat',\n description: 'At least 1'\n },\n DOG:{\n title: 'Dog',\n description: 'At least 2'\n },\n NONE:{\n title: 'None',\n description: 'No pets'\n }\n },\n wide: false,\n bordered: true,\n inlineLayout: false,\n classNames: {\n container: '',\n label: '',\n option: ''\n },\n value: [],\n className: ''\n }\n};\n\nexport const CheckboxStory = ({ \n onChange,\n options,\n wide,\n bordered,\n classNames,\n inlineLayout,\n}: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[]) => {\n setCheckedValues(newValue);\n onChange(newValue);\n }\n\n return (\n <Checkbox \n wide={wide}\n options={options} \n onChange={handleOnChange}\n value={checkedValues}\n bordered={bordered}\n classNames={classNames}\n inlineLayout={inlineLayout}\n />\n );\n}\n\nexport const CheckboxWithCustomWrapperStyles = ({ onChange }: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n }\n\n return (\n <Checkbox \n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT1: 'Cat',\n DOG1: 'Dog',\n }} \n classNames={{ container: \"p32 bg-primary-300 br24 bs-lg\" }}\n />\n );\n}\n\nexport const CheckboxWithCustomOptionStyles = ({ onChange }: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n }\n\n return (\n <Checkbox \n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT2: 'Cat',\n DOG2: 'Dog',\n }} \n classNames={{ option: \"mb32 p24 bg-green-100 br12 bs-lg\" }}\n />\n );\n}\n\nexport const CheckboxWithCustomLabelStyles = ({ onChange }: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n }\n\n return (\n <Checkbox \n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT3: 'Cat',\n DOG3: 'Dog',\n }} \n classNames={{ label: \"bg-grey-900 tc-white\" }}\n />\n );\n}\n\nexport const CheckboxWithInlineLayout = ({ onChange }: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n }\n\n return (\n <Checkbox \n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT4: 'Cat',\n DOG4: 'Dog',\n FISHER: 'Fish',\n RABBIT: 'Rabbit',\n RAT: 'Rat',\n ANOTHER: 'Other',\n }} \n classNames={{ option: \"w30\" }}\n inlineLayout\n wide\n />\n );\n}\n\nexport const CheckboxWithCustomLabel = ({ onChange, wide, classNames, inlineLayout }: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n }\n\n return (\n <Checkbox \n options={{\n BIGDOG: {\n icon: () => <img src={images.bigDog} alt='' />,\n title: 'Dog',\n },\n FISH:{\n icon: () => <img src={images.brokenAquarium} alt='' />,\n title: 'Fish',\n },\n OTHER:{\n icon: () => <img src={images.brokenGlass} alt='' />,\n title: 'Other',\n }\n }} \n onChange={handleOnChange}\n value={checkedValues}\n classNames={{ option: \"w30\" }}\n inlineLayout\n />\n );\n}\n\nCheckboxStory.storyName = 'Checkbox';\n\nexport default story;\n"],"names":["_jsx"],"mappings":";;;;;;;;IAMM,KAAK,GAAG;IAC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UAAU,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAC7B,YAAY,QACZ,IAAI,SACJ,EACF;AACJ,EAAC;IAEY,uBAAuB,GAAG,UAAC,EAAmE;QAAjE,QAAQ,cAAA,SAAM,eAAY;IAC5D,IAAA,KAAoC,QAAQ,CAAW,EAAE,CAAC,EAAzD,aAAa,QAAA,EAAE,gBAAgB,QAA0B,CAAC;IAEjE,IAAM,cAAc,GAAG,UAAC,QAAuB;QAAvB,yBAAA,EAAA,aAAuB;QAC7C,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC3B,QAAQ,CAAC,QAAQ,CAAC,CAAC;KACpB,CAAA;IAED,QACEA,IAAC,QAAQ,IACP,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,IAAI,EAAE,cAAM,OAAAA,aAAK,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAC,EAAE,GAAG,GAAA;gBAC9C,KAAK,EAAE,KAAK;aACb;YACD,IAAI,EAAC;gBACH,IAAI,EAAE,cAAM,OAAAA,aAAK,GAAG,EAAE,MAAM,CAAC,cAAc,EAAE,GAAG,EAAC,EAAE,GAAG,GAAA;gBACtD,KAAK,EAAE,MAAM;aACd;YACD,KAAK,EAAC;gBACJ,IAAI,EAAE,cAAM,OAAAA,aAAK,GAAG,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,EAAC,EAAE,GAAG,GAAA;gBACnD,KAAK,EAAE,OAAO;aACf;SACF,EACD,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAC7B,YAAY,SACZ,EACF;AACJ,EAAC;AAED,aAAa,CAAC,SAAS,GAAG,UAAU;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.stories.js","sources":["../../../../../../src/lib/components/input/checkbox/index.stories.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Checkbox, CheckboxProps } from '.';\nimport { images } from '../../../util/images';\nimport classNames from 'classnames';\n\nconst story = {\n title: 'JSX/Inputs/Checkbox',\n component: Checkbox,\n argTypes: {\n options: {\n description:\n 'Object that contains the possible options for rendering in the input.',\n },\n value: {\n description: 'Current checked values.',\n },\n fieldLegend: {\n description:\n 'Accessibility property that describes the purpose of a group of checkbox buttons, read aloud by screen readers to provide context.',\n },\n onChange: {\n description: 'Function called everytime a value changes.',\n action: true,\n table: {\n category: 'Callbacks',\n },\n },\n wide: {\n description:\n 'Property that defines if options should fill 100% of available horizontal space',\n defaultValue: false,\n },\n bordered: {\n control: 'boolean',\n description:\n 'Property that defines if checkbox should show the border around each label',\n },\n inlineLayout: {\n description:\n 'Property that defines if options should show inline instead of block. Check inline checkbox options story for examples.',\n },\n className: {\n description: 'ClassNames for custom styling',\n },\n },\n args: {\n options: {\n CAT: {\n title: 'Cat',\n description: 'At least 1',\n },\n DOG: {\n title: 'Dog',\n description: 'At least 2',\n },\n NONE: {\n title: 'None',\n description: 'No pets',\n },\n },\n fieldLegend: 'Owned pets',\n wide: false,\n bordered: true,\n inlineLayout: false,\n classNames: {\n container: '',\n label: '',\n option: '',\n },\n value: [],\n className: '',\n },\n};\n\nexport const CheckboxStory = ({\n onChange,\n options,\n wide,\n bordered,\n classNames,\n inlineLayout,\n fieldLegend,\n}: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[]) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Checkbox\n wide={wide}\n options={options}\n onChange={handleOnChange}\n value={checkedValues}\n bordered={bordered}\n classNames={classNames}\n inlineLayout={inlineLayout}\n fieldLegend={fieldLegend}\n />\n );\n};\n\nexport const CheckboxWithCustomWrapperStyles = ({\n onChange,\n}: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Checkbox\n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT1: 'Cat',\n DOG1: 'Dog',\n }}\n classNames={{ container: 'p32 bg-primary-300 br24 bs-lg' }}\n />\n );\n};\n\nexport const CheckboxWithCustomOptionStyles = ({\n onChange,\n}: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Checkbox\n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT2: 'Cat',\n DOG2: 'Dog',\n }}\n classNames={{ option: 'mb32 p24 bg-green-100 br12 bs-lg' }}\n />\n );\n};\n\nexport const CheckboxWithCustomLabelStyles = ({\n onChange,\n}: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Checkbox\n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT3: 'Cat',\n DOG3: 'Dog',\n }}\n classNames={{ label: 'bg-grey-900 tc-white' }}\n />\n );\n};\n\nexport const CheckboxWithInlineLayout = ({\n onChange,\n}: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Checkbox\n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT4: 'Cat',\n DOG4: 'Dog',\n FISHER: 'Fish',\n RABBIT: 'Rabbit',\n RAT: 'Rat',\n ANOTHER: 'Other',\n }}\n classNames={{ option: 'w30' }}\n inlineLayout\n wide\n />\n );\n};\n\nexport const CheckboxWithCustomLabel = ({\n onChange,\n wide,\n classNames,\n inlineLayout,\n}: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Checkbox\n options={{\n BIGDOG: {\n icon: () => <img src={images.bigDog} alt=\"\" />,\n title: 'Dog',\n },\n FISH: {\n icon: () => <img src={images.brokenAquarium} alt=\"\" />,\n title: 'Fish',\n },\n OTHER: {\n icon: () => <img src={images.brokenGlass} alt=\"\" />,\n title: 'Other',\n },\n }}\n onChange={handleOnChange}\n value={checkedValues}\n classNames={{ option: 'w30' }}\n inlineLayout\n />\n );\n};\n\nCheckboxStory.storyName = 'Checkbox';\n\nexport default story;\n"],"names":["_jsx"],"mappings":";;;;;;;;IAKM,KAAK,GAAG;IACZ,KAAK,EAAE,qBAAqB;IAC5B,SAAS,EAAE,QAAQ;IACnB,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,WAAW,EACT,uEAAuE;SAC1E;QACD,KAAK,EAAE;YACL,WAAW,EAAE,yBAAyB;SACvC;QACD,WAAW,EAAE;YACX,WAAW,EACT,oIAAoI;SACvI;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,4CAA4C;YACzD,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE;gBACL,QAAQ,EAAE,WAAW;aACtB;SACF;QACD,IAAI,EAAE;YACJ,WAAW,EACT,iFAAiF;YACnF,YAAY,EAAE,KAAK;SACpB;QACD,QAAQ,EAAE;YACR,OAAO,EAAE,SAAS;YAClB,WAAW,EACT,4EAA4E;SAC/E;QACD,YAAY,EAAE;YACZ,WAAW,EACT,yHAAyH;SAC5H;QACD,SAAS,EAAE;YACT,WAAW,EAAE,+BAA+B;SAC7C;KACF;IACD,IAAI,EAAE;QACJ,OAAO,EAAE;YACP,GAAG,EAAE;gBACH,KAAK,EAAE,KAAK;gBACZ,WAAW,EAAE,YAAY;aAC1B;YACD,GAAG,EAAE;gBACH,KAAK,EAAE,KAAK;gBACZ,WAAW,EAAE,YAAY;aAC1B;YACD,IAAI,EAAE;gBACJ,KAAK,EAAE,MAAM;gBACb,WAAW,EAAE,SAAS;aACvB;SACF;QACD,WAAW,EAAE,YAAY;QACzB,IAAI,EAA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;gBACL,IAAI,EAAE,cAAM,OAAAA,aAAK,GAAG,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,EAAC,EAAE,GAAG,GAAA;gBACnD,KAAK,EAAE,OAAO;aACf;SACF,EACD,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAC7B,YAAY,SACZ,EACF;AACJ,EAAE;AAEF,aAAa,CAAC,SAAS,GAAG,UAAU;;;;;"}
|
|
@@ -21,7 +21,7 @@ var Input = React__default.forwardRef(function (_a, ref) {
|
|
|
21
21
|
: styles['input--no-placeholder'], (_c = {},
|
|
22
22
|
_c[styles['input--with-prefix']] = prefix,
|
|
23
23
|
_c[styles['input--with-inside-label']] = labelInsideInput,
|
|
24
|
-
_c)), placeholder: label || labelInsideInput ? placeholder : ' ', disabled: disabled }, props)), prefix && (jsx("span", { className: classNames(styles.prefix, (_d = {}, _d[styles['prefix--with-error']] = error, _d), (_e = {}, _e[styles['prefix--disabled']] = disabled, _e)), children: prefix })), (!label || labelInsideInput) && (jsx("label", { htmlFor: uniqueId, className: classNames(styles.placeholder, (_f = {}, _f[styles['placeholder--with-prefix']] = prefix, _f), (_g = {}, _g[styles['placeholder--with-error']] = error, _g)), children: labelInsideInput ? label : placeholder }))] }), error && (jsx("p", { className: "p-p--small tc-red-500 w100 ".concat(styles.error), children: error }))] }));
|
|
24
|
+
_c)), placeholder: label || labelInsideInput ? placeholder : ' ', disabled: disabled, "aria-invalid": !!error, "aria-errormessage": error ? error : undefined }, props)), prefix && (jsx("span", { className: classNames(styles.prefix, (_d = {}, _d[styles['prefix--with-error']] = error, _d), (_e = {}, _e[styles['prefix--disabled']] = disabled, _e)), children: prefix })), (!label || labelInsideInput) && (jsx("label", { htmlFor: uniqueId, className: classNames(styles.placeholder, (_f = {}, _f[styles['placeholder--with-prefix']] = prefix, _f), (_g = {}, _g[styles['placeholder--with-error']] = error, _g)), children: labelInsideInput ? label : placeholder }))] }), error && (jsx("p", { className: "p-p--small tc-red-500 w100 ".concat(styles.error), children: error }))] }));
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
export { Input };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/lib/components/input/index.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport classnames from 'classnames';\nimport generateId from '../../util/generateId';\n\nimport styles from './style.module.scss';\n\n// Something weird is going on with enterKeyHint that makes it a required field under certain circumstances. The & Omit<…> and & Pick<…> is a hacky way to go around that.\nexport type InputProps = Omit<JSX.IntrinsicElements['input'], 'enterKeyHint'> &\n Partial<Pick<JSX.IntrinsicElements['input'], 'enterKeyHint'>> & {\n error?: string | boolean;\n prefix?: string;\n label?: string;\n id?: string;\n hideLabel?: boolean;\n labelInsideInput?: boolean;\n};\n\nexport const Input = React.forwardRef(\n (\n {\n className,\n placeholder,\n label,\n id,\n prefix,\n error,\n disabled,\n hideLabel = false,\n labelInsideInput = false,\n ...props\n }: InputProps,\n ref?: React.ForwardedRef<HTMLInputElement>\n ) => {\n const [uniqueId] = useState(id ?? generateId());\n\n return (\n <div className={`${styles.container} ${className ?? ''}`}>\n {label && !labelInsideInput && (\n <label\n htmlFor={uniqueId}\n className={classnames('p-p', styles.label, {\n [styles['label--with-error']]: error,\n 'sr-only': hideLabel,\n })}\n >\n {label}\n </label>\n )}\n <div style={{ position: 'relative' }}>\n <input\n id={uniqueId}\n data-testid=\"ds-input-input\"\n type=\"text\"\n ref={ref}\n className={classnames(\n error ? 'p-input--error' : 'p-input',\n (!label || labelInsideInput) && placeholder && placeholder.length > 0\n ? styles.input\n : styles['input--no-placeholder'],\n {\n [styles['input--with-prefix']]: prefix, \n [styles['input--with-inside-label']]: labelInsideInput\n }\n )}\n placeholder={label || labelInsideInput ? placeholder : ' '}\n disabled={disabled}\n {...props}\n />\n {prefix && (\n <span\n className={classnames(\n styles.prefix,\n { [styles['prefix--with-error']]: error },\n { [styles['prefix--disabled']]: disabled }\n )}\n >\n {prefix}\n </span>\n )}\n {(!label || labelInsideInput) && (\n <label\n htmlFor={uniqueId}\n className={classnames(\n styles.placeholder,\n { [styles['placeholder--with-prefix']]: prefix },\n { [styles['placeholder--with-error']]: error }\n )}\n >\n {labelInsideInput ? label : placeholder}\n </label>\n )}\n </div>\n {error && (\n <p className={`p-p--small tc-red-500 w100 ${styles.error}`}>\n {error}\n </p>\n )}\n </div>\n );\n }\n);\n"],"names":["React","_jsxs","_jsx","classnames"],"mappings":";;;;;;;;;;;IAiBa,KAAK,GAAGA,cAAK,CAAC,UAAU,CACnC,UACE,EAWa,EACb,GAA0C;;IAXxC,IAAA,SAAS,eAAA,EACT,WAAW,iBAAA,EACX,KAAK,WAAA,EACL,EAAE,QAAA,EACF,MAAM,YAAA,EACN,KAAK,WAAA,EACL,QAAQ,cAAA,EACR,iBAAiB,EAAjB,SAAS,mBAAG,KAAK,KAAA,EACjB,wBAAwB,EAAxB,gBAAgB,mBAAG,KAAK,KAAA,EACrB,KAAK,cAVV,2GAWC,CADS;IAIH,IAAA,QAAQ,GAAI,QAAQ,CAAC,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,UAAU,EAAE,CAAC,GAAhC,CAAiC;IAEhD,QACEC,cAAK,SAAS,EAAE,UAAG,MAAM,CAAC,SAAS,cAAI,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAE,aACrD,KAAK,IAAI,CAAC,gBAAgB,KACzBC,eACE,OAAO,EAAE,QAAQ,EACjB,SAAS,EAAEC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK;oBACvC,GAAC,MAAM,CAAC,mBAAmB,CAAC,IAAG,KAAK;oBACpC,aAAS,GAAE,SAAS;wBACpB,YAED,KAAK,GACA,CACT,EACDF,cAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,aAClCC,wBACE,EAAE,EAAE,QAAQ,iBACA,gBAAgB,EAC5B,IAAI,EAAC,MAAM,EACX,GAAG,EAAE,GAAG,EACR,SAAS,EAAEC,UAAU,CACnB,KAAK,GAAG,gBAAgB,GAAG,SAAS,EACpC,CAAC,CAAC,KAAK,IAAI,gBAAgB,KAAK,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;8BACjE,MAAM,CAAC,KAAK;8BACZ,MAAM,CAAC,uBAAuB,CAAC;4BAEjC,GAAC,MAAM,CAAC,oBAAoB,CAAC,IAAG,MAAM;4BACtC,GAAC,MAAM,CAAC,0BAA0B,CAAC,IAAG,gBAAgB;gCAEzD,EACD,WAAW,EAAE,KAAK,IAAI,gBAAgB,GAAG,WAAW,GAAG,GAAG,EAC1D,QAAQ,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/lib/components/input/index.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport classnames from 'classnames';\nimport generateId from '../../util/generateId';\n\nimport styles from './style.module.scss';\n\n// Something weird is going on with enterKeyHint that makes it a required field under certain circumstances. The & Omit<…> and & Pick<…> is a hacky way to go around that.\nexport type InputProps = Omit<JSX.IntrinsicElements['input'], 'enterKeyHint'> &\n Partial<Pick<JSX.IntrinsicElements['input'], 'enterKeyHint'>> & {\n error?: string | boolean;\n prefix?: string;\n label?: string;\n id?: string;\n hideLabel?: boolean;\n labelInsideInput?: boolean;\n};\n\nexport const Input = React.forwardRef(\n (\n {\n className,\n placeholder,\n label,\n id,\n prefix,\n error,\n disabled,\n hideLabel = false,\n labelInsideInput = false,\n ...props\n }: InputProps,\n ref?: React.ForwardedRef<HTMLInputElement>\n ) => {\n const [uniqueId] = useState(id ?? generateId());\n\n return (\n <div className={`${styles.container} ${className ?? ''}`}>\n {label && !labelInsideInput && (\n <label\n htmlFor={uniqueId}\n className={classnames('p-p', styles.label, {\n [styles['label--with-error']]: error,\n 'sr-only': hideLabel,\n })}\n >\n {label}\n </label>\n )}\n <div style={{ position: 'relative' }}>\n <input\n id={uniqueId}\n data-testid=\"ds-input-input\"\n type=\"text\"\n ref={ref}\n className={classnames(\n error ? 'p-input--error' : 'p-input',\n (!label || labelInsideInput) && placeholder && placeholder.length > 0\n ? styles.input\n : styles['input--no-placeholder'],\n {\n [styles['input--with-prefix']]: prefix, \n [styles['input--with-inside-label']]: labelInsideInput\n }\n )}\n placeholder={label || labelInsideInput ? placeholder : ' '}\n disabled={disabled}\n aria-invalid={!!error}\n aria-errormessage={error ? error : undefined}\n {...props}\n />\n {prefix && (\n <span\n className={classnames(\n styles.prefix,\n { [styles['prefix--with-error']]: error },\n { [styles['prefix--disabled']]: disabled }\n )}\n >\n {prefix}\n </span>\n )}\n {(!label || labelInsideInput) && (\n <label\n htmlFor={uniqueId}\n className={classnames(\n styles.placeholder,\n { [styles['placeholder--with-prefix']]: prefix },\n { [styles['placeholder--with-error']]: error }\n )}\n >\n {labelInsideInput ? label : placeholder}\n </label>\n )}\n </div>\n {error && (\n <p className={`p-p--small tc-red-500 w100 ${styles.error}`}>\n {error}\n </p>\n )}\n </div>\n );\n }\n);\n"],"names":["React","_jsxs","_jsx","classnames"],"mappings":";;;;;;;;;;;IAiBa,KAAK,GAAGA,cAAK,CAAC,UAAU,CACnC,UACE,EAWa,EACb,GAA0C;;IAXxC,IAAA,SAAS,eAAA,EACT,WAAW,iBAAA,EACX,KAAK,WAAA,EACL,EAAE,QAAA,EACF,MAAM,YAAA,EACN,KAAK,WAAA,EACL,QAAQ,cAAA,EACR,iBAAiB,EAAjB,SAAS,mBAAG,KAAK,KAAA,EACjB,wBAAwB,EAAxB,gBAAgB,mBAAG,KAAK,KAAA,EACrB,KAAK,cAVV,2GAWC,CADS;IAIH,IAAA,QAAQ,GAAI,QAAQ,CAAC,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,UAAU,EAAE,CAAC,GAAhC,CAAiC;IAEhD,QACEC,cAAK,SAAS,EAAE,UAAG,MAAM,CAAC,SAAS,cAAI,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAE,aACrD,KAAK,I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