@transferwise/components 46.79.1 → 46.80.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.
Files changed (32) hide show
  1. package/build/button/Button.js.map +1 -1
  2. package/build/button/Button.mjs.map +1 -1
  3. package/build/button/legacyUtils/legacyUtils.js.map +1 -1
  4. package/build/button/legacyUtils/legacyUtils.mjs.map +1 -1
  5. package/build/i18n/th.json +5 -0
  6. package/build/i18n/th.json.js +5 -0
  7. package/build/i18n/th.json.js.map +1 -1
  8. package/build/i18n/th.json.mjs +5 -0
  9. package/build/i18n/th.json.mjs.map +1 -1
  10. package/build/types/button/Button.d.ts +1 -1
  11. package/build/types/button/Button.d.ts.map +1 -1
  12. package/build/types/button/legacyUtils/legacyUtils.d.ts +2 -2
  13. package/build/types/button/legacyUtils/legacyUtils.d.ts.map +1 -1
  14. package/build/types/test-utils/index.d.ts +158 -0
  15. package/build/types/test-utils/index.d.ts.map +1 -0
  16. package/build/types/test-utils/jest.setup.d.ts +2 -0
  17. package/build/types/test-utils/jest.setup.d.ts.map +1 -0
  18. package/package.json +2 -1
  19. package/src/button/{Button.spec.js → Button.spec.tsx} +3 -2
  20. package/src/button/Button.tsx +1 -1
  21. package/src/button/legacyUtils/{legacyUtils.spec.js → legacyUtils.spec.tsx} +1 -1
  22. package/src/button/legacyUtils/legacyUtils.ts +2 -2
  23. package/src/i18n/th.json +5 -0
  24. package/src/modal/{Modal.rtl.spec.js → Modal.rtl.spec.tsx} +8 -7
  25. package/src/slidingPanel/SlidingPanel.spec.js +1 -1
  26. package/src/ssr.spec.tsx +264 -0
  27. package/src/test-utils/{index.js → index.tsx} +11 -6
  28. package/src/test-utils/{jest.setup.js → jest.setup.ts} +13 -8
  29. package/src/ssr.spec.js +0 -256
  30. /package/src/button/__snapshots__/{Button.spec.js.snap → Button.spec.tsx.snap} +0 -0
  31. /package/src/dimmer/{Dimmer.rtl.spec.js → Dimmer.rtl.spec.tsx} +0 -0
  32. /package/src/info/{Info.spec.js → Info.spec.jsx} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sources":["../../src/button/Button.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ElementType, forwardRef, MouseEvent } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport {\n Size,\n ControlType,\n Priority,\n ControlTypeAccent,\n ControlTypeNegative,\n ControlTypePositive,\n PriorityPrimary,\n PrioritySecondary,\n PriorityTertiary,\n SizeExtraSmall,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n} from '../common';\nimport ProcessIndicator from '../processIndicator';\n\nimport messages from './Button.messages';\nimport { typeClassMap, priorityClassMap } from './classMap';\nimport { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';\n\n/** @deprecated */\ntype DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';\n\n/** @deprecated */\ntype DeprecatedSizes = SizeExtraSmall;\n\ntype CommonProps = {\n block?: boolean;\n disabled?: boolean;\n loading?: boolean;\n type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;\n priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;\n size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;\n};\n\ntype ButtonProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {\n as?: 'button';\n htmlType?: 'submit' | 'reset' | 'button';\n };\n\ntype AnchorProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {\n as?: 'a';\n };\n\nexport type Props = ButtonProps | AnchorProps;\n\ntype ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;\n\nconst Button = forwardRef<ButtonReferenceType, Props>(\n (\n {\n as: component,\n block = false,\n children,\n className,\n disabled,\n loading = false,\n priority = Priority.PRIMARY,\n size = Size.MEDIUM,\n type = ControlType.ACCENT,\n onClick,\n ...rest\n }: Props,\n reference,\n ) => {\n const intl = useIntl();\n\n logDeprecationNotices({ size, type });\n\n const newType = establishNewType(type);\n const newPriority = establishNewPriority(priority, type);\n\n const classes = clsx(\n `btn btn-${size}`,\n `np-btn np-btn-${size}`,\n {\n 'btn-loading': loading,\n 'btn-block np-btn-block': block,\n disabled,\n },\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n typeClassMap[newType],\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n priorityClassMap[newPriority],\n className,\n );\n\n function processIndicatorSize() {\n return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';\n }\n\n const Element = (component as ElementType) ?? 'button';\n let props;\n\n if (Element === 'button') {\n const { htmlType = 'button', ...restProps } = rest as ButtonProps;\n props = {\n ...restProps,\n disabled,\n 'aria-disabled': loading,\n type: htmlType,\n };\n } else {\n props = {\n ...rest,\n 'aria-disabled': loading,\n } as AnchorProps;\n }\n\n /**\n * Ensures that the button cannot be activated in loading or disabled mode,\n * when `aria-disabled` might be used over the `disabled` HTML attribute\n */\n const handleClick =\n (handler: Props['onClick']) =>\n (event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {\n if (disabled || loading) {\n event.preventDefault();\n } else if (typeof handler === 'function') {\n handler(event);\n }\n };\n\n return (\n <Element\n ref={reference}\n className={classes}\n onClick={handleClick(onClick)}\n {...props}\n aria-live={loading ? 'polite' : 'off'}\n aria-busy={loading}\n aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}\n >\n {children}\n {loading && (\n <ProcessIndicator\n size={processIndicatorSize()}\n className=\"btn-loader\"\n data-testid=\"ButtonProgressIndicator\"\n />\n )}\n </Element>\n );\n },\n);\n\nexport default Button;\n"],"names":["Button","forwardRef","as","component","block","children","className","disabled","loading","priority","Priority","PRIMARY","size","Size","MEDIUM","type","ControlType","ACCENT","onClick","rest","reference","intl","useIntl","logDeprecationNotices","newType","establishNewType","newPriority","establishNewPriority","classes","clsx","typeClassMap","priorityClassMap","processIndicatorSize","includes","Element","props","htmlType","restProps","handleClick","handler","event","preventDefault","_jsxs","ref","formatMessage","messages","loadingAriaLabel","_jsx","ProcessIndicator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAMA,MAAM,gBAAGC,gBAAU,CACvB,CACE;AACEC,EAAAA,EAAE,EAAEC,SAAS;AACbC,EAAAA,KAAK,GAAG,KAAK;EACbC,QAAQ;EACRC,SAAS;EACTC,QAAQ;AACRC,EAAAA,OAAO,GAAG,KAAK;EACfC,QAAQ,GAAGC,gBAAQ,CAACC,OAAO;QAC3BC,MAAI,GAAGC,SAAI,CAACC,MAAM;EAClBC,IAAI,GAAGC,mBAAW,CAACC,MAAM;EACzBC,OAAO;EACP,GAAGC,IAAAA;AACG,CAAA,EACRC,SAAS,KACP;AACF,EAAA,MAAMC,IAAI,GAAGC,iBAAO,EAAE,CAAA;AAEtBC,EAAAA,iCAAqB,CAAC;UAAEX,MAAI;AAAEG,IAAAA,IAAAA;AAAI,GAAE,CAAC,CAAA;AAErC,EAAA,MAAMS,OAAO,GAAGC,4BAAgB,CAACV,IAAI,CAAC,CAAA;AACtC,EAAA,MAAMW,WAAW,GAAGC,gCAAoB,CAAClB,QAAQ,EAAEM,IAAI,CAAC,CAAA;EAExD,MAAMa,OAAO,GAAGC,SAAI,CAClB,CAAA,QAAA,EAAWjB,MAAI,CAAA,CAAE,EACjB,CAAA,cAAA,EAAiBA,MAAI,CAAA,CAAE,EACvB;AACE,IAAA,aAAa,EAAEJ,OAAO;AACtB,IAAA,wBAAwB,EAAEJ,KAAK;AAC/BG,IAAAA,QAAAA;GACD;AACD;AACA;EACAuB,qBAAY,CAACN,OAAO,CAAC;AACrB;AACA;AACAO,EAAAA,yBAAgB,CAACL,WAAW,CAAC,EAC7BpB,SAAS,CACV,CAAA;EAED,SAAS0B,oBAAoBA,GAAA;AAC3B,IAAA,OAAO,CAAC,IAAI,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B,IAAI,CAAC,YAAY,CAAE;AAAAd,IAAAA,QAAA,GAExFA,QAAQ,EACRG,OAAO,iBACNuC,cAAA,CAACC,gBAAgB,EAAA;MACfpC,IAAI,EAAEoB,oBAAoB,EAAG;AAC7B1B,MAAAA,SAAS,EAAC,YAAY;MACtB,aAAY,EAAA,yBAAA;AAAyB,KACrC,CACH,CAAA;AAAA,GACM,CAAC,CAAA;AAEd,CAAC;;;;"}
1
+ {"version":3,"file":"Button.js","sources":["../../src/button/Button.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ElementType, forwardRef, MouseEvent } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport {\n Size,\n ControlType,\n Priority,\n ControlTypeAccent,\n ControlTypeNegative,\n ControlTypePositive,\n PriorityPrimary,\n PrioritySecondary,\n PriorityTertiary,\n SizeExtraSmall,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n} from '../common';\nimport ProcessIndicator from '../processIndicator';\n\nimport messages from './Button.messages';\nimport { typeClassMap, priorityClassMap } from './classMap';\nimport { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';\n\n/** @deprecated */\ntype DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';\n\n/** @deprecated */\ntype DeprecatedSizes = SizeExtraSmall;\n\ntype CommonProps = {\n block?: boolean;\n disabled?: boolean;\n loading?: boolean;\n type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;\n priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;\n size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;\n};\n\ntype ButtonProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {\n as?: 'button';\n htmlType?: 'submit' | 'reset' | 'button';\n };\n\ntype AnchorProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {\n as?: 'a';\n };\n\nexport type Props = ButtonProps | AnchorProps;\n\nexport type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;\n\nconst Button = forwardRef<ButtonReferenceType, Props>(\n (\n {\n as: component,\n block = false,\n children,\n className,\n disabled,\n loading = false,\n priority = Priority.PRIMARY,\n size = Size.MEDIUM,\n type = ControlType.ACCENT,\n onClick,\n ...rest\n }: Props,\n reference,\n ) => {\n const intl = useIntl();\n\n logDeprecationNotices({ size, type });\n\n const newType = establishNewType(type);\n const newPriority = establishNewPriority(priority, type);\n\n const classes = clsx(\n `btn btn-${size}`,\n `np-btn np-btn-${size}`,\n {\n 'btn-loading': loading,\n 'btn-block np-btn-block': block,\n disabled,\n },\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n typeClassMap[newType],\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n priorityClassMap[newPriority],\n className,\n );\n\n function processIndicatorSize() {\n return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';\n }\n\n const Element = (component as ElementType) ?? 'button';\n let props;\n\n if (Element === 'button') {\n const { htmlType = 'button', ...restProps } = rest as ButtonProps;\n props = {\n ...restProps,\n disabled,\n 'aria-disabled': loading,\n type: htmlType,\n };\n } else {\n props = {\n ...rest,\n 'aria-disabled': loading,\n } as AnchorProps;\n }\n\n /**\n * Ensures that the button cannot be activated in loading or disabled mode,\n * when `aria-disabled` might be used over the `disabled` HTML attribute\n */\n const handleClick =\n (handler: Props['onClick']) =>\n (event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {\n if (disabled || loading) {\n event.preventDefault();\n } else if (typeof handler === 'function') {\n handler(event);\n }\n };\n\n return (\n <Element\n ref={reference}\n className={classes}\n onClick={handleClick(onClick)}\n {...props}\n aria-live={loading ? 'polite' : 'off'}\n aria-busy={loading}\n aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}\n >\n {children}\n {loading && (\n <ProcessIndicator\n size={processIndicatorSize()}\n className=\"btn-loader\"\n data-testid=\"ButtonProgressIndicator\"\n />\n )}\n </Element>\n );\n },\n);\n\nexport default Button;\n"],"names":["Button","forwardRef","as","component","block","children","className","disabled","loading","priority","Priority","PRIMARY","size","Size","MEDIUM","type","ControlType","ACCENT","onClick","rest","reference","intl","useIntl","logDeprecationNotices","newType","establishNewType","newPriority","establishNewPriority","classes","clsx","typeClassMap","priorityClassMap","processIndicatorSize","includes","Element","props","htmlType","restProps","handleClick","handler","event","preventDefault","_jsxs","ref","formatMessage","messages","loadingAriaLabel","_jsx","ProcessIndicator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAMA,MAAM,gBAAGC,gBAAU,CACvB,CACE;AACEC,EAAAA,EAAE,EAAEC,SAAS;AACbC,EAAAA,KAAK,GAAG,KAAK;EACbC,QAAQ;EACRC,SAAS;EACTC,QAAQ;AACRC,EAAAA,OAAO,GAAG,KAAK;EACfC,QAAQ,GAAGC,gBAAQ,CAACC,OAAO;QAC3BC,MAAI,GAAGC,SAAI,CAACC,MAAM;EAClBC,IAAI,GAAGC,mBAAW,CAACC,MAAM;EACzBC,OAAO;EACP,GAAGC,IAAAA;AACG,CAAA,EACRC,SAAS,KACP;AACF,EAAA,MAAMC,IAAI,GAAGC,iBAAO,EAAE,CAAA;AAEtBC,EAAAA,iCAAqB,CAAC;UAAEX,MAAI;AAAEG,IAAAA,IAAAA;AAAI,GAAE,CAAC,CAAA;AAErC,EAAA,MAAMS,OAAO,GAAGC,4BAAgB,CAACV,IAAI,CAAC,CAAA;AACtC,EAAA,MAAMW,WAAW,GAAGC,gCAAoB,CAAClB,QAAQ,EAAEM,IAAI,CAAC,CAAA;EAExD,MAAMa,OAAO,GAAGC,SAAI,CAClB,CAAA,QAAA,EAAWjB,MAAI,CAAA,CAAE,EACjB,CAAA,cAAA,EAAiBA,MAAI,CAAA,CAAE,EACvB;AACE,IAAA,aAAa,EAAEJ,OAAO;AACtB,IAAA,wBAAwB,E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CAAE;AAAA,IAAA,GAC1BiB,KAAK;AACT,IAAA,WAAA,EAAW3B,OAAO,GAAG,QAAQ,GAAG,KAAM;AACtC,IAAA,WAAA,EAAWA,OAAQ;AACnB,IAAA,YAAA,EAAYA,OAAO,GAAGa,IAAI,CAACuB,aAAa,CAACC,eAAQ,CAACC,gBAAgB,CAAC,GAAG3B,IAAI,CAAC,YAAY,CAAE;AAAAd,IAAAA,QAAA,GAExFA,QAAQ,EACRG,OAAO,iBACNuC,cAAA,CAACC,gBAAgB,EAAA;MACfpC,IAAI,EAAEoB,oBAAoB,EAAG;AAC7B1B,MAAAA,SAAS,EAAC,YAAY;MACtB,aAAY,EAAA,yBAAA;AAAyB,KACrC,CACH,CAAA;AAAA,GACM,CAAC,CAAA;AAEd,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Button.mjs","sources":["../../src/button/Button.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ElementType, forwardRef, MouseEvent } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport {\n Size,\n ControlType,\n Priority,\n ControlTypeAccent,\n ControlTypeNegative,\n ControlTypePositive,\n PriorityPrimary,\n PrioritySecondary,\n PriorityTertiary,\n SizeExtraSmall,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n} from '../common';\nimport ProcessIndicator from '../processIndicator';\n\nimport messages from './Button.messages';\nimport { typeClassMap, priorityClassMap } from './classMap';\nimport { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';\n\n/** @deprecated */\ntype DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';\n\n/** @deprecated */\ntype DeprecatedSizes = SizeExtraSmall;\n\ntype CommonProps = {\n block?: boolean;\n disabled?: boolean;\n loading?: boolean;\n type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;\n priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;\n size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;\n};\n\ntype ButtonProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {\n as?: 'button';\n htmlType?: 'submit' | 'reset' | 'button';\n };\n\ntype AnchorProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {\n as?: 'a';\n };\n\nexport type Props = ButtonProps | AnchorProps;\n\ntype ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;\n\nconst Button = forwardRef<ButtonReferenceType, Props>(\n (\n {\n as: component,\n block = false,\n children,\n className,\n disabled,\n loading = false,\n priority = Priority.PRIMARY,\n size = Size.MEDIUM,\n type = ControlType.ACCENT,\n onClick,\n ...rest\n }: Props,\n reference,\n ) => {\n const intl = useIntl();\n\n logDeprecationNotices({ size, type });\n\n const newType = establishNewType(type);\n const newPriority = establishNewPriority(priority, type);\n\n const classes = clsx(\n `btn btn-${size}`,\n `np-btn np-btn-${size}`,\n {\n 'btn-loading': loading,\n 'btn-block np-btn-block': block,\n disabled,\n },\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n typeClassMap[newType],\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n priorityClassMap[newPriority],\n className,\n );\n\n function processIndicatorSize() {\n return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';\n }\n\n const Element = (component as ElementType) ?? 'button';\n let props;\n\n if (Element === 'button') {\n const { htmlType = 'button', ...restProps } = rest as ButtonProps;\n props = {\n ...restProps,\n disabled,\n 'aria-disabled': loading,\n type: htmlType,\n };\n } else {\n props = {\n ...rest,\n 'aria-disabled': loading,\n } as AnchorProps;\n }\n\n /**\n * Ensures that the button cannot be activated in loading or disabled mode,\n * when `aria-disabled` might be used over the `disabled` HTML attribute\n */\n const handleClick =\n (handler: Props['onClick']) =>\n (event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {\n if (disabled || loading) {\n event.preventDefault();\n } else if (typeof handler === 'function') {\n handler(event);\n }\n };\n\n return (\n <Element\n ref={reference}\n className={classes}\n onClick={handleClick(onClick)}\n {...props}\n aria-live={loading ? 'polite' : 'off'}\n aria-busy={loading}\n aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}\n >\n {children}\n {loading && (\n <ProcessIndicator\n size={processIndicatorSize()}\n className=\"btn-loader\"\n data-testid=\"ButtonProgressIndicator\"\n />\n )}\n </Element>\n );\n },\n);\n\nexport default Button;\n"],"names":["Button","forwardRef","as","component","block","children","className","disabled","loading","priority","Priority","PRIMARY","size","Size","MEDIUM","type","ControlType","ACCENT","onClick","rest","reference","intl","useIntl","logDeprecationNotices","newType","establishNewType","newPriority","establishNewPriority","classes","clsx","typeClassMap","priorityClassMap","processIndicatorSize","includes","Element","props","htmlType","restProps","handleClick","handler","event","preventDefault","_jsxs","ref","formatMessage","messages","loadingAriaLabel","_jsx","ProcessIndicator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAMA,MAAM,gBAAGC,UAAU,CACvB,CACE;AACEC,EAAAA,EAAE,EAAEC,SAAS;AACbC,EAAAA,KAAK,GAAG,KAAK;EACbC,QAAQ;EACRC,SAAS;EACTC,QAAQ;AACRC,EAAAA,OAAO,GAAG,KAAK;EACfC,QAAQ,GAAGC,QAAQ,CAACC,OAAO;EAC3BC,IAAI,GAAGC,IAAI,CAACC,MAAM;EAClBC,IAAI,GAAGC,WAAW,CAACC,MAAM;EACzBC,OAAO;EACP,GAAGC,IAAAA;AACG,CAAA,EACRC,SAAS,KACP;AACF,EAAA,MAAMC,IAAI,GAAGC,OAAO,EAAE,CAAA;AAEtBC,EAAAA,qBAAqB,CAAC;IAAEX,IAAI;AAAEG,IAAAA,IAAAA;AAAI,GAAE,CAAC,CAAA;AAErC,EAAA,MAAMS,OAAO,GAAGC,gBAAgB,CAACV,IAAI,CAAC,CAAA;AACtC,EAAA,MAAMW,WAAW,GAAGC,o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UAAU,EAAE;MACxCA,OAAO,CAACC,KAAK,CAAC,CAAA;AAChB,KAAA;GACD,CAAA;EAEH,oBACEE,IAAA,CAACR,OAAO,EAAA;AACNS,IAAAA,GAAG,EAAEvB,SAAU;AACfd,IAAAA,SAAS,EAAEsB,OAAQ;AACnBV,IAAAA,OAAO,EAAEoB,WAAW,CAACpB,OAAO,CAAE;AAAA,IAAA,GAC1BiB,KAAK;AACT,IAAA,WAAA,EAAW3B,OAAO,GAAG,QAAQ,GAAG,KAAM;AACtC,IAAA,WAAA,EAAWA,OAAQ;AACnB,IAAA,YAAA,EAAYA,OAAO,GAAGa,IAAI,CAACuB,aAAa,CAACC,QAAQ,CAACC,gBAAgB,CAAC,GAAG3B,IAAI,CAAC,YAAY,CAAE;AAAAd,IAAAA,QAAA,GAExFA,QAAQ,EACRG,OAAO,iBACNuC,GAAA,CAACC,gBAAgB,EAAA;MACfpC,IAAI,EAAEoB,oBAAoB,EAAG;AAC7B1B,MAAAA,SAAS,EAAC,YAAY;MACtB,aAAY,EAAA,yBAAA;AAAyB,KACrC,CACH,CAAA;AAAA,GACM,CAAC,CAAA;AAEd,CAAC;;;;"}
1
+ {"version":3,"file":"Button.mjs","sources":["../../src/button/Button.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ElementType, forwardRef, MouseEvent } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport {\n Size,\n ControlType,\n Priority,\n ControlTypeAccent,\n ControlTypeNegative,\n ControlTypePositive,\n PriorityPrimary,\n PrioritySecondary,\n PriorityTertiary,\n SizeExtraSmall,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n} from '../common';\nimport ProcessIndicator from '../processIndicator';\n\nimport messages from './Button.messages';\nimport { typeClassMap, priorityClassMap } from './classMap';\nimport { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';\n\n/** @deprecated */\ntype DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';\n\n/** @deprecated */\ntype DeprecatedSizes = SizeExtraSmall;\n\ntype CommonProps = {\n block?: boolean;\n disabled?: boolean;\n loading?: boolean;\n type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;\n priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;\n size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;\n};\n\ntype ButtonProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {\n as?: 'button';\n htmlType?: 'submit' | 'reset' | 'button';\n };\n\ntype AnchorProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {\n as?: 'a';\n };\n\nexport type Props = ButtonProps | AnchorProps;\n\nexport type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;\n\nconst Button = forwardRef<ButtonReferenceType, Props>(\n (\n {\n as: component,\n block = false,\n children,\n className,\n disabled,\n loading = false,\n priority = Priority.PRIMARY,\n size = Size.MEDIUM,\n type = ControlType.ACCENT,\n onClick,\n ...rest\n }: Props,\n reference,\n ) => {\n const intl = useIntl();\n\n logDeprecationNotices({ size, type });\n\n const newType = establishNewType(type);\n const newPriority = establishNewPriority(priority, type);\n\n const classes = clsx(\n `btn btn-${size}`,\n `np-btn np-btn-${size}`,\n {\n 'btn-loading': loading,\n 'btn-block np-btn-block': block,\n disabled,\n },\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n typeClassMap[newType],\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n priorityClassMap[newPriority],\n className,\n );\n\n function processIndicatorSize() {\n return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';\n }\n\n const Element = (component as ElementType) ?? 'button';\n let props;\n\n if (Element === 'button') {\n const { htmlType = 'button', ...restProps } = rest as ButtonProps;\n props = {\n ...restProps,\n disabled,\n 'aria-disabled': loading,\n type: htmlType,\n };\n } else {\n props = {\n ...rest,\n 'aria-disabled': loading,\n } as AnchorProps;\n }\n\n /**\n * Ensures that the button cannot be activated in loading or disabled mode,\n * when `aria-disabled` might be used over the `disabled` HTML attribute\n */\n const handleClick =\n (handler: Props['onClick']) =>\n (event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {\n if (disabled || loading) {\n event.preventDefault();\n } else if (typeof handler === 'function') {\n handler(event);\n }\n };\n\n return (\n <Element\n ref={reference}\n className={classes}\n onClick={handleClick(onClick)}\n {...props}\n aria-live={loading ? 'polite' : 'off'}\n aria-busy={loading}\n aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}\n >\n {children}\n {loading && (\n <ProcessIndicator\n size={processIndicatorSize()}\n className=\"btn-loader\"\n data-testid=\"ButtonProgressIndicator\"\n />\n )}\n </Element>\n );\n },\n);\n\nexport default Button;\n"],"names":["Button","forwardRef","as","component","block","children","className","disabled","loading","priority","Priority","PRIMARY","size","Size","MEDIUM","type","ControlType","ACCENT","onClick","rest","reference","intl","useIntl","logDeprecationNotices","newType","establishNewType","newPriority","establishNewPriority","classes","clsx","typeClassMap","priorityClassMap","processIndicatorSize","includes","Element","props","htmlType","restProps","handleClick","handler","event","preventDefault","_jsxs","ref","formatMessage","messages","loadingAriaLabel","_jsx","ProcessIndicator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAMA,MAAM,gBAAGC,UAAU,CACvB,CACE;AACEC,EAAAA,EAAE,EAAEC,SAAS;AACbC,EAAAA,KAAK,GAAG,KAAK;EACbC,QAAQ;EACRC,SAAS;EACTC,QAAQ;AACRC,EAAAA,OAAO,GAAG,KAAK;EACfC,QAAQ,GAAGC,QAAQ,CAACC,OAAO;EAC3BC,IAAI,GAAGC,IAAI,CAACC,MAAM;EAClBC,IAAI,GAAGC,WAAW,CAACC,MAAM;EACzBC,OAAO;EACP,GAAGC,IAAAA;AACG,CAAA,EACRC,SAAS,KACP;AACF,EAAA,MAAMC,IAAI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CAAA;AAClB,GAAA;AAEA;;;AAGG;AACH,EAAA,MAAM8B,WAAW,GACdC,OAAyB,IACzBC,KAAoE,IAAI;IACvE,IAAIjC,QAAQ,IAAIC,OAAO,EAAE;MACvBgC,KAAK,CAACC,cAAc,EAAE,CAAA;AACxB,KAAC,MAAM,IAAI,OAAOF,OAAO,KAAK,UAAU,EAAE;MACxCA,OAAO,CAACC,KAAK,CAAC,CAAA;AAChB,KAAA;GACD,CAAA;EAEH,oBACEE,IAAA,CAACR,OAAO,EAAA;AACNS,IAAAA,GAAG,EAAEvB,SAAU;AACfd,IAAAA,SAAS,EAAEsB,OAAQ;AACnBV,IAAAA,OAAO,EAAEoB,WAAW,CAACpB,OAAO,CAAE;AAAA,IAAA,GAC1BiB,KAAK;AACT,IAAA,WAAA,EAAW3B,OAAO,GAAG,QAAQ,GAAG,KAAM;AACtC,IAAA,WAAA,EAAWA,OAAQ;AACnB,IAAA,YAAA,EAAYA,OAAO,GAAGa,IAAI,CAACuB,aAAa,CAACC,QAAQ,CAACC,gBAAgB,CAAC,GAAG3B,IAAI,CAAC,YAAY,CAAE;AAAAd,IAAAA,QAAA,GAExFA,QAAQ,EACRG,OAAO,iBACNuC,GAAA,CAACC,gBAAgB,EAAA;MACfpC,IAAI,EAAEoB,oBAAoB,EAAG;AAC7B1B,MAAAA,SAAS,EAAC,YAAY;MACtB,aAAY,EAAA,yBAAA;AAAyB,KACrC,CACH,CAAA;AAAA,GACM,CAAC,CAAA;AAEd,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"legacyUtils.js","sources":["../../../src/button/legacyUtils/legacyUtils.ts"],"sourcesContent":["import { ControlType, Priority, Size, Type } from '../../common';\nimport { logActionRequired, logActionRequiredIf } from '../../utilities';\n\nconst deprecatedTypeMap: Record<Type, ControlType> = {\n [Type.PRIMARY]: ControlType.ACCENT,\n [Type.SECONDARY]: ControlType.ACCENT,\n [Type.LINK]: ControlType.ACCENT,\n [Type.PAY]: ControlType.POSITIVE,\n [Type.DANGER]: ControlType.NEGATIVE,\n};\n\ntype OldTypeKeys = Type.DANGER | Type.LINK | Type.SECONDARY;\nconst oldTypePriorityMap: Record<OldTypeKeys, Priority> = {\n [Type.DANGER]: Priority.SECONDARY,\n [Type.LINK]: Priority.TERTIARY,\n [Type.SECONDARY]: Priority.SECONDARY,\n};\n\nconst deprecatedTypeMapMessage = {\n [Type.DANGER]: 'Type.NEGATIVE',\n [Type.LINK]: 'ControlType.ACCENT with priority Priority.TERTIARY',\n [Type.PAY]: 'ControlType.POSITIVE',\n [Type.PRIMARY]: 'ControlType.ACCENT',\n [Type.SECONDARY]: 'ControlType.ACCENT with priority Priority.SECONDARY',\n};\n\nconst deprecatedTypes = Object.keys(deprecatedTypeMap);\n\ntype EstablishNewTypeType = (\n originalType: Type | (string & Record<never, never>) | null,\n) => `${ControlType}` | string | null;\n\nexport const establishNewType: EstablishNewTypeType = (originalType) =>\n originalType && originalType in deprecatedTypeMap\n ? deprecatedTypeMap[originalType as Type]\n : originalType;\n\ntype EstablishNewPriorityType = (\n originalPriority?: Priority | (string & Record<never, never>) | null,\n originalType?: OldTypeKeys | (string & Record<never, never>) | null,\n) => `${ControlType}` | string | null | undefined;\n\nexport const establishNewPriority: EstablishNewPriorityType = (originalPriority, originalType) => {\n const type = originalType ? establishNewType(originalType) : '';\n\n // The old SECONDARY and LINK types now map to priorities. If they're still using one of\n // these old types, ignore whatever priority they've passed and use this instead.\n if (originalType && originalType in oldTypePriorityMap) {\n return oldTypePriorityMap[originalType as OldTypeKeys];\n }\n // Only ControlType.ACCENT supports tertiary styles\n if (originalPriority === Priority.TERTIARY && type !== ControlType.ACCENT) {\n return Priority.SECONDARY;\n }\n return originalPriority;\n};\n\ntype DeprecatedTypeMapMessageType = keyof typeof deprecatedTypeMapMessage;\ntype LogDeprecationNoticesType = (params: {\n size: `${Size}`;\n type: DeprecatedTypeMapMessageType | (string & Record<never, never>) | null;\n}) => void;\nexport const logDeprecationNotices: LogDeprecationNoticesType = ({ size, type }) => {\n logActionRequiredIf(\n 'Button has deprecated the `Size.EXTRA_SMALL` value for the `size` prop. Please use Size.SMALL instead.',\n size === Size.EXTRA_SMALL,\n );\n\n if (type && deprecatedTypes.includes(type) && type in deprecatedTypeMapMessage) {\n logActionRequired(\n `Button has deprecated the ${type} value for the \\`type\\` prop. Please update to ${deprecatedTypeMapMessage[type as DeprecatedTypeMapMessageType]}.`,\n );\n }\n};\n"],"names":["deprecatedTypeMap","Type","PRIMARY","ControlType","ACCENT","SECONDARY","LINK","PAY","POSITIVE","DANGER","NEGATIVE","oldTypePriorityMap","Priority","TERTIARY","deprecatedTypeMapMessage","deprecatedTypes","Object","keys","establishNewType","originalType","establishNewPriority","originalPriority","type","logDeprecationNotices","size","logActionRequiredIf","Size","EXTRA_SMALL","includes","logActionRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAMA,iBAAiB,GAA8B;AACnD,EAAA,CAACC,SAAI,CAACC,OAAO,GAAGC,mBAAW,CAACC,MAAM;AAClC,EAAA,CAACH,SAAI,CAACI,SAAS,GAAGF,mBAAW,CAACC,MAAM;AACpC,EAAA,CAACH,SAAI,CAACK,IAAI,GAAGH,mBAAW,CAACC,MAAM;AAC/B,EAAA,CAACH,SAAI,CAACM,GAAG,GAAGJ,mBAAW,CAACK,QAAQ;AAChC,EAAA,CAACP,SAAI,CAACQ,MAAM,GAAGN,mBAAW,CAACO,QAAAA;CAC5B,CAAA;AAGD,MAAMC,kBAAkB,GAAkC;AACxD,EAAA,CAACV,SAAI,CAACQ,MAAM,GAAGG,gBAAQ,CAACP,SAAS;AACjC,EAAA,CAACJ,SAAI,CAACK,IAAI,GAAGM,gBAAQ,CAACC,QAAQ;AAC9B,EAAA,CAACZ,SAAI,CAACI,SAAS,GAAGO,gBAAQ,CAACP,SAAAA;CAC5B,CAAA;AAED,MAAMS,wBAAwB,GAAG;AAC/B,EAAA,CAACb,SAAI,CAACQ,MAAM,GAAG,eAAe;AAC9B,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C,CAAA,CAAA,CAAG,CACrJ,CAAA;AACH,GAAA;AACF;;;;;;"}
1
+ {"version":3,"file":"legacyUtils.js","sources":["../../../src/button/legacyUtils/legacyUtils.ts"],"sourcesContent":["import { ControlType, Priority, Size, Type } from '../../common';\nimport { logActionRequired, logActionRequiredIf } from '../../utilities';\n\nconst deprecatedTypeMap: Record<Type, ControlType> = {\n [Type.PRIMARY]: ControlType.ACCENT,\n [Type.SECONDARY]: ControlType.ACCENT,\n [Type.LINK]: ControlType.ACCENT,\n [Type.PAY]: ControlType.POSITIVE,\n [Type.DANGER]: ControlType.NEGATIVE,\n};\n\ntype OldTypeKeys = Type.DANGER | Type.LINK | Type.SECONDARY;\nconst oldTypePriorityMap: Record<OldTypeKeys, Priority> = {\n [Type.DANGER]: Priority.SECONDARY,\n [Type.LINK]: Priority.TERTIARY,\n [Type.SECONDARY]: Priority.SECONDARY,\n};\n\nconst deprecatedTypeMapMessage = {\n [Type.DANGER]: 'Type.NEGATIVE',\n [Type.LINK]: 'ControlType.ACCENT with priority Priority.TERTIARY',\n [Type.PAY]: 'ControlType.POSITIVE',\n [Type.PRIMARY]: 'ControlType.ACCENT',\n [Type.SECONDARY]: 'ControlType.ACCENT with priority Priority.SECONDARY',\n};\n\nconst deprecatedTypes = Object.keys(deprecatedTypeMap);\n\ntype EstablishNewTypeType = (\n originalType: Type | (string & Record<never, never>) | null,\n) => `${ControlType}` | string | null;\n\nexport const establishNewType: EstablishNewTypeType = (originalType) =>\n originalType && originalType in deprecatedTypeMap\n ? deprecatedTypeMap[originalType as Type]\n : originalType;\n\ntype EstablishNewPriorityType = (\n originalPriority?: Priority | (string & Record<never, never>) | null,\n originalType?: OldTypeKeys | (string & Record<never, never>) | null,\n) => `${ControlType}` | string | null | undefined;\n\nexport const establishNewPriority: EstablishNewPriorityType = (originalPriority, originalType) => {\n const type = originalType ? establishNewType(originalType) : '';\n\n // The old SECONDARY and LINK types now map to priorities. If they're still using one of\n // these old types, ignore whatever priority they've passed and use this instead.\n if (originalType && originalType in oldTypePriorityMap) {\n return oldTypePriorityMap[originalType as OldTypeKeys];\n }\n // Only ControlType.ACCENT supports tertiary styles\n if (originalPriority === Priority.TERTIARY && type !== ControlType.ACCENT) {\n return Priority.SECONDARY;\n }\n return originalPriority;\n};\n\ntype DeprecatedTypeMapMessageType = keyof typeof deprecatedTypeMapMessage;\ntype LogDeprecationNoticesType = (params: {\n size?: `${Size}`;\n type?: DeprecatedTypeMapMessageType | (string & Record<never, never>) | null;\n}) => void;\nexport const logDeprecationNotices: LogDeprecationNoticesType = ({ size, type }) => {\n logActionRequiredIf(\n 'Button has deprecated the `Size.EXTRA_SMALL` value for the `size` prop. Please use Size.SMALL instead.',\n size === Size.EXTRA_SMALL,\n );\n\n if (type && deprecatedTypes.includes(type) && type in deprecatedTypeMapMessage) {\n logActionRequired(\n `Button has deprecated the ${type} value for the \\`type\\` prop. Please update to ${deprecatedTypeMapMessage[type as DeprecatedTypeMapMessageType]}.`,\n );\n }\n};\n"],"names":["deprecatedTypeMap","Type","PRIMARY","ControlType","ACCENT","SECONDARY","LINK","PAY","POSITIVE","DANGER","NEGATIVE","oldTypePriorityMap","Priority","TERTIARY","deprecatedTypeMapMessage","deprecatedTypes","Object","keys","establishNewType","originalType","establishNewPriority","originalPriority","type","logDeprecationNotices","size","logActionRequiredIf","Size","EXTRA_SMALL","includes","logActionRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAMA,iBAAiB,GAA8B;AACnD,EAAA,CAACC,SAAI,CAACC,OAAO,GAAGC,mBAAW,CAACC,MAAM;AAClC,EAAA,CAACH,SAAI,CAACI,SAAS,GAAGF,mBAAW,CAACC,MAAM;AACpC,EAAA,CAACH,SAAI,CAACK,IAAI,GAAGH,mBAAW,CAACC,MAAM;AAC/B,EAAA,CAACH,SAAI,CAACM,GAAG,GAAGJ,mBAAW,CAACK,QAAQ;AAChC,EAAA,CAACP,SAAI,CAACQ,MAAM,GAAGN,mBAAW,CA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,qBAAqB,GAA8BA,CAAC;QAAEC,MAAI;AAAEF,EAAAA,IAAAA;AAAM,CAAA,KAAI;EACjFG,qCAAmB,CACjB,wGAAwG,EACxGD,MAAI,KAAKE,SAAI,CAACC,WAAW,CAC1B,CAAA;AAED,EAAA,IAAIL,IAAI,IAAIP,eAAe,CAACa,QAAQ,CAACN,IAAI,CAAC,IAAIA,IAAI,IAAIR,wBAAwB,EAAE;IAC9Ee,mCAAiB,CACf,6BAA6BP,IAAI,CAAA,+CAAA,EAAkDR,wBAAwB,CAACQ,IAAoC,CAAC,CAAA,CAAA,CAAG,CACrJ,CAAA;AACH,GAAA;AACF;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"legacyUtils.mjs","sources":["../../../src/button/legacyUtils/legacyUtils.ts"],"sourcesContent":["import { ControlType, Priority, Size, Type } from '../../common';\nimport { logActionRequired, logActionRequiredIf } from '../../utilities';\n\nconst deprecatedTypeMap: Record<Type, ControlType> = {\n [Type.PRIMARY]: ControlType.ACCENT,\n [Type.SECONDARY]: ControlType.ACCENT,\n [Type.LINK]: ControlType.ACCENT,\n [Type.PAY]: ControlType.POSITIVE,\n [Type.DANGER]: ControlType.NEGATIVE,\n};\n\ntype OldTypeKeys = Type.DANGER | Type.LINK | Type.SECONDARY;\nconst oldTypePriorityMap: Record<OldTypeKeys, Priority> = {\n [Type.DANGER]: Priority.SECONDARY,\n [Type.LINK]: Priority.TERTIARY,\n [Type.SECONDARY]: Priority.SECONDARY,\n};\n\nconst deprecatedTypeMapMessage = {\n [Type.DANGER]: 'Type.NEGATIVE',\n [Type.LINK]: 'ControlType.ACCENT with priority Priority.TERTIARY',\n [Type.PAY]: 'ControlType.POSITIVE',\n [Type.PRIMARY]: 'ControlType.ACCENT',\n [Type.SECONDARY]: 'ControlType.ACCENT with priority Priority.SECONDARY',\n};\n\nconst deprecatedTypes = Object.keys(deprecatedTypeMap);\n\ntype EstablishNewTypeType = (\n originalType: Type | (string & Record<never, never>) | null,\n) => `${ControlType}` | string | null;\n\nexport const establishNewType: EstablishNewTypeType = (originalType) =>\n originalType && originalType in deprecatedTypeMap\n ? deprecatedTypeMap[originalType as Type]\n : originalType;\n\ntype EstablishNewPriorityType = (\n originalPriority?: Priority | (string & Record<never, never>) | null,\n originalType?: OldTypeKeys | (string & Record<never, never>) | null,\n) => `${ControlType}` | string | null | undefined;\n\nexport const establishNewPriority: EstablishNewPriorityType = (originalPriority, originalType) => {\n const type = originalType ? establishNewType(originalType) : '';\n\n // The old SECONDARY and LINK types now map to priorities. If they're still using one of\n // these old types, ignore whatever priority they've passed and use this instead.\n if (originalType && originalType in oldTypePriorityMap) {\n return oldTypePriorityMap[originalType as OldTypeKeys];\n }\n // Only ControlType.ACCENT supports tertiary styles\n if (originalPriority === Priority.TERTIARY && type !== ControlType.ACCENT) {\n return Priority.SECONDARY;\n }\n return originalPriority;\n};\n\ntype DeprecatedTypeMapMessageType = keyof typeof deprecatedTypeMapMessage;\ntype LogDeprecationNoticesType = (params: {\n size: `${Size}`;\n type: DeprecatedTypeMapMessageType | (string & Record<never, never>) | null;\n}) => void;\nexport const logDeprecationNotices: LogDeprecationNoticesType = ({ size, type }) => {\n logActionRequiredIf(\n 'Button has deprecated the `Size.EXTRA_SMALL` value for the `size` prop. Please use Size.SMALL instead.',\n size === Size.EXTRA_SMALL,\n );\n\n if (type && deprecatedTypes.includes(type) && type in deprecatedTypeMapMessage) {\n logActionRequired(\n `Button has deprecated the ${type} value for the \\`type\\` prop. Please update to ${deprecatedTypeMapMessage[type as DeprecatedTypeMapMessageType]}.`,\n );\n }\n};\n"],"names":["deprecatedTypeMap","Type","PRIMARY","ControlType","ACCENT","SECONDARY","LINK","PAY","POSITIVE","DANGER","NEGATIVE","oldTypePriorityMap","Priority","TERTIARY","deprecatedTypeMapMessage","deprecatedTypes","Object","keys","establishNewType","originalType","establishNewPriority","originalPriority","type","logDeprecationNotices","size","logActionRequiredIf","Size","EXTRA_SMALL","includes","logActionRequired"],"mappings":";;;;;;;;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,CAAA;AAE/D;AACA;AACA,EAAA,IAAIA,YAAY,IAAIA,YAAY,IAAIR,kBAAkB,EAAE;IACtD,OAAOA,kBAAkB,CAACQ,YAA2B,CAAC,CAAA;AACxD,GAAA;AACA;EACA,IAAIE,gBAAgB,KAAKT,QAAQ,CAACC,QAAQ,IAAIS,IAAI,KAAKnB,WAAW,CAACC,MAAM,EAAE;IACzE,OAAOQ,QAAQ,CAACP,SAAS,CAAA;AAC3B,GAAA;AACA,EAAA,OAAOgB,gBAAgB,CAAA;AACzB,EAAC;AAOM,MAAME,qBAAqB,GAA8BA,CAAC;EAAEC,IAAI;AAAEF,EAAAA,IAAAA;AAAM,CAAA,KAAI;EACjFG,mBAAmB,CACjB,wGAAwG,EACxGD,IAAI,KAAKE,IAAI,CAACC,WAAW,CAC1B,CAAA;AAED,EAAA,IAAIL,IAAI,IAAIP,eAAe,CAACa,QAAQ,CAACN,IAAI,CAAC,IAAIA,IAAI,IAAIR,wBAAwB,EAAE;IAC9Ee,iBAAiB,CACf,6BAA6BP,IAAI,CAAA,+CAAA,EAAkDR,wBAAwB,CAACQ,IAAoC,CAAC,CAAA,CAAA,CAAG,CACrJ,CAAA;AACH,GAAA;AACF;;;;"}
1
+ {"version":3,"file":"legacyUtils.mjs","sources":["../../../src/button/legacyUtils/legacyUtils.ts"],"sourcesContent":["import { ControlType, Priority, Size, Type } from '../../common';\nimport { logActionRequired, logActionRequiredIf } from '../../utilities';\n\nconst deprecatedTypeMap: Record<Type, ControlType> = {\n [Type.PRIMARY]: ControlType.ACCENT,\n [Type.SECONDARY]: ControlType.ACCENT,\n [Type.LINK]: ControlType.ACCENT,\n [Type.PAY]: ControlType.POSITIVE,\n [Type.DANGER]: ControlType.NEGATIVE,\n};\n\ntype OldTypeKeys = Type.DANGER | Type.LINK | Type.SECONDARY;\nconst oldTypePriorityMap: Record<OldTypeKeys, Priority> = {\n [Type.DANGER]: Priority.SECONDARY,\n [Type.LINK]: Priority.TERTIARY,\n [Type.SECONDARY]: Priority.SECONDARY,\n};\n\nconst deprecatedTypeMapMessage = {\n [Type.DANGER]: 'Type.NEGATIVE',\n [Type.LINK]: 'ControlType.ACCENT with priority Priority.TERTIARY',\n [Type.PAY]: 'ControlType.POSITIVE',\n [Type.PRIMARY]: 'ControlType.ACCENT',\n [Type.SECONDARY]: 'ControlType.ACCENT with priority Priority.SECONDARY',\n};\n\nconst deprecatedTypes = Object.keys(deprecatedTypeMap);\n\ntype EstablishNewTypeType = (\n originalType: Type | (string & Record<never, never>) | null,\n) => `${ControlType}` | string | null;\n\nexport const establishNewType: EstablishNewTypeType = (originalType) =>\n originalType && originalType in deprecatedTypeMap\n ? deprecatedTypeMap[originalType as Type]\n : originalType;\n\ntype EstablishNewPriorityType = (\n originalPriority?: Priority | (string & Record<never, never>) | null,\n originalType?: OldTypeKeys | (string & Record<never, never>) | null,\n) => `${ControlType}` | string | null | undefined;\n\nexport const establishNewPriority: EstablishNewPriorityType = (originalPriority, originalType) => {\n const type = originalType ? establishNewType(originalType) : '';\n\n // The old SECONDARY and LINK types now map to priorities. If they're still using one of\n // these old types, ignore whatever priority they've passed and use this instead.\n if (originalType && originalType in oldTypePriorityMap) {\n return oldTypePriorityMap[originalType as OldTypeKeys];\n }\n // Only ControlType.ACCENT supports tertiary styles\n if (originalPriority === Priority.TERTIARY && type !== ControlType.ACCENT) {\n return Priority.SECONDARY;\n }\n return originalPriority;\n};\n\ntype DeprecatedTypeMapMessageType = keyof typeof deprecatedTypeMapMessage;\ntype LogDeprecationNoticesType = (params: {\n size?: `${Size}`;\n type?: DeprecatedTypeMapMessageType | (string & Record<never, never>) | null;\n}) => void;\nexport const logDeprecationNotices: LogDeprecationNoticesType = ({ size, type }) => {\n logActionRequiredIf(\n 'Button has deprecated the `Size.EXTRA_SMALL` value for the `size` prop. Please use Size.SMALL instead.',\n size === Size.EXTRA_SMALL,\n );\n\n if (type && deprecatedTypes.includes(type) && type in deprecatedTypeMapMessage) {\n logActionRequired(\n `Button has deprecated the ${type} value for the \\`type\\` prop. Please update to ${deprecatedTypeMapMessage[type as DeprecatedTypeMapMessageType]}.`,\n );\n }\n};\n"],"names":["deprecatedTypeMap","Type","PRIMARY","ControlType","ACCENT","SECONDARY","LINK","PAY","POSITIVE","DANGER","NEGATIVE","oldTypePriorityMap","Priority","TERTIARY","deprecatedTypeMapMessage","deprecatedTypes","Object","keys","establishNewType","originalType","establishNewPriority","originalPriority","type","logDeprecationNotices","size","logActionRequiredIf","Size","EXTRA_SMALL","includes","logActionRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAMA,iBAAiB,GAA8B;AACnD,EAAA,CAACC,IAAI,CAACC,OAAO,GAAGC,WAAW,CAACC,MAAM;AAClC,EAAA,CAACH,IAAI,CAACI,SAAS,GAAGF,WAAW,CAACC,MAAM;AACpC,EAAA,CAACH,IAAI,CAACK,IAAI,GAAGH,WAAW,CAACC,MAAM;AAC/B,EAAA,CAACH,IAAI,CAACM,GAAG,GAAGJ,WAAW,CAACK,QAAQ;AAChC,EAAA,CAACP,IAAI,CAACQ,MAAM,GAAGN,WAAW,CAACO,QAAAA;CAC5B,CAAA;AAGD,MAAMC,kBAAkB,GAAkC;AACxD,EAAA,CAACV,IAAI,CAACQ,MAAM,GAAGG,QAAQ,CAACP,SAAS;AACjC,EAAA,CAACJ,IAAI,CAACK,IAAI,GAAGM,QAAQ,CAACC,QAAQ;AAC9B,EAAA,CAACZ,IAAI,CAACI,SAAS,GAAGO,QAAQ,CAACP,SAAAA;CAC5B,CAAA;AAED,MAAMS,wBAAwB,GAAG;AAC/B,EAAA,CAACb,IAAI,CAACQ,MAAM,GAAG,eAAe;AAC9B,EAAA,CAACR,IAAI,CAACK,IAAI,GAAG,oDAAoD;AACjE,EAAA,CAACL,IAAI,CAACM,GAAG,GAAG,sBAAsB;AAClC,EAAA,CAACN,IAAI,CAACC,OAAO,GAAG,oBAAoB;EACpC,CAACD,IAAI,CAACI,SAAS,GAAG,qDAAA;CACnB,CAAA;AAED,MAAMU,eAAe,GAAGC,MAAM,CAACC,IAAI,CAACjB,iBAAiB,CAAC,CAAA;MAMzCkB,gBAAgB,GAA0BC,YAAY,IACjEA,YAAY,IAAIA,YAAY,IAAInB,iBAAiB,GAC7CA,iBAAiB,CAACmB,YAAoB,CAAC,GACvCA,aAAY;MAOLC,oBAAoB,GAA6BA,CAACC,gBAAgB,EAAEF,YAAY,KAAI;EAC/F,MAAMG,IAAI,GAAGH,YAAY,GAAGD,gBAAgB,CAACC,YAAY,CAAC,GAAG,EAAE,CAAA;AAE/D;AACA;AACA,EAAA,IAAIA,YAAY,IAAIA,YAAY,IAAIR,kBAAkB,EAAE;IACtD,OAAOA,kBAAkB,CAACQ,YAA2B,CAAC,CAAA;AACxD,GAAA;AACA;EACA,IAAIE,gBAAgB,KAAKT,QAAQ,CAACC,QAAQ,IAAIS,IAAI,KAAKnB,WAAW,CAACC,MAAM,EAAE;IACzE,OAAOQ,QAAQ,CAACP,SAAS,CAAA;AAC3B,GAAA;AACA,EAAA,OAAOgB,gBAAgB,CAAA;AACzB,EAAC;AAOM,MAAME,qBAAqB,GAA8BA,CAAC;EAAEC,IAAI;AAAEF,EAAAA,IAAAA;AAAM,CAAA,KAAI;EACjFG,mBAAmB,CACjB,wGAAwG,EACxGD,IAAI,KAAKE,IAAI,CAACC,WAAW,CAC1B,CAAA;AAED,EAAA,IAAIL,IAAI,IAAIP,eAAe,CAACa,QAAQ,CAACN,IAAI,CAAC,IAAIA,IAAI,IAAIR,wBAAwB,EAAE;IAC9Ee,iBAAiB,CACf,6BAA6BP,IAAI,CAAA,+CAAA,EAAkDR,wBAAwB,CAACQ,IAAoC,CAAC,CAAA,CAAA,CAAG,CACrJ,CAAA;AACH,GAAA;AACF;;;;"}
@@ -27,6 +27,11 @@
27
27
  "neptune.SelectInput.noResultsFound": "ไม่พบผลลัพธ์",
28
28
  "neptune.SelectOption.action.label": "เลือก",
29
29
  "neptune.SelectOption.selected.action.label": "เปลี่ยนตัวเลือกที่เลือกไว้",
30
+ "neptune.StatusIcon.iconLabel.error": "ข้อผิดพลาด:",
31
+ "neptune.StatusIcon.iconLabel.information": "ข้อมูล:",
32
+ "neptune.StatusIcon.iconLabel.pending": "รอดำเนินการ:",
33
+ "neptune.StatusIcon.iconLabel.success": "สำเร็จ:",
34
+ "neptune.StatusIcon.iconLabel.warning": "คำเตือน:",
30
35
  "neptune.Summary.statusDone": "รายการที่ทำแล้ว",
31
36
  "neptune.Summary.statusNotDone": "รายการที่ต้องทำ",
32
37
  "neptune.Summary.statusPending": "รายการที่รอดำเนินการ",
@@ -29,6 +29,11 @@ var th = {
29
29
  "neptune.SelectInput.noResultsFound": "ไม่พบผลลัพธ์",
30
30
  "neptune.SelectOption.action.label": "เลือก",
31
31
  "neptune.SelectOption.selected.action.label": "เปลี่ยนตัวเลือกที่เลือกไว้",
32
+ "neptune.StatusIcon.iconLabel.error": "ข้อผิดพลาด:",
33
+ "neptune.StatusIcon.iconLabel.information": "ข้อมูล:",
34
+ "neptune.StatusIcon.iconLabel.pending": "รอดำเนินการ:",
35
+ "neptune.StatusIcon.iconLabel.success": "สำเร็จ:",
36
+ "neptune.StatusIcon.iconLabel.warning": "คำเตือน:",
32
37
  "neptune.Summary.statusDone": "รายการที่ทำแล้ว",
33
38
  "neptune.Summary.statusNotDone": "รายการที่ต้องทำ",
34
39
  "neptune.Summary.statusPending": "รายการที่รอดำเนินการ",
@@ -1 +1 @@
1
- {"version":3,"file":"th.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"th.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -27,6 +27,11 @@ var th = {
27
27
  "neptune.SelectInput.noResultsFound": "ไม่พบผลลัพธ์",
28
28
  "neptune.SelectOption.action.label": "เลือก",
29
29
  "neptune.SelectOption.selected.action.label": "เปลี่ยนตัวเลือกที่เลือกไว้",
30
+ "neptune.StatusIcon.iconLabel.error": "ข้อผิดพลาด:",
31
+ "neptune.StatusIcon.iconLabel.information": "ข้อมูล:",
32
+ "neptune.StatusIcon.iconLabel.pending": "รอดำเนินการ:",
33
+ "neptune.StatusIcon.iconLabel.success": "สำเร็จ:",
34
+ "neptune.StatusIcon.iconLabel.warning": "คำเตือน:",
30
35
  "neptune.Summary.statusDone": "รายการที่ทำแล้ว",
31
36
  "neptune.Summary.statusNotDone": "รายการที่ต้องทำ",
32
37
  "neptune.Summary.statusPending": "รายการที่รอดำเนินการ",
@@ -1 +1 @@
1
- {"version":3,"file":"th.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"th.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -19,7 +19,7 @@ type AnchorProps = CommonProps & Omit<React.ComponentPropsWithRef<'a'>, 'type'>
19
19
  as?: 'a';
20
20
  };
21
21
  export type Props = ButtonProps | AnchorProps;
22
- type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
22
+ export type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
23
23
  declare const Button: import("react").ForwardRefExoticComponent<(Omit<ButtonProps, "ref"> | Omit<AnchorProps, "ref">) & import("react").RefAttributes<ButtonReferenceType>>;
24
24
  export default Button;
25
25
  //# sourceMappingURL=Button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/button/Button.tsx"],"names":[],"mappings":"AAIA,OAAO,EAIL,iBAAiB,EACjB,m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9C,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAExE,QAAA,MAAM,MAAM,uJAkGX,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -13,8 +13,8 @@ type EstablishNewPriorityType = (originalPriority?: Priority | (string & Record<
13
13
  export declare const establishNewPriority: EstablishNewPriorityType;
14
14
  type DeprecatedTypeMapMessageType = keyof typeof deprecatedTypeMapMessage;
15
15
  type LogDeprecationNoticesType = (params: {
16
- size: `${Size}`;
17
- type: DeprecatedTypeMapMessageType | (string & Record<never, never>) | null;
16
+ size?: `${Size}`;
17
+ type?: DeprecatedTypeMapMessageType | (string & Record<never, never>) | null;
18
18
  }) => void;
19
19
  export declare const logDeprecationNotices: LogDeprecationNoticesType;
20
20
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"legacyUtils.d.ts","sourceRoot":"","sources":["../../../../src/button/legacyUtils/legacyUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAWjE,KAAK,WAAW,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;AAO5D,QAAA,MAAM,wBAAwB;;;;;;CAM7B,CAAC;AAIF,KAAK,oBAAoB,GAAG,CAC1B,YAAY,EAAE,IAAI,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,KACxD,GAAG,WAAW,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC;AAEtC,eAAO,MAAM,gBAAgB,EAAE,oBAGb,CAAC;AAEnB,KAAK,wBAAwB,GAAG,CAC9B,gBAAgB,CAAC,EAAE,QAAQ,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,EACpE,YAAY,CAAC,EAAE,WAAW,GAAG,CAAC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,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,KAChE,GAAG,WAAW,EAAE,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAElD,eAAO,MAAM,oBAAoB,EAAE,wBAalC,CAAC;AAEF,KAAK,4BAA4B,GAAG,MAAM,OAAO,wBAAwB,CAAC;AAC1E,KAAK,yBAAyB,GAAG,CAAC,MAAM,EAAE;IACxC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC;IACjB,IAAI,CAAC,EAAE,4BAA4B,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC;CAC9E,KAAK,IAAI,CAAC;AACX,eAAO,MAAM,qBAAqB,EAAE,yBAWnC,CAAC"}
@@ -0,0 +1,158 @@
1
+ import { ReactElement } from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import { userEvent } from '@testing-library/user-event';
4
+ /**
5
+ * Custom `render` function which wraps passed elements in Provider component
6
+ * Source: https://testing-library.com/docs/example-react-intl/#creating-a-custom-render-function
7
+ *
8
+ */
9
+ declare function customRender(ui: ReactElement, { locale, messages, ...renderOptions }?: {
10
+ locale?: string | undefined;
11
+ messages?: {
12
+ "neptune.Button.loadingAriaLabel": string;
13
+ "neptune.Chips.ariaLabel": string;
14
+ "neptune.ClearButton.ariaLabel": string;
15
+ "neptune.CloseButton.ariaLabel": string;
16
+ "neptune.DateInput.day.label": string;
17
+ "neptune.DateInput.day.placeholder": string;
18
+ "neptune.DateInput.month.label": string;
19
+ "neptune.DateInput.year.label": string;
20
+ "neptune.DateInput.year.placeholder": string;
21
+ "neptune.DateLookup.day": string;
22
+ "neptune.DateLookup.goTo20YearView": string;
23
+ "neptune.DateLookup.month": string;
24
+ "neptune.DateLookup.next": string;
25
+ "neptune.DateLookup.previous": string;
26
+ "neptune.DateLookup.selected": string;
27
+ "neptune.DateLookup.twentyYears": string;
28
+ "neptune.DateLookup.year": string;
29
+ "neptune.FlowNavigation.back": string;
30
+ "neptune.Info.ariaLabel": string;
31
+ "neptune.Label.optional": string;
32
+ "neptune.Link.opensInNewTab": string;
33
+ "neptune.MoneyInput.Select.placeholder": string;
34
+ "neptune.MoneyInput.Select.selectCurrencyLabel": string;
35
+ "neptune.PhoneNumberInput.SelectInput.placeholder": string;
36
+ "neptune.Select.searchPlaceholder": string;
37
+ "neptune.SelectInput.noResultsFound": string;
38
+ "neptune.SelectOption.action.label": string;
39
+ "neptune.SelectOption.selected.action.label": string;
40
+ "neptune.StatusIcon.iconLabel.error": string;
41
+ "neptune.StatusIcon.iconLabel.information": string;
42
+ "neptune.StatusIcon.iconLabel.pending": string;
43
+ "neptune.StatusIcon.iconLabel.success": string;
44
+ "neptune.StatusIcon.iconLabel.warning": string;
45
+ "neptune.Summary.statusDone": string;
46
+ "neptune.Summary.statusNotDone": string;
47
+ "neptune.Summary.statusPending": string;
48
+ "neptune.Upload.csButtonText": string;
49
+ "neptune.Upload.csFailureText": string;
50
+ "neptune.Upload.csSuccessText": string;
51
+ "neptune.Upload.csTooLargeMessage": string;
52
+ "neptune.Upload.csWrongTypeMessage": string;
53
+ "neptune.Upload.psButtonText": string;
54
+ "neptune.Upload.psProcessingText": string;
55
+ "neptune.Upload.retry": string;
56
+ "neptune.Upload.usButtonText": string;
57
+ "neptune.Upload.usDropMessage": string;
58
+ "neptune.Upload.usPlaceholder": string;
59
+ "neptune.UploadButton.allFileTypes": string;
60
+ "neptune.UploadButton.dropFiles": string;
61
+ "neptune.UploadButton.instructions": string;
62
+ "neptune.UploadButton.uploadFile": string;
63
+ "neptune.UploadButton.uploadFiles": string;
64
+ "neptune.UploadInput.deleteModalBody": string;
65
+ "neptune.UploadInput.deleteModalCancelButtonText": string;
66
+ "neptune.UploadInput.deleteModalConfirmButtonText": string;
67
+ "neptune.UploadInput.deleteModalTitle": string;
68
+ "neptune.UploadInput.fileIsTooLarge": string;
69
+ "neptune.UploadInput.fileTypeNotSupported": string;
70
+ "neptune.UploadInput.maximumFilesAlreadyUploaded": string;
71
+ "neptune.UploadItem.deleting": string;
72
+ "neptune.UploadItem.removeFile": string;
73
+ "neptune.UploadItem.uploaded": string;
74
+ "neptune.UploadItem.uploadedFile": string;
75
+ "neptune.UploadItem.uploading": string;
76
+ "neptune.UploadItem.uploadingFailed": string;
77
+ } | undefined;
78
+ }): ReturnType<typeof render>;
79
+ /**
80
+ * Custom `renderHook` function which wraps passed elements in Provider component
81
+ * For more info: https://react-hooks-testing-library.com/usage/advanced-hooks#context
82
+ */
83
+ declare function customRenderHook(callback: () => unknown, { locale, messages }?: {
84
+ locale?: string | undefined;
85
+ messages?: {
86
+ "neptune.Button.loadingAriaLabel": string;
87
+ "neptune.Chips.ariaLabel": string;
88
+ "neptune.ClearButton.ariaLabel": string;
89
+ "neptune.CloseButton.ariaLabel": string;
90
+ "neptune.DateInput.day.label": string;
91
+ "neptune.DateInput.day.placeholder": string;
92
+ "neptune.DateInput.month.label": string;
93
+ "neptune.DateInput.year.label": string;
94
+ "neptune.DateInput.year.placeholder": string;
95
+ "neptune.DateLookup.day": string;
96
+ "neptune.DateLookup.goTo20YearView": string;
97
+ "neptune.DateLookup.month": string;
98
+ "neptune.DateLookup.next": string;
99
+ "neptune.DateLookup.previous": string;
100
+ "neptune.DateLookup.selected": string;
101
+ "neptune.DateLookup.twentyYears": string;
102
+ "neptune.DateLookup.year": string;
103
+ "neptune.FlowNavigation.back": string;
104
+ "neptune.Info.ariaLabel": string;
105
+ "neptune.Label.optional": string;
106
+ "neptune.Link.opensInNewTab": string;
107
+ "neptune.MoneyInput.Select.placeholder": string;
108
+ "neptune.MoneyInput.Select.selectCurrencyLabel": string;
109
+ "neptune.PhoneNumberInput.SelectInput.placeholder": string;
110
+ "neptune.Select.searchPlaceholder": string;
111
+ "neptune.SelectInput.noResultsFound": string;
112
+ "neptune.SelectOption.action.label": string;
113
+ "neptune.SelectOption.selected.action.label": string;
114
+ "neptune.StatusIcon.iconLabel.error": string;
115
+ "neptune.StatusIcon.iconLabel.information": string;
116
+ "neptune.StatusIcon.iconLabel.pending": string;
117
+ "neptune.StatusIcon.iconLabel.success": string;
118
+ "neptune.StatusIcon.iconLabel.warning": string;
119
+ "neptune.Summary.statusDone": string;
120
+ "neptune.Summary.statusNotDone": string;
121
+ "neptune.Summary.statusPending": string;
122
+ "neptune.Upload.csButtonText": string;
123
+ "neptune.Upload.csFailureText": string;
124
+ "neptune.Upload.csSuccessText": string;
125
+ "neptune.Upload.csTooLargeMessage": string;
126
+ "neptune.Upload.csWrongTypeMessage": string;
127
+ "neptune.Upload.psButtonText": string;
128
+ "neptune.Upload.psProcessingText": string;
129
+ "neptune.Upload.retry": string;
130
+ "neptune.Upload.usButtonText": string;
131
+ "neptune.Upload.usDropMessage": string;
132
+ "neptune.Upload.usPlaceholder": string;
133
+ "neptune.UploadButton.allFileTypes": string;
134
+ "neptune.UploadButton.dropFiles": string;
135
+ "neptune.UploadButton.instructions": string;
136
+ "neptune.UploadButton.uploadFile": string;
137
+ "neptune.UploadButton.uploadFiles": string;
138
+ "neptune.UploadInput.deleteModalBody": string;
139
+ "neptune.UploadInput.deleteModalCancelButtonText": string;
140
+ "neptune.UploadInput.deleteModalConfirmButtonText": string;
141
+ "neptune.UploadInput.deleteModalTitle": string;
142
+ "neptune.UploadInput.fileIsTooLarge": string;
143
+ "neptune.UploadInput.fileTypeNotSupported": string;
144
+ "neptune.UploadInput.maximumFilesAlreadyUploaded": string;
145
+ "neptune.UploadItem.deleting": string;
146
+ "neptune.UploadItem.removeFile": string;
147
+ "neptune.UploadItem.uploaded": string;
148
+ "neptune.UploadItem.uploadedFile": string;
149
+ "neptune.UploadItem.uploading": string;
150
+ "neptune.UploadItem.uploadingFailed": string;
151
+ } | undefined;
152
+ }): import("@testing-library/react").RenderHookResult<unknown, unknown>;
153
+ export * from '@testing-library/react';
154
+ export * from './fake-data';
155
+ export * from './story-config';
156
+ export * from './window-mock';
157
+ export { customRender as render, customRenderHook as renderHook, userEvent };
158
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test-utils/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAM,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,MAAM,EAAc,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAMxD;;;;GAIG;AACH,iBAAS,YAAY,CACnB,EAAE,EAAE,YAAY,EAChB,EAAE,MAAuB,EAAE,QAAa,EAAE,GAAG,aAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAK,GAChE,UAAU,CAAC,OAAO,MAAM,CAAC,CAK3B;AAED;;;GAGG;AACH,iBAAS,gBAAgB,CACvB,QAAQ,EAAE,MAAM,OAAO,EACvB,EAAE,MAAuB,EAAE,QAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAK,uEAKhD;AAED,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,gBAAgB,IAAI,UAAU,EAAE,SAAS,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom';
2
+ //# sourceMappingURL=jest.setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jest.setup.d.ts","sourceRoot":"","sources":["../../../src/test-utils/jest.setup.ts"],"names":[],"mappings":"AACA,OAAO,2BAA2B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.79.1",
3
+ "version": "46.80.0",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -72,6 +72,7 @@
72
72
  "@tsconfig/recommended": "^1.0.7",
73
73
  "@types/babel__core": "^7.20.5",
74
74
  "@types/commonmark": "^0.27.9",
75
+ "@types/enzyme": "^3.10.18",
75
76
  "@types/jest": "^29.5.12",
76
77
  "@types/lodash": "4.17.6",
77
78
  "@types/lodash.clamp": "^4.0.9",
@@ -5,6 +5,7 @@ import { render, screen, userEvent } from '../test-utils';
5
5
 
6
6
  import Button from '.';
7
7
  import messages from './Button.messages';
8
+ import { ButtonReferenceType } from './Button';
8
9
 
9
10
  const { ACCENT, POSITIVE, NEGATIVE } = ControlType;
10
11
  const { PAY, LINK, DANGER } = Type;
@@ -14,7 +15,7 @@ const { SMALL, MEDIUM, LARGE } = Size;
14
15
  describe('Button', () => {
15
16
  // eslint-disable-next-line no-console
16
17
  const originalWarn = console.warn;
17
- let mockedWarn;
18
+ let mockedWarn: typeof originalWarn;
18
19
 
19
20
  const props = {
20
21
  onClick: jest.fn(),
@@ -47,7 +48,7 @@ describe('Button', () => {
47
48
  });
48
49
 
49
50
  it('set `ref` to be true on Button', () => {
50
- const reference = createRef();
51
+ const reference = createRef<ButtonReferenceType>();
51
52
 
52
53
  expect(reference.current).toBeFalsy();
53
54
  render(<Button ref={reference}>Click me!</Button>);
@@ -51,7 +51,7 @@ type AnchorProps = CommonProps &
51
51
 
52
52
  export type Props = ButtonProps | AnchorProps;
53
53
 
54
- type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
54
+ export type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
55
55
 
56
56
  const Button = forwardRef<ButtonReferenceType, Props>(
57
57
  (
@@ -68,7 +68,7 @@ describe('establishNewType', () => {
68
68
 
69
69
  describe('logDeprecationNotices', () => {
70
70
  const origWarn = console.warn;
71
- let mockedWarn;
71
+ let mockedWarn: typeof origWarn;
72
72
 
73
73
  beforeAll(() => {
74
74
  mockedWarn = jest.fn();
@@ -57,8 +57,8 @@ export const establishNewPriority: EstablishNewPriorityType = (originalPriority,
57
57
 
58
58
  type DeprecatedTypeMapMessageType = keyof typeof deprecatedTypeMapMessage;
59
59
  type LogDeprecationNoticesType = (params: {
60
- size: `${Size}`;
61
- type: DeprecatedTypeMapMessageType | (string & Record<never, never>) | null;
60
+ size?: `${Size}`;
61
+ type?: DeprecatedTypeMapMessageType | (string & Record<never, never>) | null;
62
62
  }) => void;
63
63
  export const logDeprecationNotices: LogDeprecationNoticesType = ({ size, type }) => {
64
64
  logActionRequiredIf(
package/src/i18n/th.json CHANGED
@@ -27,6 +27,11 @@
27
27
  "neptune.SelectInput.noResultsFound": "ไม่พบผลลัพธ์",
28
28
  "neptune.SelectOption.action.label": "เลือก",
29
29
  "neptune.SelectOption.selected.action.label": "เปลี่ยนตัวเลือกที่เลือกไว้",
30
+ "neptune.StatusIcon.iconLabel.error": "ข้อผิดพลาด:",
31
+ "neptune.StatusIcon.iconLabel.information": "ข้อมูล:",
32
+ "neptune.StatusIcon.iconLabel.pending": "รอดำเนินการ:",
33
+ "neptune.StatusIcon.iconLabel.success": "สำเร็จ:",
34
+ "neptune.StatusIcon.iconLabel.warning": "คำเตือน:",
30
35
  "neptune.Summary.statusDone": "รายการที่ทำแล้ว",
31
36
  "neptune.Summary.statusNotDone": "รายการที่ต้องทำ",
32
37
  "neptune.Summary.statusPending": "รายการที่รอดำเนินการ",
@@ -1,15 +1,16 @@
1
1
  import { Position } from '../common';
2
2
  import { render, fireEvent, screen, mockMatchMedia } from '../test-utils';
3
3
 
4
- import Modal from './Modal';
4
+ import Modal, { ModalProps } from './Modal';
5
5
 
6
6
  mockMatchMedia();
7
7
 
8
8
  describe('Modal', () => {
9
- const props = {
9
+ const props: ModalProps = {
10
10
  onClose: jest.fn(),
11
11
  body: 'Some body',
12
12
  position: Position.TOP,
13
+ open: true,
13
14
  };
14
15
 
15
16
  beforeEach(() => {
@@ -17,14 +18,14 @@ describe('Modal', () => {
17
18
  });
18
19
 
19
20
  it(`doesn't calls onClose when click is inside modal`, () => {
20
- render(<Modal {...props} open />);
21
+ render(<Modal {...props} />);
21
22
 
22
23
  fireEvent.click(getDialog());
23
24
  expect(props.onClose).not.toHaveBeenCalled();
24
25
  });
25
26
 
26
27
  it('calls onClose if click outside the content', () => {
27
- render(<Modal {...props} open />);
28
+ render(<Modal {...props} />);
28
29
  expect(props.onClose).not.toHaveBeenCalled();
29
30
 
30
31
  fireEvent.click(screen.getByRole('presentation'));
@@ -32,7 +33,7 @@ describe('Modal', () => {
32
33
  });
33
34
 
34
35
  it("doesn't call onClose if click outside the content and closing on dimmer is disabled", () => {
35
- render(<Modal {...props} open disableDimmerClickToClose />);
36
+ render(<Modal {...props} disableDimmerClickToClose />);
36
37
 
37
38
  fireEvent.click(screen.getByRole('presentation'));
38
39
 
@@ -40,7 +41,7 @@ describe('Modal', () => {
40
41
  });
41
42
 
42
43
  it('calls onClose when Escape is pressed on Modal', () => {
43
- render(<Modal {...props} open />);
44
+ render(<Modal {...props} />);
44
45
  expect(props.onClose).not.toHaveBeenCalled();
45
46
 
46
47
  fireEvent.keyDown(getDialog(), { key: 'Escape' });
@@ -48,7 +49,7 @@ describe('Modal', () => {
48
49
  });
49
50
 
50
51
  it('calls onClose when Escape is pressed on document', () => {
51
- render(<Modal {...props} open />);
52
+ render(<Modal {...props} />);
52
53
  expect(props.onClose).not.toHaveBeenCalled();
53
54
 
54
55
  fireEvent.keyDown(document, { key: 'Escape' });
@@ -1,6 +1,6 @@
1
1
  import { shallow, mount } from 'enzyme';
2
2
 
3
- import SlidingPanel, { EXIT_ANIMATION } from './SlidingPanel';
3
+ import SlidingPanel from './SlidingPanel';
4
4
 
5
5
  describe('SlidingPanel', () => {
6
6
  let component;
@@ -0,0 +1,264 @@
1
+ /**
2
+ * @jest-environment node
3
+ */
4
+ import { renderToString } from 'react-dom/server';
5
+
6
+ import en from './i18n/en.json';
7
+
8
+ import * as exposedLibraryItems from '.';
9
+
10
+ type ExposedLibraryItemsType = typeof exposedLibraryItems;
11
+ type ExposedLibraryKeysType = keyof ExposedLibraryItemsType;
12
+
13
+ const excluded = new Set<ExposedLibraryKeysType | string>([
14
+ // hooks
15
+ 'useSnackbar',
16
+ 'useDirection',
17
+ 'useLayout',
18
+ 'useScreenSize',
19
+
20
+ // specific components
21
+ 'Provider',
22
+ 'BottomSheet',
23
+ 'DropFade',
24
+ 'SelectInputTriggerButton',
25
+ 'Panel',
26
+ 'ResponsivePanel',
27
+
28
+ // enums
29
+ 'Size',
30
+ 'Width',
31
+ 'Sentiment',
32
+ 'Variant',
33
+ 'Priority',
34
+ 'ControlType',
35
+ 'Type',
36
+ 'Theme',
37
+ 'DateMode',
38
+ 'MonthFormat',
39
+ 'Position',
40
+ 'Scroll',
41
+ 'ProfileType',
42
+ 'Breakpoint',
43
+ 'Layout',
44
+ 'Status',
45
+ 'MarkdownNodeType',
46
+ 'AvatarType',
47
+ 'InfoPresentation',
48
+ 'UploadStep',
49
+ 'DecisionPresentation',
50
+ 'DecisionType',
51
+ 'AlertArrowPosition',
52
+ 'LogoType',
53
+ 'FileType',
54
+ 'Direction',
55
+ 'Typography',
56
+
57
+ // types
58
+ 'SearchInputProps',
59
+ 'SelectInputItem',
60
+ 'SelectInputOptionContentProps',
61
+ 'SelectInputProps',
62
+ 'UploadedFile',
63
+ 'UploadError',
64
+ 'UploadResponse',
65
+ 'LayoutDirection',
66
+
67
+ // utils
68
+ 'SUPPORTED_LANGUAGES',
69
+ 'RTL_LANGUAGES',
70
+ 'DEFAULT_LANG',
71
+ 'DEFAULT_LOCALE',
72
+ 'adjustLocale',
73
+ 'getLangFromLocale',
74
+ 'getCountryFromLocale',
75
+ 'getDirectionFromLocale',
76
+ 'isServerSide',
77
+ 'isBrowser',
78
+
79
+ // other
80
+ 'translations',
81
+ ]);
82
+
83
+ function isNotExcluded(item: ExposedLibraryKeysType) {
84
+ return !excluded.has(item);
85
+ }
86
+
87
+ describe('Server side rendering', () => {
88
+ const componentNames = (
89
+ Object.keys(exposedLibraryItems) as (keyof ExposedLibraryItemsType)[]
90
+ ).filter((moduleName) => isNotExcluded(moduleName));
91
+
92
+ // stick all possible properties we might need to render all components in here
93
+ const allProps: Record<string, unknown> = {
94
+ currencies: [],
95
+ steps: [],
96
+ stepper: {
97
+ steps: [],
98
+ },
99
+ items: [],
100
+ children: 'yo',
101
+ id: '1',
102
+ text: 'test',
103
+ timeout: 0,
104
+ timestamp: 1,
105
+ title: 'trolo',
106
+ name: 'lolo',
107
+ label: 'hello',
108
+ content: 'world',
109
+ currency: 'XYZ',
110
+ amount: 0,
111
+ options: [],
112
+ model: {},
113
+ fields: {},
114
+ media: <h1>Hello</h1>,
115
+ onClick: jest.fn(),
116
+ onChange: jest.fn(),
117
+ status: 'processing',
118
+ size: 'sm',
119
+ body: 'body',
120
+ onClose: jest.fn(),
121
+ onDismiss: jest.fn(),
122
+ onRemove: jest.fn(),
123
+ radios: [
124
+ {
125
+ id: 'id-test-0',
126
+ label: 'Radio1',
127
+ },
128
+ {
129
+ id: 'id-test-0',
130
+ label: 'Radio1',
131
+ },
132
+ ],
133
+ position: 'left',
134
+ open: true,
135
+ tabs: [],
136
+ direction: {
137
+ xs: 'column',
138
+ sm: 'row',
139
+ md: 'column',
140
+ lg: 'row',
141
+ },
142
+ alt: '',
143
+ src: '',
144
+ details: 'yo',
145
+ icon: <svg />,
146
+ badge: <svg />,
147
+ link: 'link',
148
+ href: '#',
149
+ description: 'description',
150
+ 'aria-label': 'a label',
151
+ logo: <svg />,
152
+ chips: [
153
+ {
154
+ value: 1,
155
+ label: 'One',
156
+ },
157
+ {
158
+ value: 2,
159
+ label: 'Two',
160
+ },
161
+ ],
162
+ segments: [
163
+ {
164
+ id: '1',
165
+ value: 'accounting',
166
+ label: 'Accounting',
167
+ },
168
+ {
169
+ id: '2',
170
+ value: 'payroll',
171
+ label: 'Payroll',
172
+ },
173
+ {
174
+ id: '3',
175
+ value: 'reporting',
176
+ label: 'Reporting',
177
+ },
178
+ ],
179
+ };
180
+
181
+ // Override props in case of name collision.
182
+ const overrideProps: Partial<Record<keyof ExposedLibraryItemsType, Record<string, unknown>>> = {
183
+ Alert: { children: undefined, message: 'Fluffy kittens', size: undefined },
184
+ Card: { isExpanded: true },
185
+ CheckboxButton: { children: undefined, onChange: jest.fn() },
186
+ Typeahead: { size: 'md' },
187
+ InputWithDisplayFormat: { displayPattern: '**-**' },
188
+ TextareaWithDisplayFormat: { displayPattern: '**-**' },
189
+ Sticky: { position: 'top' },
190
+ MoneyInput: { selectedCurrency: { currency: 'EUR' } },
191
+ Tabs: { selected: 1, onTabSelect: jest.fn() },
192
+ Markdown: { children: '# Markdown string' },
193
+ SnackbarConsumer: {
194
+ children: jest.fn(),
195
+ },
196
+ SnackbarContext: {
197
+ children: jest.fn(),
198
+ },
199
+ Popover: {
200
+ children: <div />,
201
+ },
202
+ Progress: {
203
+ progress: { value: 50, max: 100 },
204
+ },
205
+ ProgressBar: {
206
+ progress: { value: 50, max: 100 },
207
+ },
208
+ Field: {
209
+ model: 'a model',
210
+ type: 'text',
211
+ children: <input />,
212
+ },
213
+ Input: {
214
+ children: undefined,
215
+ },
216
+ SearchInput: {
217
+ children: undefined,
218
+ },
219
+ TextArea: {
220
+ children: undefined,
221
+ },
222
+ Summary: {
223
+ status: 'done',
224
+ content: undefined,
225
+ },
226
+ Modal: { position: 'top' },
227
+ ActionOption: { action: 'hello' },
228
+ DateLookup: { value: new Date() },
229
+ Link: { size: 16 },
230
+ Tooltip: { children: <>yo</> },
231
+ SelectOption: { placeholder: { media: <img alt="img" /> } },
232
+ };
233
+
234
+ const { Provider } = exposedLibraryItems;
235
+ type ComponentWithProvider = React.ComponentType<unknown> & {
236
+ Provider?: React.ComponentType<unknown>;
237
+ };
238
+
239
+ componentNames.forEach((componentName: ExposedLibraryKeysType) => {
240
+ it(`can render component: ${componentName}`, () => {
241
+ const Component = exposedLibraryItems[componentName] as ComponentWithProvider;
242
+ const newProps = { ...allProps };
243
+
244
+ Object.keys(overrideProps[componentName] ?? {}).forEach((propertyToOverrideKey) => {
245
+ const key = propertyToOverrideKey as keyof (typeof overrideProps)[typeof componentName];
246
+ newProps[key] = overrideProps?.[componentName]?.[key];
247
+ });
248
+
249
+ const view = renderToString(
250
+ <Provider i18n={{ locale: 'en-GB', messages: en }}>
251
+ {componentName.endsWith('Context') && Component.Provider ? (
252
+ <Component.Provider {...newProps} />
253
+ ) : (
254
+ <div>
255
+ <Component {...newProps} />
256
+ </div>
257
+ )}
258
+ </Provider>,
259
+ );
260
+
261
+ expect(view).toStrictEqual(expect.any(String));
262
+ });
263
+ });
264
+ });
@@ -1,8 +1,9 @@
1
+ import { ReactElement, FC } from 'react';
1
2
  import { render, renderHook } from '@testing-library/react';
2
3
  import { userEvent } from '@testing-library/user-event';
3
4
 
4
5
  import { Provider } from '..';
5
- import { DEFAULT_LOCALE } from '../common/locale';
6
+ import { DEFAULT_LOCALE } from '../common';
6
7
  import en from '../i18n/en.json';
7
8
 
8
9
  /**
@@ -10,9 +11,11 @@ import en from '../i18n/en.json';
10
11
  * Source: https://testing-library.com/docs/example-react-intl/#creating-a-custom-render-function
11
12
  *
12
13
  */
13
- function customRender(ui, { locale = DEFAULT_LOCALE, messages = en, ...renderOptions } = {}) {
14
- // eslint-disable-next-line react/prop-types
15
- const Wrapper = ({ children }) => {
14
+ function customRender(
15
+ ui: ReactElement,
16
+ { locale = DEFAULT_LOCALE, messages = en, ...renderOptions } = {},
17
+ ): ReturnType<typeof render> {
18
+ const Wrapper: FC<{ children: React.ReactNode }> = ({ children }) => {
16
19
  return <Provider i18n={{ locale, messages }}>{children}</Provider>;
17
20
  };
18
21
  return render(ui, { wrapper: Wrapper, ...renderOptions });
@@ -21,9 +24,11 @@ function customRender(ui, { locale = DEFAULT_LOCALE, messages = en, ...renderOpt
21
24
  /**
22
25
  * Custom `renderHook` function which wraps passed elements in Provider component
23
26
  * For more info: https://react-hooks-testing-library.com/usage/advanced-hooks#context
24
- *
25
27
  */
26
- function customRenderHook(callback, { locale = DEFAULT_LOCALE, messages = en } = {}) {
28
+ function customRenderHook(
29
+ callback: () => unknown,
30
+ { locale = DEFAULT_LOCALE, messages = en } = {},
31
+ ) {
27
32
  return renderHook(callback, {
28
33
  wrapper: ({ children }) => <Provider i18n={{ locale, messages }}>{children}</Provider>,
29
34
  });
@@ -1,14 +1,19 @@
1
- require('@testing-library/jest-dom');
1
+ import util from 'node:util';
2
+ import '@testing-library/jest-dom';
2
3
 
3
- const { default: Adapter } = require('@cfaester/enzyme-adapter-react-18');
4
- const Enzyme = require('enzyme');
5
- const util = require('node:util');
4
+ import Adapter from '@cfaester/enzyme-adapter-react-18';
5
+ import Enzyme from 'enzyme';
6
+ import fetchMock from 'jest-fetch-mock';
6
7
 
7
- global.fetch = require('jest-fetch-mock');
8
+ global.fetch = fetchMock as unknown as typeof global.fetch;
8
9
 
10
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
9
11
  Enzyme.configure({ adapter: new Adapter() });
10
12
 
11
- global.requestAnimationFrame = (callback) => callback();
13
+ global.requestAnimationFrame = (callback: (time: number) => void): number => {
14
+ callback(performance.now());
15
+ return 0;
16
+ };
12
17
 
13
18
  Object.defineProperty(global, 'TextEncoder', {
14
19
  value: util.TextEncoder,
@@ -18,7 +23,7 @@ Object.defineProperty(global, 'TextEncoder', {
18
23
  // This mock will make tests fail when props error occurs.
19
24
  const { error, warn } = console;
20
25
  // eslint-disable-next-line no-console
21
- console.error = (message, ...args) => {
26
+ console.error = (message: string, ...args: unknown[]): void => {
22
27
  if (/(Invalid prop|Failed prop type)/i.test(message)) {
23
28
  throw new Error(message);
24
29
  }
@@ -27,7 +32,7 @@ console.error = (message, ...args) => {
27
32
  };
28
33
 
29
34
  // eslint-disable-next-line no-console
30
- console.warn = (message, ...args) => {
35
+ console.warn = (message: string, ...args: unknown[]): void => {
31
36
  if (/(Call to useTheme outside a ThemeProvider)/i.test(message)) {
32
37
  return;
33
38
  }
package/src/ssr.spec.js DELETED
@@ -1,256 +0,0 @@
1
- /**
2
- * @jest-environment node
3
- */
4
- import { renderToString } from 'react-dom/server';
5
-
6
- import en from './i18n/en.json';
7
-
8
- import * as exposedLibraryItems from '.';
9
-
10
- const excluded = new Set([
11
- // hooks
12
- 'useSnackbar',
13
- 'useDirection',
14
- 'useLayout',
15
- 'useScreenSize',
16
-
17
- // specific components
18
- 'Provider',
19
- 'BottomSheet',
20
- 'DropFade',
21
- 'SelectInputTriggerButton',
22
- 'Panel',
23
- 'ResponsivePanel',
24
-
25
- // enums
26
- 'Size',
27
- 'Width',
28
- 'Sentiment',
29
- 'Variant',
30
- 'Priority',
31
- 'ControlType',
32
- 'Type',
33
- 'Theme',
34
- 'DateMode',
35
- 'MonthFormat',
36
- 'Position',
37
- 'Scroll',
38
- 'ProfileType',
39
- 'Breakpoint',
40
- 'Layout',
41
- 'Status',
42
- 'MarkdownNodeType',
43
- 'AvatarType',
44
- 'InfoPresentation',
45
- 'UploadStep',
46
- 'DecisionPresentation',
47
- 'DecisionType',
48
- 'AlertArrowPosition',
49
- 'LogoType',
50
- 'FileType',
51
- 'Direction',
52
- 'Typography',
53
-
54
- // types
55
- 'SearchInputProps',
56
- 'SelectInputItem',
57
- 'SelectInputOptionContentProps',
58
- 'SelectInputProps',
59
- 'UploadedFile',
60
- 'UploadError',
61
- 'UploadResponse',
62
- 'LayoutDirection',
63
-
64
- // utils
65
- 'SUPPORTED_LANGUAGES',
66
- 'RTL_LANGUAGES',
67
- 'DEFAULT_LANG',
68
- 'DEFAULT_LOCALE',
69
- 'adjustLocale',
70
- 'getLangFromLocale',
71
- 'getCountryFromLocale',
72
- 'getDirectionFromLocale',
73
- 'isServerSide',
74
- 'isBrowser',
75
-
76
- // other
77
- 'translations',
78
- ]);
79
-
80
- function isNotExcluded(item) {
81
- return !excluded.has(item);
82
- }
83
-
84
- describe('Server side rendering', () => {
85
- it('can render components', () => {
86
- const componentNames = Object.keys(exposedLibraryItems).filter(isNotExcluded);
87
- expect(componentNames.length).toBeGreaterThan(0);
88
-
89
- // stick all possible properties we might need to render all components in here
90
- const allProps = {
91
- currencies: [],
92
- steps: [],
93
- stepper: {
94
- steps: [],
95
- },
96
- items: [],
97
- children: 'yo',
98
- id: '1',
99
- text: 'test',
100
- timeout: 0,
101
- timestamp: 1,
102
- title: 'trolo',
103
- name: 'lolo',
104
- label: 'hello',
105
- content: 'world',
106
- currency: 'XYZ',
107
- amount: 0,
108
- options: [],
109
- model: {},
110
- fields: {},
111
- media: <h1>Hello</h1>,
112
- onClick: jest.fn(),
113
- onChange: jest.fn(),
114
- status: 'processing',
115
- size: 'sm',
116
- body: 'body',
117
- onClose: jest.fn(),
118
- onDismiss: jest.fn(),
119
- onRemove: jest.fn(),
120
- radios: [
121
- {
122
- id: 'id-test-0',
123
- label: 'Radio1',
124
- },
125
- {
126
- id: 'id-test-0',
127
- label: 'Radio1',
128
- },
129
- ],
130
- position: 'left',
131
- open: true,
132
- tabs: [],
133
- direction: {
134
- xs: 'column',
135
- sm: 'row',
136
- md: 'column',
137
- lg: 'row',
138
- },
139
- alt: '',
140
- src: '',
141
- details: 'yo',
142
- icon: <svg />,
143
- badge: <svg />,
144
- link: 'link',
145
- href: '#',
146
- description: 'description',
147
- 'aria-label': 'a label',
148
- logo: <svg />,
149
- chips: [
150
- {
151
- value: 1,
152
- label: 'One',
153
- },
154
- {
155
- value: 2,
156
- label: 'Two',
157
- },
158
- ],
159
- segments: [
160
- {
161
- id: '1',
162
- value: 'accounting',
163
- label: 'Accounting',
164
- },
165
- {
166
- id: '2',
167
- value: 'payroll',
168
- label: 'Payroll',
169
- },
170
- {
171
- id: '3',
172
- value: 'reporting',
173
- label: 'Reporting',
174
- },
175
- ],
176
- };
177
-
178
- // Override props in case of name collision.
179
- const overrideProps = {
180
- Alert: { children: undefined, message: 'Fluffy kittens', size: undefined },
181
- Card: { isExpanded: true },
182
- CheckboxButton: { children: undefined, onChange: jest.fn() },
183
- Typeahead: { size: 'md' },
184
- InputWithDisplayFormat: { displayPattern: '**-**' },
185
- TextareaWithDisplayFormat: { displayPattern: '**-**' },
186
- Sticky: { position: 'top' },
187
- MoneyInput: { selectedCurrency: { currency: 'EUR' } },
188
- Tabs: { selected: 1, onTabSelect: jest.fn() },
189
- Markdown: { children: '# Markdown string' },
190
- SnackbarConsumer: {
191
- children: jest.fn(),
192
- },
193
- SnackbarContext: {
194
- children: jest.fn(),
195
- },
196
- Popover: {
197
- children: <div />,
198
- },
199
- Progress: {
200
- progress: { value: 50, max: 100 },
201
- },
202
- ProgressBar: {
203
- progress: { value: 50, max: 100 },
204
- },
205
- Field: {
206
- model: 'a model',
207
- type: 'text',
208
- children: <input />,
209
- },
210
- Input: {
211
- children: undefined,
212
- },
213
- SearchInput: {
214
- children: undefined,
215
- },
216
- TextArea: {
217
- children: undefined,
218
- },
219
- Summary: {
220
- status: 'done',
221
- content: undefined,
222
- },
223
- Tile: {
224
- media: <img alt="img" />,
225
- },
226
- Modal: { position: 'top' },
227
- ActionOption: { action: 'hello' },
228
- DateLookup: { value: new Date() },
229
- Link: { size: 16 },
230
- Tooltip: { children: <>yo</> },
231
- SelectOption: { placeholder: { media: <img alt="img" /> } },
232
- };
233
-
234
- const { Provider } = exposedLibraryItems;
235
- componentNames.forEach((componentName) => {
236
- const Component = exposedLibraryItems[componentName];
237
- const newProps = { ...allProps };
238
-
239
- Object.keys(overrideProps[componentName] || {}).forEach((propertyToOverrideKey) => {
240
- newProps[propertyToOverrideKey] = overrideProps[componentName][propertyToOverrideKey];
241
- });
242
-
243
- const view = renderToString(
244
- <Provider i18n={{ locale: 'en-GB', messages: en }}>
245
- {componentName.endsWith('Context') ? (
246
- <Component.Provider {...newProps} />
247
- ) : (
248
- <Component {...newProps} />
249
- )}
250
- </Provider>,
251
- );
252
-
253
- expect(view).toStrictEqual(expect.any(String));
254
- });
255
- });
256
- });
File without changes