@popsure/dirty-swan 0.32.0 → 0.33.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/cjs/index.d.ts +1 -1
  2. package/dist/cjs/index.js +62 -14
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/lib/components/downloadButton/index.d.ts +3 -3
  5. package/dist/cjs/lib/components/downloadButton/index.stories.d.ts +36 -0
  6. package/dist/cjs/lib/components/input/checkbox/index.d.ts +17 -0
  7. package/dist/cjs/lib/components/input/checkbox/index.stories.d.ts +64 -0
  8. package/dist/cjs/lib/components/input/checkbox/index.test.d.ts +1 -0
  9. package/dist/cjs/lib/components/markdown/index.d.ts +9 -8
  10. package/dist/cjs/lib/components/markdown/index.stories.d.ts +44 -0
  11. package/dist/cjs/lib/components/signaturePad/index.d.ts +4 -4
  12. package/dist/cjs/lib/components/signaturePad/index.stories.d.ts +21 -0
  13. package/dist/cjs/lib/index.d.ts +5 -4
  14. package/dist/esm/components/downloadButton/index.js +1 -1
  15. package/dist/esm/components/downloadButton/index.js.map +1 -1
  16. package/dist/esm/components/downloadButton/index.stories.js +47 -0
  17. package/dist/esm/components/downloadButton/index.stories.js.map +1 -0
  18. package/dist/esm/components/input/checkbox/index.js +53 -0
  19. package/dist/esm/components/input/checkbox/index.js.map +1 -0
  20. package/dist/esm/components/input/checkbox/index.stories.js +153 -0
  21. package/dist/esm/components/input/checkbox/index.stories.js.map +1 -0
  22. package/dist/esm/components/input/checkbox/index.test.js +105 -0
  23. package/dist/esm/components/input/checkbox/index.test.js.map +1 -0
  24. package/dist/esm/components/markdown/index.js +1 -1
  25. package/dist/esm/components/markdown/index.js.map +1 -1
  26. package/dist/esm/components/markdown/index.stories.js +66 -0
  27. package/dist/esm/components/markdown/index.stories.js.map +1 -0
  28. package/dist/esm/components/signaturePad/index.js +14 -14
  29. package/dist/esm/components/signaturePad/index.js.map +1 -1
  30. package/dist/esm/components/signaturePad/index.stories.js +33 -0
  31. package/dist/esm/components/signaturePad/index.stories.js.map +1 -0
  32. package/dist/esm/index.d.ts +1 -1
  33. package/dist/esm/index.js +4 -3
  34. package/dist/esm/index.js.map +1 -1
  35. package/dist/esm/lib/components/downloadButton/index.d.ts +3 -3
  36. package/dist/esm/lib/components/downloadButton/index.stories.d.ts +36 -0
  37. package/dist/esm/lib/components/input/checkbox/index.d.ts +17 -0
  38. package/dist/esm/lib/components/input/checkbox/index.stories.d.ts +64 -0
  39. package/dist/esm/lib/components/input/checkbox/index.test.d.ts +1 -0
  40. package/dist/esm/lib/components/markdown/index.d.ts +9 -8
  41. package/dist/esm/lib/components/markdown/index.stories.d.ts +44 -0
  42. package/dist/esm/lib/components/signaturePad/index.d.ts +4 -4
  43. package/dist/esm/lib/components/signaturePad/index.stories.d.ts +21 -0
  44. package/dist/esm/lib/index.d.ts +5 -4
  45. package/dist/index.css +4 -0
  46. package/dist/index.css.map +1 -1
  47. package/dist/lib/scss/private/components/_input.scss +4 -0
  48. package/package.json +1 -1
  49. package/src/App.tsx +1 -1
  50. package/src/index.tsx +1 -0
  51. package/src/lib/components/downloadButton/index.stories.tsx +58 -0
  52. package/src/lib/components/downloadButton/index.tsx +3 -3
  53. package/src/lib/components/input/checkbox/index.stories.tsx +214 -0
  54. package/src/lib/components/input/checkbox/index.test.tsx +110 -0
  55. package/src/lib/components/input/checkbox/index.tsx +129 -0
  56. package/src/lib/components/markdown/index.stories.tsx +131 -0
  57. package/src/lib/components/markdown/index.tsx +11 -9
  58. package/src/lib/components/signaturePad/index.stories.tsx +35 -0
  59. package/src/lib/components/signaturePad/index.tsx +6 -6
  60. package/src/lib/index.tsx +5 -3
  61. package/src/lib/scss/private/components/_input.scss +4 -0
  62. package/src/lib/components/downloadButton/index.stories.mdx +0 -59
  63. package/src/lib/components/markdown/example.md +0 -78
  64. package/src/lib/components/markdown/index.stories.mdx +0 -22
  65. package/src/lib/components/signaturePad/index.stories.mdx +0 -17
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { DownloadStatus } from '../../models/download';
3
- interface Props {
3
+ export interface DownloadButtonProps {
4
4
  downloadStatus: DownloadStatus;
5
5
  onDownload: () => void;
6
6
  className?: string;
7
7
  customFail?: React.ReactNode;
8
8
  }
9
- declare const DownloadButton: ({ downloadStatus, onDownload, className, customFail, }: Props) => JSX.Element;
10
- export default DownloadButton;
9
+ declare const DownloadButton: ({ downloadStatus, onDownload, className, customFail, }: DownloadButtonProps) => JSX.Element;
10
+ export { DownloadButton };
@@ -0,0 +1,36 @@
1
+ import { DownloadButtonProps } from '.';
2
+ declare const story: {
3
+ title: string;
4
+ component: ({ downloadStatus, onDownload, className, customFail, }: DownloadButtonProps) => JSX.Element;
5
+ argTypes: {
6
+ downloadStatus: {
7
+ description: string;
8
+ defaultValue: string;
9
+ };
10
+ customFail: {
11
+ description: string;
12
+ control: {
13
+ type: string;
14
+ };
15
+ };
16
+ onDownload: {
17
+ description: string;
18
+ action: boolean;
19
+ table: {
20
+ category: string;
21
+ };
22
+ };
23
+ className: {
24
+ description: string;
25
+ };
26
+ };
27
+ parameters: {
28
+ componentSubtitle: string;
29
+ };
30
+ };
31
+ export declare const DownloadButtonStory: {
32
+ ({ downloadStatus, onDownload, className, customFail }: DownloadButtonProps): JSX.Element;
33
+ storyName: string;
34
+ };
35
+ export declare const CustomErrorMessage: ({ onDownload, }: DownloadButtonProps) => JSX.Element;
36
+ export default story;
@@ -0,0 +1,17 @@
1
+ import { ReactNode } from "react";
2
+ export interface CheckboxWithDescription {
3
+ title: string;
4
+ description?: string;
5
+ icon?: (selected: boolean) => ReactNode;
6
+ }
7
+ export interface CheckboxProps<ValueType extends string> {
8
+ options: Record<ValueType, string | CheckboxWithDescription>;
9
+ value?: ValueType[];
10
+ onChange: (value: ValueType[]) => void;
11
+ wide?: boolean;
12
+ inlineLayout?: boolean;
13
+ className?: string;
14
+ labelClassName?: string;
15
+ optionClassName?: string;
16
+ }
17
+ export declare const Checkbox: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, className, labelClassName, optionClassName, }: CheckboxProps<ValueType>) => JSX.Element;
@@ -0,0 +1,64 @@
1
+ import { CheckboxProps } from '.';
2
+ declare const story: {
3
+ title: string;
4
+ component: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, className, labelClassName, optionClassName, }: CheckboxProps<ValueType>) => JSX.Element;
5
+ argTypes: {
6
+ options: {
7
+ description: string;
8
+ defaultValue: {
9
+ CAT: {
10
+ title: string;
11
+ description: string;
12
+ };
13
+ DOG: {
14
+ title: string;
15
+ description: string;
16
+ };
17
+ NONE: {
18
+ title: string;
19
+ description: string;
20
+ };
21
+ };
22
+ };
23
+ value: {
24
+ description: string;
25
+ };
26
+ onChange: {
27
+ description: string;
28
+ action: boolean;
29
+ table: {
30
+ category: string;
31
+ };
32
+ };
33
+ wide: {
34
+ description: string;
35
+ defaultValue: boolean;
36
+ };
37
+ inlineLayout: {
38
+ description: string;
39
+ defaultValue: boolean;
40
+ };
41
+ className: {
42
+ description: string;
43
+ defaultValue: string;
44
+ };
45
+ optionClassName: {
46
+ description: string;
47
+ defaultValue: string;
48
+ };
49
+ labelClassName: {
50
+ description: string;
51
+ defaultValue: string;
52
+ };
53
+ };
54
+ };
55
+ export declare const CheckboxStory: {
56
+ ({ onChange, options, wide, className, optionClassName, labelClassName, inlineLayout, }: CheckboxProps<string>): JSX.Element;
57
+ storyName: string;
58
+ };
59
+ export declare const CheckboxWithCustomWrapperStyles: ({ onChange }: CheckboxProps<string>) => JSX.Element;
60
+ export declare const CheckboxWithCustomOptionStyles: ({ onChange }: CheckboxProps<string>) => JSX.Element;
61
+ export declare const CheckboxWithCustomLabelStyles: ({ onChange }: CheckboxProps<string>) => JSX.Element;
62
+ export declare const CheckboxWithInlineLayout: ({ onChange }: CheckboxProps<string>) => JSX.Element;
63
+ export declare const CheckboxWithCustomLabel: ({ onChange, wide, className, optionClassName, inlineLayout }: CheckboxProps<string>) => JSX.Element;
64
+ export default story;
@@ -1,9 +1,10 @@
1
- import React, { FunctionComponent } from 'react';
2
- declare const Markdown: ({ children, customMDComponents, className, openLinksInNewTab, paragraphClassName, }: {
1
+ import { FunctionComponent } from 'react';
2
+ export interface MarkdownProps {
3
3
  children: string;
4
- customMDComponents?: Record<string, React.FunctionComponent<any>> | undefined;
5
- className?: string | undefined;
6
- openLinksInNewTab?: boolean | undefined;
7
- paragraphClassName?: string | undefined;
8
- }) => JSX.Element;
9
- export default Markdown;
4
+ customMDComponents?: Record<string, FunctionComponent<any>>;
5
+ className?: string;
6
+ openLinksInNewTab?: boolean;
7
+ paragraphClassName?: string;
8
+ }
9
+ declare const Markdown: ({ children, customMDComponents, className, openLinksInNewTab, paragraphClassName, }: MarkdownProps) => JSX.Element;
10
+ export { Markdown };
@@ -0,0 +1,44 @@
1
+ import { MarkdownProps } from '.';
2
+ declare const story: {
3
+ title: string;
4
+ component: ({ children, customMDComponents, className, openLinksInNewTab, paragraphClassName, }: MarkdownProps) => JSX.Element;
5
+ argTypes: {
6
+ children: {
7
+ description: string;
8
+ };
9
+ className: {
10
+ defaultValue: string;
11
+ description: string;
12
+ };
13
+ customMDComponents: {
14
+ defaultValue: {};
15
+ description: string;
16
+ table: {
17
+ type: {
18
+ summary: string;
19
+ };
20
+ };
21
+ };
22
+ paragraphClassName: {
23
+ defaultValue: string;
24
+ description: string;
25
+ };
26
+ openLinksInNewTab: {
27
+ defaultValue: boolean;
28
+ description: string;
29
+ };
30
+ };
31
+ args: {
32
+ children: string;
33
+ };
34
+ parameters: {
35
+ componentSubtitle: JSX.Element;
36
+ };
37
+ };
38
+ export declare const MarkdownStory: {
39
+ ({ children, className }: MarkdownProps): JSX.Element;
40
+ storyName: string;
41
+ };
42
+ export declare const AvailableMDComponents: ({ className }: MarkdownProps) => JSX.Element;
43
+ export declare const AddingCustomComponents: ({ className }: MarkdownProps) => JSX.Element;
44
+ export default story;
@@ -1,19 +1,19 @@
1
1
  import { Component } from 'react';
2
- interface Props {
2
+ export interface SignaturePadProps {
3
3
  onChange: (base64signature: string) => void;
4
4
  }
5
5
  interface State {
6
6
  hasContent: boolean;
7
7
  }
8
- declare class Signature extends Component<Props, State> {
8
+ declare class SignaturePad extends Component<SignaturePadProps, State> {
9
9
  private canvasRef;
10
10
  private canvas;
11
11
  private signaturePad;
12
- constructor(props: Props);
12
+ constructor(props: SignaturePadProps);
13
13
  componentDidMount(): void;
14
14
  render(): JSX.Element;
15
15
  private notifyOnChange;
16
16
  private resizeCanvas;
17
17
  private clear;
18
18
  }
19
- export default Signature;
19
+ export { SignaturePad };
@@ -0,0 +1,21 @@
1
+ import { SignaturePad, SignaturePadProps } from '.';
2
+ declare const story: {
3
+ title: string;
4
+ component: typeof SignaturePad;
5
+ argTypes: {
6
+ onChange: {
7
+ action: boolean;
8
+ table: {
9
+ category: string;
10
+ };
11
+ };
12
+ };
13
+ parameters: {
14
+ componentSubtitle: string;
15
+ };
16
+ };
17
+ export declare const SignaturePadStory: {
18
+ ({ onChange, }: SignaturePadProps): JSX.Element;
19
+ storyName: string;
20
+ };
21
+ export default story;
@@ -1,11 +1,12 @@
1
1
  import DateSelector from './components/dateSelector';
2
- import SignaturePad from './components/signaturePad';
2
+ import { SignaturePad } from './components/signaturePad';
3
3
  import { AutocompleteAddress } from './components/autocompleteAddress';
4
4
  import Input from './components/input';
5
5
  import MultiDropzone, { FileType, MultiDropzoneProps, UploadedFile, UploadStatus } from './components/multiDropzone';
6
- import DownloadButton from './components/downloadButton';
6
+ import { DownloadButton } from './components/downloadButton';
7
7
  import IbanInput from './components/input/iban';
8
8
  import CurrencyInput from './components/input/currency';
9
+ import { Checkbox } from './components/input/checkbox';
9
10
  import { BottomModal, RegularModal, BottomOrRegularModal } from './components/modal';
10
11
  import { CardWithTopLeftIcon, CardWithLeftIcon, CardWithTopIcon, InfoCard, CardButton } from './components/cards';
11
12
  import Button from './components/button';
@@ -14,8 +15,8 @@ import Chip from './components/chip';
14
15
  import AutoSuggestInput from './components/input/autoSuggestInput';
15
16
  import { ComparisonTable, TableRating, TableTrueFalse, TableRowHeader, TableButton, TableInfoButton, TableHeader } from './components/comparisonTable';
16
17
  import { SegmentedControl } from './components/segmentedControl';
17
- import Markdown from './components/markdown';
18
+ import { Markdown } from './components/markdown';
18
19
  import { images } from './util/images';
19
- export { DateSelector, SignaturePad, AutocompleteAddress, Input, MultiDropzone, DownloadButton, IbanInput, BottomModal, RegularModal, BottomOrRegularModal, CardWithTopLeftIcon, CardWithLeftIcon, CardWithTopIcon, InfoCard, CardButton, Button, CurrencyInput, AutoSuggestMultiSelect, Chip, AutoSuggestInput, ComparisonTable, TableRating, TableTrueFalse, TableRowHeader, TableButton, TableInfoButton, SegmentedControl, Markdown, images, };
20
+ export { DateSelector, SignaturePad, AutocompleteAddress, Input, MultiDropzone, DownloadButton, IbanInput, BottomModal, RegularModal, BottomOrRegularModal, CardWithTopLeftIcon, CardWithLeftIcon, CardWithTopIcon, InfoCard, CardButton, Button, CurrencyInput, AutoSuggestMultiSelect, Chip, AutoSuggestInput, ComparisonTable, TableRating, TableTrueFalse, TableRowHeader, TableButton, TableInfoButton, SegmentedControl, Markdown, Checkbox, images, };
20
21
  export type { FileType, MultiDropzoneProps, TableHeader, UploadedFile, UploadStatus };
21
22
  export type { DownloadStatus } from './models/download';
@@ -32,5 +32,5 @@ var DownloadButton = function (_a) {
32
32
  downloadStatus === 'FAILED' && (jsx("div", __assign({ className: "p-notice p-notice--danger p-p mt40 wmx5" }, { children: customFail !== null && customFail !== void 0 ? customFail : 'An error occured when generating documents. Please try again or contact us.' }), void 0))] }), void 0));
33
33
  };
34
34
 
35
- export default DownloadButton;
35
+ export { DownloadButton };
36
36
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/lib/components/downloadButton/icons/check.svg","../../../../src/lib/components/downloadButton/icons/download.svg","../../../../../src/lib/components/downloadButton/index.tsx"],"sourcesContent":["export default \"data:image/svg+xml,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2020%2020%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M16.6666%205.83203L7.49992%2014.9987L3.33325%2010.832%22%20stroke%3D%22%23B4B4BA%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E\"","export default \"data:image/svg+xml,%3Csvg%20width%3D%2221%22%20height%3D%2220%22%20viewBox%3D%220%200%2021%2020%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M18%2012.5V15.8333C18%2016.2754%2017.8244%2016.6993%2017.5118%2017.0118C17.1993%2017.3244%2016.7754%2017.5%2016.3333%2017.5H4.66667C4.22464%2017.5%203.80072%2017.3244%203.48816%2017.0118C3.17559%2016.6993%203%2016.2754%203%2015.8333V12.5%22%20stroke%3D%22white%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3Cpath%20d%3D%22M6.33325%208.33301L10.4999%2012.4997L14.6666%208.33301%22%20stroke%3D%22white%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3Cpath%20d%3D%22M10.5%2012.5V2.5%22%20stroke%3D%22white%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E\"","import Button from '../button';\nimport { DownloadStatus } from '../../models/download';\n\nimport checkIcon from './icons/check.svg';\nimport downloadIcon from './icons/download.svg';\nimport styles from './style.module.scss';\n\ninterface Props {\n downloadStatus: DownloadStatus;\n onDownload: () => void;\n className?: string;\n customFail?: React.ReactNode;\n}\n\nconst InitialButton = ({ onDownload }: { onDownload: () => void }) => (\n <Button\n className={`w100 ${styles.button}`}\n buttonTitle=\"Download\"\n leftIcon={{ src: downloadIcon, alt: 'download arrow icon' }}\n onClick={onDownload}\n data-cy=\"download-documents-button\"\n />\n);\n\n// TODO: Allow setting loading to true to display text\nconst GeneratingButton = () => (\n <Button\n className={`w100 ${styles.button}`}\n buttonTitle=\"Generating\"\n loading={true}\n />\n);\n\nconst CompletedChip = () => (\n <div className={styles['chip-complete']}>\n <img src={checkIcon} alt=\"grey check\" />\n <div className=\"p-h4 tc-grey-500 ml8\">Download complete</div>\n </div>\n);\n\nconst DownloadButton = ({\n downloadStatus,\n onDownload,\n className = '',\n customFail,\n}: Props) => {\n const mapDownloadButton: { [K in DownloadStatus]: React.ReactNode } = {\n INITIAL: <InitialButton onDownload={onDownload} />,\n GENERATING: <GeneratingButton />,\n COMPLETED: <CompletedChip />,\n FAILED: <InitialButton onDownload={onDownload} />,\n };\n\n return (\n <div className={`d-flex fd-column ai-center ${className}`}>\n <div className=\"ws4\">{mapDownloadButton[downloadStatus]}</div>\n {downloadStatus === 'FAILED' && (\n <div className=\"p-notice p-notice--danger p-p mt40 wmx5\">\n {customFail ??\n 'An error occured when generating documents. Please try again or contact us.'}\n </div>\n )}\n </div>\n );\n};\n\nexport default DownloadButton;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;AAAA,gBAAe;;ACAf,mBAAe;;;;;;ACcf,IAAM,aAAa,GAAG,UAAC,EAA0C;QAAxC,UAAU,gBAAA;IAAmC,QACpEA,IAAC,MAAM,IACL,SAAS,EAAE,UAAQ,MAAM,CAAC,MAAQ,EAClC,WAAW,EAAC,UAAU,EACtB,QAAQ,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,qBAAqB,EAAE,EAC3D,OAAO,EAAE,UAAU,aACX,2BAA2B,WACnC;AAPkE,CAQrE,CAAC;AAEF;AACA,IAAM,gBAAgB,GAAG,cAAM,QAC7BA,IAAC,MAAM,IACL,SAAS,EAAE,UAAQ,MAAM,CAAC,MAAQ,EAClC,WAAW,EAAC,YAAY,EACxB,OAAO,EAAE,IAAI,WACb,IACH,CAAC;AAEF,IAAM,aAAa,GAAG,cAAM,QAC1BC,uBAAK,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,iBACrCD,aAAK,GAAG,EAAE,SAAS,EAAE,GAAG,EAAC,YAAY,WAAG;QACxCA,sBAAK,SAAS,EAAC,sBAAsB,+CAAwB,aACzD,IACP,CAAC;IAEI,cAAc,GAAG,UAAC,EAKhB;QAJN,cAAc,oBAAA,EACd,UAAU,gBAAA,EACV,iBAAc,EAAd,SAAS,mBAAG,EAAE,KAAA,EACd,UAAU,gBAAA;IAEV,IAAM,iBAAiB,GAA+C;QACpE,OAAO,EAAEA,IAAC,aAAa,IAAC,UAAU,EAAE,UAAU,WAAI;QAClD,UAAU,EAAEA,IAAC,gBAAgB,aAAG;QAChC,SAAS,EAAEA,IAAC,aAAa,aAAG;QAC5B,MAAM,EAAEA,IAAC,aAAa,IAAC,UAAU,EAAE,UAAU,WAAI;KAClD,CAAC;IAEF,QACEC,uBAAK,SAAS,EAAE,gCAA8B,SAAW,iBACvDD,sBAAK,SAAS,EAAC,KAAK,gBAAE,iBAAiB,CAAC,cAAc,CAAC,YAAO;YAC7D,cAAc,KAAK,QAAQ,KAC1BA,sBAAK,SAAS,EAAC,yCAAyC,gBACrD,UAAU,aAAV,UAAU,cAAV,UAAU,GACT,6EAA6E,YAC3E,CACP,aACG,EACN;AACJ;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/lib/components/downloadButton/icons/check.svg","../../../../src/lib/components/downloadButton/icons/download.svg","../../../../../src/lib/components/downloadButton/index.tsx"],"sourcesContent":["export default \"data:image/svg+xml,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2020%2020%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M16.6666%205.83203L7.49992%2014.9987L3.33325%2010.832%22%20stroke%3D%22%23B4B4BA%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E\"","export default \"data:image/svg+xml,%3Csvg%20width%3D%2221%22%20height%3D%2220%22%20viewBox%3D%220%200%2021%2020%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M18%2012.5V15.8333C18%2016.2754%2017.8244%2016.6993%2017.5118%2017.0118C17.1993%2017.3244%2016.7754%2017.5%2016.3333%2017.5H4.66667C4.22464%2017.5%203.80072%2017.3244%203.48816%2017.0118C3.17559%2016.6993%203%2016.2754%203%2015.8333V12.5%22%20stroke%3D%22white%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3Cpath%20d%3D%22M6.33325%208.33301L10.4999%2012.4997L14.6666%208.33301%22%20stroke%3D%22white%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3Cpath%20d%3D%22M10.5%2012.5V2.5%22%20stroke%3D%22white%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E\"","import Button from '../button';\nimport { DownloadStatus } from '../../models/download';\n\nimport checkIcon from './icons/check.svg';\nimport downloadIcon from './icons/download.svg';\nimport styles from './style.module.scss';\n\nexport interface DownloadButtonProps {\n downloadStatus: DownloadStatus;\n onDownload: () => void;\n className?: string;\n customFail?: React.ReactNode;\n}\n\nconst InitialButton = ({ onDownload }: { onDownload: () => void }) => (\n <Button\n className={`w100 ${styles.button}`}\n buttonTitle=\"Download\"\n leftIcon={{ src: downloadIcon, alt: 'download arrow icon' }}\n onClick={onDownload}\n data-cy=\"download-documents-button\"\n />\n);\n\n// TODO: Allow setting loading to true to display text\nconst GeneratingButton = () => (\n <Button\n className={`w100 ${styles.button}`}\n buttonTitle=\"Generating\"\n loading={true}\n />\n);\n\nconst CompletedChip = () => (\n <div className={styles['chip-complete']}>\n <img src={checkIcon} alt=\"grey check\" />\n <div className=\"p-h4 tc-grey-500 ml8\">Download complete</div>\n </div>\n);\n\nconst DownloadButton = ({\n downloadStatus,\n onDownload,\n className = '',\n customFail,\n}: DownloadButtonProps) => {\n const mapDownloadButton: { [K in DownloadStatus]: React.ReactNode } = {\n INITIAL: <InitialButton onDownload={onDownload} />,\n GENERATING: <GeneratingButton />,\n COMPLETED: <CompletedChip />,\n FAILED: <InitialButton onDownload={onDownload} />,\n };\n\n return (\n <div className={`d-flex fd-column ai-center ${className}`}>\n <div className=\"ws4\">{mapDownloadButton[downloadStatus]}</div>\n {downloadStatus === 'FAILED' && (\n <div className=\"p-notice p-notice--danger p-p mt40 wmx5\">\n {customFail ??\n 'An error occured when generating documents. Please try again or contact us.'}\n </div>\n )}\n </div>\n );\n};\n\nexport { DownloadButton };\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;AAAA,gBAAe;;ACAf,mBAAe;;;;;;ACcf,IAAM,aAAa,GAAG,UAAC,EAA0C;QAAxC,UAAU,gBAAA;IAAmC,QACpEA,IAAC,MAAM,IACL,SAAS,EAAE,UAAQ,MAAM,CAAC,MAAQ,EAClC,WAAW,EAAC,UAAU,EACtB,QAAQ,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,qBAAqB,EAAE,EAC3D,OAAO,EAAE,UAAU,aACX,2BAA2B,WACnC;AAPkE,CAQrE,CAAC;AAEF;AACA,IAAM,gBAAgB,GAAG,cAAM,QAC7BA,IAAC,MAAM,IACL,SAAS,EAAE,UAAQ,MAAM,CAAC,MAAQ,EAClC,WAAW,EAAC,YAAY,EACxB,OAAO,EAAE,IAAI,WACb,IACH,CAAC;AAEF,IAAM,aAAa,GAAG,cAAM,QAC1BC,uBAAK,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,iBACrCD,aAAK,GAAG,EAAE,SAAS,EAAE,GAAG,EAAC,YAAY,WAAG;QACxCA,sBAAK,SAAS,EAAC,sBAAsB,+CAAwB,aACzD,IACP,CAAC;IAEI,cAAc,GAAG,UAAC,EAKF;QAJpB,cAAc,oBAAA,EACd,UAAU,gBAAA,EACV,iBAAc,EAAd,SAAS,mBAAG,EAAE,KAAA,EACd,UAAU,gBAAA;IAEV,IAAM,iBAAiB,GAA+C;QACpE,OAAO,EAAEA,IAAC,aAAa,IAAC,UAAU,EAAE,UAAU,WAAI;QAClD,UAAU,EAAEA,IAAC,gBAAgB,aAAG;QAChC,SAAS,EAAEA,IAAC,aAAa,aAAG;QAC5B,MAAM,EAAEA,IAAC,aAAa,IAAC,UAAU,EAAE,UAAU,WAAI;KAClD,CAAC;IAEF,QACEC,uBAAK,SAAS,EAAE,gCAA8B,SAAW,iBACvDD,sBAAK,SAAS,EAAC,KAAK,gBAAE,iBAAiB,CAAC,cAAc,CAAC,YAAO;YAC7D,cAAc,KAAK,QAAQ,KAC1BA,sBAAK,SAAS,EAAC,yCAAyC,gBACrD,UAAU,aAAV,UAAU,cAAV,UAAU,GACT,6EAA6E,YAC3E,CACP,aACG,EACN;AACJ;;;;"}
@@ -0,0 +1,47 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { DownloadButton } from './index.js';
3
+ import '../../tslib.es6-5bc94358.js';
4
+ import '../button/index.js';
5
+ import 'react';
6
+ import '../../style-inject.es-1f59c1d0.js';
7
+
8
+ var story = {
9
+ title: 'JSX/DownloadButton',
10
+ component: DownloadButton,
11
+ argTypes: {
12
+ downloadStatus: {
13
+ description: 'Status of the button',
14
+ defaultValue: 'INITIAL',
15
+ },
16
+ customFail: {
17
+ description: 'Customised error message. Only visible when button is on `FAILED` state.',
18
+ control: { type: 'text' },
19
+ },
20
+ onDownload: {
21
+ description: 'Called when download button has been clicked.',
22
+ action: true,
23
+ table: {
24
+ category: 'Callbacks',
25
+ },
26
+ },
27
+ className: {
28
+ description: 'This property allows to add custom styles to the component.',
29
+ }
30
+ },
31
+ parameters: {
32
+ componentSubtitle: 'DownloadButton component displays progress and status of downloading files.',
33
+ },
34
+ };
35
+ var DownloadButtonStory = function (_a) {
36
+ var downloadStatus = _a.downloadStatus, onDownload = _a.onDownload, className = _a.className, customFail = _a.customFail;
37
+ return (jsx(DownloadButton, { className: className, customFail: customFail, downloadStatus: downloadStatus, onDownload: onDownload }, void 0));
38
+ };
39
+ DownloadButtonStory.storyName = "DownloadButton";
40
+ var CustomErrorMessage = function (_a) {
41
+ var onDownload = _a.onDownload;
42
+ return (jsx(DownloadButton, { customFail: "Custom error message", downloadStatus: "FAILED", onDownload: onDownload }, void 0));
43
+ };
44
+
45
+ export default story;
46
+ export { CustomErrorMessage, DownloadButtonStory };
47
+ //# sourceMappingURL=index.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.stories.js","sources":["../../../../../src/lib/components/downloadButton/index.stories.tsx"],"sourcesContent":["import { DownloadButton, DownloadButtonProps } from '.';\n\nconst story = {\n title: 'JSX/DownloadButton',\n component: DownloadButton,\n argTypes: {\n downloadStatus: {\n description: 'Status of the button',\n defaultValue: 'INITIAL',\n },\n customFail: {\n description: 'Customised error message. Only visible when button is on `FAILED` state.',\n control: { type: 'text' },\n },\n onDownload: {\n description: 'Called when download button has been clicked.',\n action: true,\n table: {\n category: 'Callbacks',\n },\n },\n className: {\n description: 'This property allows to add custom styles to the component.',\n }\n },\n parameters: {\n componentSubtitle: 'DownloadButton component displays progress and status of downloading files.',\n },\n};\n\nexport const DownloadButtonStory = ({\n downloadStatus,\n onDownload,\n className,\n customFail\n}: DownloadButtonProps) => (\n <DownloadButton\n className={className}\n customFail={customFail}\n downloadStatus={downloadStatus}\n onDownload={onDownload}\n />\n);\n\nDownloadButtonStory.storyName = \"DownloadButton\";\n\nexport const CustomErrorMessage = ({\n onDownload,\n}: DownloadButtonProps) => (\n <DownloadButton\n customFail=\"Custom error message\"\n downloadStatus=\"FAILED\"\n onDownload={onDownload}\n />\n);\n\n\nexport default story;\n"],"names":["_jsx"],"mappings":";;;;;;;IAEM,KAAK,GAAG;IACZ,KAAK,EAAE,oBAAoB;IAC3B,SAAS,EAAE,cAAc;IACzB,QAAQ,EAAE;QACR,cAAc,EAAE;YACd,WAAW,EAAE,sBAAsB;YACnC,YAAY,EAAE,SAAS;SACxB;QACD,UAAU,EAAE;YACV,WAAW,EAAE,0EAA0E;YACvF,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;SAC1B;QACD,UAAU,EAAE;YACV,WAAW,EAAE,+CAA+C;YAC5D,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE;gBACL,QAAQ,EAAE,WAAW;aACtB;SACF;QACD,SAAS,EAAE;YACT,WAAW,EAAE,6DAA6D;SAC3E;KACF;IACD,UAAU,EAAE;QACV,iBAAiB,EAAE,6EAA6E;KACjG;EACD;IAEW,mBAAmB,GAAG,UAAC,EAKd;QAJpB,cAAc,oBAAA,EACd,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,UAAU,gBAAA;IACe,QACzBA,IAAC,cAAc,IACb,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU,WACtB;AANuB,EAOzB;AAEF,mBAAmB,CAAC,SAAS,GAAG,gBAAgB,CAAC;IAEpC,kBAAkB,GAAG,UAAC,EAEb;QADlB,UAAU,gBAAA;IACa,QACzBA,IAAC,cAAc,IACb,UAAU,EAAC,sBAAsB,EACjC,cAAc,EAAC,QAAQ,EACvB,UAAU,EAAE,UAAU,WACtB;AALuB;;;;;"}
@@ -0,0 +1,53 @@
1
+ import { _ as __assign, d as __spreadArray } from '../../../tslib.es6-5bc94358.js';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { c as classnames } from '../../../index-e9e37a34.js';
4
+
5
+ var Checkbox = function (_a) {
6
+ var options = _a.options, _b = _a.value, value = _b === void 0 ? [] : _b, onChange = _a.onChange, _c = _a.wide, wide = _c === void 0 ? false : _c, _d = _a.inlineLayout, inlineLayout = _d === void 0 ? false : _d, _e = _a.className, className = _e === void 0 ? '' : _e, _f = _a.labelClassName, labelClassName = _f === void 0 ? '' : _f, _g = _a.optionClassName, optionClassName = _g === void 0 ? '' : _g;
7
+ var hasNoneValue = Object.keys(options).includes('NONE');
8
+ var handleOnChange = function (newValue) {
9
+ if (value === null || value === void 0 ? void 0 : value.includes(newValue)) {
10
+ var filteredCheckboxValues = value.filter(function (selectedValue) { return selectedValue !== newValue; });
11
+ onChange(filteredCheckboxValues);
12
+ return;
13
+ }
14
+ if (hasNoneValue && newValue === 'NONE') {
15
+ onChange([newValue]);
16
+ return;
17
+ }
18
+ if (hasNoneValue && newValue !== 'NONE') {
19
+ var newValues_1 = value
20
+ ? __spreadArray(__spreadArray([], value.filter(function (v) { return v !== 'NONE'; })), [newValue]) : [newValue];
21
+ onChange(newValues_1);
22
+ return;
23
+ }
24
+ var newValues = value
25
+ ? __spreadArray(__spreadArray([], value), [newValue]) : [newValue];
26
+ onChange(newValues);
27
+ };
28
+ var entries = Object.entries(options);
29
+ return (jsx("div", __assign({ className: classnames(className, 'd-flex gap8', {
30
+ ws10: wide,
31
+ ws6: !wide,
32
+ 'fd-row': inlineLayout,
33
+ 'f-wrap': inlineLayout,
34
+ 'fd-column': !inlineLayout,
35
+ }) }, { children: entries.map(function (_a) {
36
+ var _b;
37
+ var currentValue = _a[0], label = _a[1];
38
+ var checked = value === null || value === void 0 ? void 0 : value.includes(currentValue);
39
+ var customIcon = (_b = label) === null || _b === void 0 ? void 0 : _b.icon;
40
+ return (jsxs("div", __assign({ className: optionClassName }, { children: [jsx("input", { className: classnames("p-checkbox", {
41
+ 'p-checkbox--no-icon': customIcon
42
+ }), id: currentValue, type: "checkbox", value: currentValue, onChange: function () { return handleOnChange(currentValue); }, checked: checked, "data-testid": "checkbox-input-" + currentValue }, void 0),
43
+ jsxs("label", __assign({ htmlFor: currentValue, className: classnames(labelClassName, 'p-label p-label--bordered pr16', {
44
+ 'jc-center': customIcon,
45
+ 'fd-column': customIcon
46
+ }), "data-cy": "checkbox-" + currentValue, "data-testid": "checkbox-" + currentValue }, { children: [customIcon && (jsx("div", __assign({ className: "mt8" }, { children: customIcon === null || customIcon === void 0 ? void 0 : customIcon(checked) }), void 0)),
47
+ typeof label === 'string' ? label : (jsxs("div", { children: [jsx("p", __assign({ className: "p-p" }, { children: label.title }), void 0),
48
+ jsx("span", __assign({ className: "d-block p-p p-p--small tc-grey-600" }, { children: label.description }), void 0)] }, void 0))] }), void 0)] }), currentValue));
49
+ }) }), void 0));
50
+ };
51
+
52
+ export { Checkbox };
53
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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\nexport interface CheckboxWithDescription {\n title: string;\n description?: string;\n icon?: (selected: boolean) => ReactNode;\n}\n\nexport interface CheckboxProps<ValueType extends string> {\n options: Record<ValueType, string | CheckboxWithDescription>;\n value?: ValueType[];\n onChange: (value: ValueType[]) => void;\n wide?: boolean;\n inlineLayout?: boolean;\n className?: string;\n labelClassName?: string;\n optionClassName?: string\n}\n\nexport const Checkbox = <ValueType extends string>({\n options,\n value = [],\n onChange,\n wide = false,\n inlineLayout = false,\n className = '',\n labelClassName = '',\n optionClassName = '',\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\n ? [...value, newValue]\n : [newValue];\n onChange(newValues);\n };\n\n\n const entries = Object.entries(options) as [\n ValueType,\n string | CheckboxWithDescription\n ][];\n\n return (\n <div\n className={classNames(className, 'd-flex gap8', {\n ws10: wide,\n ws6: !wide,\n 'fd-row': inlineLayout,\n 'f-wrap': inlineLayout,\n 'fd-column': !inlineLayout,\n })}\n >\n {entries.map(([currentValue, label]) => {\n const checked = value?.includes(currentValue);\n const customIcon = (label as CheckboxWithDescription)?.icon;\n\n return (\n <div className={optionClassName} key={currentValue}>\n <input\n className={classNames(\n \"p-checkbox\", {\n 'p-checkbox--no-icon': customIcon\n }\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(\n labelClassName,\n 'p-label p-label--bordered pr16',\n {\n 'jc-center': customIcon,\n 'fd-column': customIcon\n }\n )}\n data-cy={`checkbox-${currentValue}`}\n data-testid={`checkbox-${currentValue}`}\n >\n {customIcon && (\n <div className=\"mt8\">{customIcon?.(checked)}</div>\n )}\n\n {typeof label === 'string' ? 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 </div>\n );\n })}\n </div>\n );\n};\n"],"names":["_jsx","classNames","_jsxs"],"mappings":";;;;IAoBa,QAAQ,GAAG,UAA2B,EASjB;QARhC,OAAO,aAAA,EACP,aAAU,EAAV,KAAK,mBAAG,EAAE,KAAA,EACV,QAAQ,cAAA,EACR,YAAY,EAAZ,IAAI,mBAAG,KAAK,KAAA,EACZ,oBAAoB,EAApB,YAAY,mBAAG,KAAK,KAAA,EACpB,iBAAc,EAAd,SAAS,mBAAG,EAAE,KAAA,EACd,sBAAmB,EAAnB,cAAc,mBAAG,EAAE,KAAA,EACnB,uBAAoB,EAApB,eAAe,mBAAG,EAAE,KAAA;IAEpB,IAAM,YAAY,GAA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AK,QAAA;YAChC,IAAM,OAAO,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;YAC9C,IAAM,UAAU,GAAG,MAAC,KAAiC,0CAAE,IAAI,CAAC;YAE5D,QACEC,uBAAK,SAAS,EAAE,eAAe,iBAC7BF,eACE,SAAS,EAAEC,UAAU,CACnB,YAAY,EAAE;4BACZ,qBAAqB,EAAE,UAAU;yBAClC,CACF,EACD,EAAE,EAAE,YAAY,EAChB,IAAI,EAAC,UAAU,EACf,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAM,OAAA,cAAc,CAAC,YAAY,CAAC,GAAA,EAC5C,OAAO,EAAE,OAAO,iBACH,oBAAkB,YAAc,WAC7C;oBAEFC,yBACE,OAAO,EAAE,YAAY,EACrB,SAAS,EAAED,UAAU,CACnB,cAAc,EACd,gCAAgC,EAChC;4BACE,WAAW,EAAE,UAAU;4BACvB,WAAW,EAAE,UAAU;yBACxB,CACF,aACQ,cAAY,YAAc,iBACtB,cAAY,YAAc,iBAEtC,UAAU,KACTD,sBAAK,SAAS,EAAC,KAAK,gBAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,OAAO,CAAC,YAAO,CACnD;4BAEA,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,IAChCE,yBACEF,oBAAG,SAAS,EAAC,KAAK,gBAAE,KAAK,CAAC,KAAK,YAAK;oCACpCA,uBAAM,SAAS,EAAC,oCAAoC,gBACjD,KAAK,CAAC,WAAW,YACb,YACH,CACP,aACK,MAxC4B,YAAY,CAyC5C,EACN;SACH,CAAC,YACE,EACN;AACJ;;;;"}
@@ -0,0 +1,153 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useState } from 'react';
3
+ import { Checkbox } from './index.js';
4
+ import { i as images } from '../../../index-db2e797f.js';
5
+ import '../../../tslib.es6-5bc94358.js';
6
+ import '../../../index-e9e37a34.js';
7
+
8
+ var story = {
9
+ title: 'JSX/Inputs/Checkbox',
10
+ component: Checkbox,
11
+ argTypes: {
12
+ options: {
13
+ description: 'Object that contains the possible options for rendering in the input.',
14
+ defaultValue: {
15
+ CAT: {
16
+ title: 'Cat',
17
+ description: 'At least 1'
18
+ },
19
+ DOG: {
20
+ title: 'Dog',
21
+ description: 'At least 2'
22
+ },
23
+ NONE: {
24
+ title: 'None',
25
+ description: 'No pets'
26
+ }
27
+ }
28
+ },
29
+ value: {
30
+ description: 'Current checked values.',
31
+ },
32
+ onChange: {
33
+ description: 'Function called everytime a value changes.',
34
+ action: true,
35
+ table: {
36
+ category: "Callbacks",
37
+ },
38
+ },
39
+ wide: {
40
+ description: 'Property that defines if options should fill 100% of available horizontal space',
41
+ defaultValue: false
42
+ },
43
+ inlineLayout: {
44
+ description: 'Property that defines if options should show inline instead of block. Check inline checkbox options story for examples.',
45
+ defaultValue: false
46
+ },
47
+ className: {
48
+ description: 'Wrapper classNames for custom styling',
49
+ defaultValue: ''
50
+ },
51
+ optionClassName: {
52
+ description: 'Option classNames for custom styling',
53
+ defaultValue: ''
54
+ },
55
+ labelClassName: {
56
+ description: 'Label classNames for custom styling',
57
+ defaultValue: ''
58
+ },
59
+ }
60
+ };
61
+ var CheckboxStory = function (_a) {
62
+ var onChange = _a.onChange, options = _a.options, wide = _a.wide, className = _a.className, optionClassName = _a.optionClassName, labelClassName = _a.labelClassName, inlineLayout = _a.inlineLayout;
63
+ var _b = useState([]), checkedValues = _b[0], setCheckedValues = _b[1];
64
+ var handleOnChange = function (newValue) {
65
+ setCheckedValues(newValue);
66
+ onChange(newValue);
67
+ };
68
+ return (jsx(Checkbox, { wide: wide, options: options, onChange: handleOnChange, value: checkedValues, className: className, labelClassName: labelClassName, optionClassName: optionClassName, inlineLayout: inlineLayout }, void 0));
69
+ };
70
+ var CheckboxWithCustomWrapperStyles = function (_a) {
71
+ var onChange = _a.onChange;
72
+ var _b = useState([]), checkedValues = _b[0], setCheckedValues = _b[1];
73
+ var handleOnChange = function (newValue) {
74
+ if (newValue === void 0) { newValue = []; }
75
+ setCheckedValues(newValue);
76
+ onChange(newValue);
77
+ };
78
+ return (jsx(Checkbox, { onChange: handleOnChange, value: checkedValues, options: {
79
+ CAT1: 'Cat',
80
+ DOG1: 'Dog',
81
+ }, className: "p32 bg-primary-300 br24 bs-lg" }, void 0));
82
+ };
83
+ var CheckboxWithCustomOptionStyles = function (_a) {
84
+ var onChange = _a.onChange;
85
+ var _b = useState([]), checkedValues = _b[0], setCheckedValues = _b[1];
86
+ var handleOnChange = function (newValue) {
87
+ if (newValue === void 0) { newValue = []; }
88
+ setCheckedValues(newValue);
89
+ onChange(newValue);
90
+ };
91
+ return (jsx(Checkbox, { onChange: handleOnChange, value: checkedValues, options: {
92
+ CAT2: 'Cat',
93
+ DOG2: 'Dog',
94
+ }, optionClassName: "mb32 p24 bg-green-100 br12 bs-lg" }, void 0));
95
+ };
96
+ var CheckboxWithCustomLabelStyles = function (_a) {
97
+ var onChange = _a.onChange;
98
+ var _b = useState([]), checkedValues = _b[0], setCheckedValues = _b[1];
99
+ var handleOnChange = function (newValue) {
100
+ if (newValue === void 0) { newValue = []; }
101
+ setCheckedValues(newValue);
102
+ onChange(newValue);
103
+ };
104
+ return (jsx(Checkbox, { onChange: handleOnChange, value: checkedValues, options: {
105
+ CAT3: 'Cat',
106
+ DOG3: 'Dog',
107
+ }, labelClassName: "bg-grey-900 tc-white" }, void 0));
108
+ };
109
+ var CheckboxWithInlineLayout = function (_a) {
110
+ var onChange = _a.onChange;
111
+ var _b = useState([]), checkedValues = _b[0], setCheckedValues = _b[1];
112
+ var handleOnChange = function (newValue) {
113
+ if (newValue === void 0) { newValue = []; }
114
+ setCheckedValues(newValue);
115
+ onChange(newValue);
116
+ };
117
+ return (jsx(Checkbox, { onChange: handleOnChange, value: checkedValues, options: {
118
+ CAT4: 'Cat',
119
+ DOG4: 'Dog',
120
+ FISHER: 'Fish',
121
+ RABBIT: 'Rabbit',
122
+ RAT: 'Rat',
123
+ ANOTHER: 'Other',
124
+ }, optionClassName: "w30", inlineLayout: true, wide: true }, void 0));
125
+ };
126
+ var CheckboxWithCustomLabel = function (_a) {
127
+ var onChange = _a.onChange; _a.wide; _a.className; _a.optionClassName; _a.inlineLayout;
128
+ var _b = useState([]), checkedValues = _b[0], setCheckedValues = _b[1];
129
+ var handleOnChange = function (newValue) {
130
+ if (newValue === void 0) { newValue = []; }
131
+ setCheckedValues(newValue);
132
+ onChange(newValue);
133
+ };
134
+ return (jsx(Checkbox, { options: {
135
+ BIGDOG: {
136
+ icon: function () { return jsx("img", { src: images.bigDog, alt: '' }, void 0); },
137
+ title: 'Dog',
138
+ },
139
+ FISH: {
140
+ icon: function () { return jsx("img", { src: images.brokenAquarium, alt: '' }, void 0); },
141
+ title: 'Fish',
142
+ },
143
+ OTHER: {
144
+ icon: function () { return jsx("img", { src: images.brokenGlass, alt: '' }, void 0); },
145
+ title: 'Other',
146
+ }
147
+ }, onChange: handleOnChange, value: checkedValues, optionClassName: "w30", inlineLayout: true }, void 0));
148
+ };
149
+ CheckboxStory.storyName = 'Checkbox';
150
+
151
+ export default story;
152
+ export { CheckboxStory, CheckboxWithCustomLabel, CheckboxWithCustomLabelStyles, CheckboxWithCustomOptionStyles, CheckboxWithCustomWrapperStyles, CheckboxWithInlineLayout };
153
+ //# sourceMappingURL=index.stories.js.map
@@ -0,0 +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';\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 defaultValue: {\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 },\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 inlineLayout: {\n description: 'Property that defines if options should show inline instead of block. Check inline checkbox options story for examples.',\n defaultValue: false\n },\n className: {\n description: 'Wrapper classNames for custom styling',\n defaultValue: ''\n },\n optionClassName: {\n description: 'Option classNames for custom styling',\n defaultValue: ''\n },\n labelClassName: {\n description: 'Label classNames for custom styling',\n defaultValue: ''\n },\n }\n};\n\nexport const CheckboxStory = ({ \n onChange,\n options,\n wide,\n className,\n optionClassName,\n labelClassName,\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 className={className}\n labelClassName={labelClassName}\n optionClassName={optionClassName}\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 className=\"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 optionClassName=\"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 labelClassName=\"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 optionClassName=\"w30\"\n inlineLayout\n wide\n />\n );\n}\n\nexport const CheckboxWithCustomLabel = ({ onChange, wide, className, optionClassName, 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 optionClassName=\"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;Y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