@pega/cosmos-react-core 5.0.0-dev.2.1 → 5.0.0-dev.3.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 (229) hide show
  1. package/lib/components/AIButton/AIButton.d.ts +1 -1
  2. package/lib/components/Actions/Actions.d.ts +1 -1
  3. package/lib/components/AdditionalInfo/AdditionalInfo.d.ts +1 -1
  4. package/lib/components/AppShell/AppShell.styles.d.ts +2 -2
  5. package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
  6. package/lib/components/AppShell/AppShell.styles.js +2 -1
  7. package/lib/components/AppShell/AppShell.styles.js.map +1 -1
  8. package/lib/components/AppShell/NavigationList.js +2 -2
  9. package/lib/components/AppShell/NavigationList.js.map +1 -1
  10. package/lib/components/Avatar/Avatar.d.ts +1 -1
  11. package/lib/components/Avatar/Avatar.d.ts.map +1 -1
  12. package/lib/components/Avatar/Avatar.js +4 -10
  13. package/lib/components/Avatar/Avatar.js.map +1 -1
  14. package/lib/components/Backdrop/Backdrop.d.ts +2 -2
  15. package/lib/components/Badges/Alert.d.ts +1 -1
  16. package/lib/components/Badges/Count.d.ts +1 -1
  17. package/lib/components/Badges/Keyboard.d.ts +1 -1
  18. package/lib/components/Badges/Status.d.ts +1 -1
  19. package/lib/components/Banner/Banner.d.ts +1 -1
  20. package/lib/components/Boolean/BooleanDisplay.d.ts +1 -1
  21. package/lib/components/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  22. package/lib/components/Breadcrumbs/Breadcrumbs.js +27 -16
  23. package/lib/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
  24. package/lib/components/ComboBox/ComboBox.d.ts +2 -2
  25. package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
  26. package/lib/components/ComboBox/ComboBox.js +47 -29
  27. package/lib/components/ComboBox/ComboBox.js.map +1 -1
  28. package/lib/components/ComboBox/ComboBoxInput.d.ts.map +1 -1
  29. package/lib/components/ComboBox/ComboBoxInput.js +1 -7
  30. package/lib/components/ComboBox/ComboBoxInput.js.map +1 -1
  31. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.d.ts.map +1 -1
  32. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +1 -5
  33. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
  34. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.d.ts.map +1 -1
  35. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js +2 -10
  36. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js.map +1 -1
  37. package/lib/components/CompositeInput/CompositeInput.d.ts.map +1 -1
  38. package/lib/components/CompositeInput/CompositeInput.js +1 -12
  39. package/lib/components/CompositeInput/CompositeInput.js.map +1 -1
  40. package/lib/components/Configuration/Configuration.d.ts +19 -9
  41. package/lib/components/Configuration/Configuration.d.ts.map +1 -1
  42. package/lib/components/Configuration/Configuration.js +49 -27
  43. package/lib/components/Configuration/Configuration.js.map +1 -1
  44. package/lib/components/Currency/CurrencyInput.d.ts.map +1 -1
  45. package/lib/components/Currency/CurrencyInput.js +2 -13
  46. package/lib/components/Currency/CurrencyInput.js.map +1 -1
  47. package/lib/components/DangerButton/DangerButton.d.ts +1 -1
  48. package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
  49. package/lib/components/DateTime/Input/DateInput.js +1 -12
  50. package/lib/components/DateTime/Input/DateInput.js.map +1 -1
  51. package/lib/components/DateTime/Input/DateTime.styles.d.ts.map +1 -1
  52. package/lib/components/DateTime/Input/DateTime.styles.js +26 -20
  53. package/lib/components/DateTime/Input/DateTime.styles.js.map +1 -1
  54. package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
  55. package/lib/components/DateTime/Input/DateTimeInput.js +1 -12
  56. package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
  57. package/lib/components/DateTime/Input/Duration/DurationInput.d.ts.map +1 -1
  58. package/lib/components/DateTime/Input/Duration/DurationInput.js +2 -11
  59. package/lib/components/DateTime/Input/Duration/DurationInput.js.map +1 -1
  60. package/lib/components/DateTime/Input/MonthInput.d.ts.map +1 -1
  61. package/lib/components/DateTime/Input/MonthInput.js +1 -11
  62. package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
  63. package/lib/components/DateTime/Input/QuarterInput.d.ts.map +1 -1
  64. package/lib/components/DateTime/Input/QuarterInput.js +1 -11
  65. package/lib/components/DateTime/Input/QuarterInput.js.map +1 -1
  66. package/lib/components/DateTime/Input/TimeInput.d.ts.map +1 -1
  67. package/lib/components/DateTime/Input/TimeInput.js +1 -12
  68. package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
  69. package/lib/components/DateTime/Input/WeekInput.d.ts.map +1 -1
  70. package/lib/components/DateTime/Input/WeekInput.js +1 -11
  71. package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
  72. package/lib/components/Drawer/Drawer.js +1 -1
  73. package/lib/components/Drawer/Drawer.js.map +1 -1
  74. package/lib/components/File/FileDisplay.d.ts.map +1 -1
  75. package/lib/components/File/FileDisplay.js +1 -5
  76. package/lib/components/File/FileDisplay.js.map +1 -1
  77. package/lib/components/File/FileInput.d.ts.map +1 -1
  78. package/lib/components/File/FileInput.js +1 -11
  79. package/lib/components/File/FileInput.js.map +1 -1
  80. package/lib/components/File/FileVisual.d.ts +1 -1
  81. package/lib/components/File/FileVisual.d.ts.map +1 -1
  82. package/lib/components/File/FileVisual.js +15 -11
  83. package/lib/components/File/FileVisual.js.map +1 -1
  84. package/lib/components/Form/Form.d.ts +6 -4
  85. package/lib/components/Form/Form.d.ts.map +1 -1
  86. package/lib/components/Form/Form.js +7 -4
  87. package/lib/components/Form/Form.js.map +1 -1
  88. package/lib/components/Form/Form.test-ids.d.ts +2 -0
  89. package/lib/components/Form/Form.test-ids.d.ts.map +1 -0
  90. package/lib/components/Form/Form.test-ids.js +3 -0
  91. package/lib/components/Form/Form.test-ids.js.map +1 -0
  92. package/lib/components/HTML/HTML.d.ts +6 -4
  93. package/lib/components/HTML/HTML.d.ts.map +1 -1
  94. package/lib/components/HTML/HTML.js +7 -4
  95. package/lib/components/HTML/HTML.js.map +1 -1
  96. package/lib/components/HTML/HTML.test-ids.d.ts +2 -0
  97. package/lib/components/HTML/HTML.test-ids.d.ts.map +1 -0
  98. package/lib/components/HTML/HTML.test-ids.js +3 -0
  99. package/lib/components/HTML/HTML.test-ids.js.map +1 -0
  100. package/lib/components/Icon/Icon.d.ts +37 -8
  101. package/lib/components/Icon/Icon.d.ts.map +1 -1
  102. package/lib/components/Icon/Icon.js +97 -11
  103. package/lib/components/Icon/Icon.js.map +1 -1
  104. package/lib/components/Input/Input.d.ts.map +1 -1
  105. package/lib/components/Input/Input.js +2 -27
  106. package/lib/components/Input/Input.js.map +1 -1
  107. package/lib/components/Lightbox/Lightbox.d.ts +4 -2
  108. package/lib/components/Lightbox/Lightbox.d.ts.map +1 -1
  109. package/lib/components/Lightbox/Lightbox.js +11 -9
  110. package/lib/components/Lightbox/Lightbox.js.map +1 -1
  111. package/lib/components/Lightbox/Lightbox.styles.d.ts +1 -1
  112. package/lib/components/Lightbox/Lightbox.styles.d.ts.map +1 -1
  113. package/lib/components/Lightbox/Lightbox.test-ids.d.ts +2 -0
  114. package/lib/components/Lightbox/Lightbox.test-ids.d.ts.map +1 -0
  115. package/lib/components/Lightbox/Lightbox.test-ids.js +12 -0
  116. package/lib/components/Lightbox/Lightbox.test-ids.js.map +1 -0
  117. package/lib/components/Lightbox/Lightbox.types.d.ts +2 -2
  118. package/lib/components/Lightbox/Lightbox.types.d.ts.map +1 -1
  119. package/lib/components/Lightbox/Lightbox.types.js.map +1 -1
  120. package/lib/components/Link/Link.d.ts +6 -4
  121. package/lib/components/Link/Link.d.ts.map +1 -1
  122. package/lib/components/Link/Link.js +8 -6
  123. package/lib/components/Link/Link.js.map +1 -1
  124. package/lib/components/Link/Link.test-ids.d.ts +2 -0
  125. package/lib/components/Link/Link.test-ids.d.ts.map +1 -0
  126. package/lib/components/Link/Link.test-ids.js +7 -0
  127. package/lib/components/Link/Link.test-ids.js.map +1 -0
  128. package/lib/components/ListToolbar/ListToolbar.d.ts +1 -1
  129. package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
  130. package/lib/components/ListToolbar/ListToolbar.js +10 -8
  131. package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
  132. package/lib/components/ListToolbar/ListToolbar.styles.d.ts +1 -1
  133. package/lib/components/ListToolbar/ListToolbar.styles.d.ts.map +1 -1
  134. package/lib/components/Location/LocationDisplay.d.ts.map +1 -1
  135. package/lib/components/Location/LocationDisplay.js +1 -6
  136. package/lib/components/Location/LocationDisplay.js.map +1 -1
  137. package/lib/components/Location/LocationInput.d.ts.map +1 -1
  138. package/lib/components/Location/LocationInput.js +3 -30
  139. package/lib/components/Location/LocationInput.js.map +1 -1
  140. package/lib/components/Location/LocationView.d.ts +1 -1
  141. package/lib/components/Location/LocationView.d.ts.map +1 -1
  142. package/lib/components/Menu/Menu.styles.d.ts +1 -1
  143. package/lib/components/Menu/Menu.styles.d.ts.map +1 -1
  144. package/lib/components/Menu/Menu.styles.js +2 -2
  145. package/lib/components/Menu/Menu.styles.js.map +1 -1
  146. package/lib/components/Menu/MenuItem.d.ts.map +1 -1
  147. package/lib/components/Menu/MenuItem.js +1 -1
  148. package/lib/components/Menu/MenuItem.js.map +1 -1
  149. package/lib/components/Modal/Modal.js +1 -1
  150. package/lib/components/Modal/Modal.js.map +1 -1
  151. package/lib/components/MultiStepForm/FormProgress.styles.d.ts +1 -1
  152. package/lib/components/MultiStepForm/FormProgress.styles.d.ts.map +1 -1
  153. package/lib/components/MultiStepForm/FormProgress.styles.js +1 -2
  154. package/lib/components/MultiStepForm/FormProgress.styles.js.map +1 -1
  155. package/lib/components/Number/NumberInput.d.ts.map +1 -1
  156. package/lib/components/Number/NumberInput.js +3 -15
  157. package/lib/components/Number/NumberInput.js.map +1 -1
  158. package/lib/components/Phone/PhoneInput.d.ts.map +1 -1
  159. package/lib/components/Phone/PhoneInput.js +1 -12
  160. package/lib/components/Phone/PhoneInput.js.map +1 -1
  161. package/lib/components/Progress/Progress.styles.d.ts +1 -1
  162. package/lib/components/Progress/Progress.styles.d.ts.map +1 -1
  163. package/lib/components/RadioCheckGroup/RadioCheckGroup.d.ts.map +1 -1
  164. package/lib/components/RadioCheckGroup/RadioCheckGroup.js +1 -8
  165. package/lib/components/RadioCheckGroup/RadioCheckGroup.js.map +1 -1
  166. package/lib/components/SearchInput/SearchInput.d.ts +2 -2
  167. package/lib/components/SearchInput/SearchInput.d.ts.map +1 -1
  168. package/lib/components/SearchInput/SearchInput.js +69 -19
  169. package/lib/components/SearchInput/SearchInput.js.map +1 -1
  170. package/lib/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
  171. package/lib/components/SearchInput/SearchInput.styles.js +4 -0
  172. package/lib/components/SearchInput/SearchInput.styles.js.map +1 -1
  173. package/lib/components/Select/Select.d.ts.map +1 -1
  174. package/lib/components/Select/Select.js +1 -14
  175. package/lib/components/Select/Select.js.map +1 -1
  176. package/lib/components/Slider/Slider.d.ts.map +1 -1
  177. package/lib/components/Slider/Slider.js +2 -12
  178. package/lib/components/Slider/Slider.js.map +1 -1
  179. package/lib/components/TextArea/TextArea.d.ts.map +1 -1
  180. package/lib/components/TextArea/TextArea.js +2 -30
  181. package/lib/components/TextArea/TextArea.js.map +1 -1
  182. package/lib/components/Toaster/Toaster.d.ts +4 -2
  183. package/lib/components/Toaster/Toaster.d.ts.map +1 -1
  184. package/lib/components/Toaster/Toaster.js +18 -16
  185. package/lib/components/Toaster/Toaster.js.map +1 -1
  186. package/lib/components/Toaster/Toaster.test-ids.d.ts +2 -0
  187. package/lib/components/Toaster/Toaster.test-ids.d.ts.map +1 -0
  188. package/lib/components/Toaster/Toaster.test-ids.js +3 -0
  189. package/lib/components/Toaster/Toaster.test-ids.js.map +1 -0
  190. package/lib/components/Toaster/Toaster.types.d.ts +2 -1
  191. package/lib/components/Toaster/Toaster.types.d.ts.map +1 -1
  192. package/lib/components/Toaster/Toaster.types.js.map +1 -1
  193. package/lib/components/Tooltip/Tooltip.d.ts +6 -4
  194. package/lib/components/Tooltip/Tooltip.d.ts.map +1 -1
  195. package/lib/components/Tooltip/Tooltip.js +7 -5
  196. package/lib/components/Tooltip/Tooltip.js.map +1 -1
  197. package/lib/components/Tooltip/Tooltip.test-ids.d.ts +2 -0
  198. package/lib/components/Tooltip/Tooltip.test-ids.d.ts.map +1 -0
  199. package/lib/components/Tooltip/Tooltip.test-ids.js +3 -0
  200. package/lib/components/Tooltip/Tooltip.test-ids.js.map +1 -0
  201. package/lib/components/Tree/StandardTree.styles.d.ts +5 -3
  202. package/lib/components/Tree/StandardTree.styles.d.ts.map +1 -1
  203. package/lib/components/Tree/Tree.d.ts +6 -4
  204. package/lib/components/Tree/Tree.d.ts.map +1 -1
  205. package/lib/components/Tree/Tree.js +7 -3
  206. package/lib/components/Tree/Tree.js.map +1 -1
  207. package/lib/components/Tree/Tree.test-ids.d.ts +3 -0
  208. package/lib/components/Tree/Tree.test-ids.d.ts.map +1 -0
  209. package/lib/components/Tree/Tree.test-ids.js +4 -0
  210. package/lib/components/Tree/Tree.test-ids.js.map +1 -0
  211. package/lib/hooks/useActiveDescendant.d.ts.map +1 -1
  212. package/lib/hooks/useActiveDescendant.js +4 -1
  213. package/lib/hooks/useActiveDescendant.js.map +1 -1
  214. package/lib/hooks/useI18n.d.ts +35 -0
  215. package/lib/hooks/useI18n.d.ts.map +1 -1
  216. package/lib/i18n/default.d.ts +35 -0
  217. package/lib/i18n/default.d.ts.map +1 -1
  218. package/lib/i18n/default.js +37 -1
  219. package/lib/i18n/default.js.map +1 -1
  220. package/lib/i18n/i18n.d.ts +35 -0
  221. package/lib/i18n/i18n.d.ts.map +1 -1
  222. package/lib/theme/theme.d.ts +37 -6
  223. package/lib/theme/theme.d.ts.map +1 -1
  224. package/lib/theme/themeDefinition.json +12 -4
  225. package/lib/theme/themeOverrides.schema.json +22 -3
  226. package/lib/theme/themes/aries2023DarkTheme.json +1 -3
  227. package/lib/theme/themes/aries2023Theme.json +1 -1
  228. package/lib/theme/themes/darkTheme.json +1 -3
  229. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"FileInput.js","sourceRoot":"","sources":["../../../src/components/File/FileInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EAEV,WAAW,EAGX,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AASxC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,WAAiC,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,cAAuC,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,YAAY,CAAC,aAAa,CAAC,CAAC;AAyC5B,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,WAAW,CAAC,CAAwB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;IAC/F,OAAO,GAAG,CAAA;wBACY,KAAK,CAAC,IAAI,CAAC,OAAO;;;;;MAKpC,QAAQ;QACV,GAAG,CAA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I,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;oBAEjF,4IAA4I;oBAC5I,OAAO,KAAC,cAAc,OAAe,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,IAA9B,GAAG,CAA+B,CAAC;gBACjE,CAAC,CAAC,GACG,CACR,IACI,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import {\n FunctionComponent,\n Ref,\n forwardRef,\n ChangeEvent,\n useCallback,\n PropsWithoutRef,\n DragEvent,\n useState\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { hideVisually } from 'polished';\n\nimport {\n BaseProps,\n ForwardProps,\n NoChildrenProp,\n PropsWithDefaults,\n TestIdProp\n} from '../../types';\nimport { useConsolidatedRef, useI18n, useUID, useDirection, useTestIds } from '../../hooks';\nimport FormControl, { FormControlProps } from '../FormControl';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport Text from '../Text';\nimport Icon, { registerIcon } from '../Icon';\nimport * as paperClipIcon from '../Icon/icons/paper-clip.icon';\nimport FormField from '../FormField';\nimport Grid from '../Grid';\nimport { withTestIds } from '../../utils';\n\nimport FileUploadItem, { FileUploadItemProps } from './FileUploadItem';\nimport { getFileInputTestIds } from './File.test-ids';\n\nregisterIcon(paperClipIcon);\n\ntype FileInputPropsWithDefaults = PropsWithDefaults<FileInputProps>;\n\nexport interface FileInputProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** Called when files are added either via the input or drop zone. */\n onFilesAdded?: (files: File[]) => void;\n /**\n * Allow multiple files to be selected from the OS specific file browser.\n * NOTE: This does not restrict multiple files from being added via drag and drop.\n * Restrict multi file drag and drop via onFilesAdded and custom info message.\n * @default false\n */\n multiple?: boolean;\n /** An array of files that have been uploaded. */\n files?: FileUploadItemProps[];\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Pass a heading and content to show additional information on the field. */\n additionalInfo?: FormControlProps['additionalInfo'];\n /** Ref for the input element within the component's dom structure. */\n ref?: Ref<HTMLInputElement>;\n}\n\nexport const StyledDropZone = styled(FormControl)<{ dragOver: boolean }>(({ dragOver, theme }) => {\n return css`\n padding: calc(2 * ${theme.base.spacing});\n min-height: 4rem;\n border-style: dashed;\n cursor: pointer;\n\n ${dragOver &&\n css`\n border-style: solid;\n `}\n `;\n});\n\nexport const StyledFileInput = styled.div<FileInputPropsWithDefaults & ForwardProps>(\n ({ theme }) => {\n return css`\n position: relative;\n\n input {\n ${hideVisually}\n }\n\n input:enabled:focus + ${StyledDropZone} {\n box-shadow: ${theme.components['form-control'][':focus']['box-shadow']};\n }\n\n input[hidden] + ${StyledDropZone} {\n display: none;\n }\n `;\n }\n);\n\nStyledFileInput.defaultProps = defaultThemeProp;\n\nconst StyledInteractiveText = styled.span(({ theme }) => {\n return css`\n color: ${theme.base.palette.interactive};\n `;\n});\n\nStyledInteractiveText.defaultProps = defaultThemeProp;\n\nconst FileInput: FunctionComponent<FileInputProps & ForwardProps> = forwardRef(function FileInput(\n props: PropsWithoutRef<FileInputProps>,\n ref: FileInputProps['ref']\n) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n label,\n labelHidden,\n info,\n required = false,\n disabled = false,\n files,\n onFilesAdded,\n multiple = false,\n status,\n additionalInfo,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getFileInputTestIds);\n\n const icon = <Icon name='paper-clip' />;\n const inputRef = useConsolidatedRef(ref);\n\n const onChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.files) {\n onFilesAdded?.(Array.from(e.target.files));\n }\n /**\n * WHY are we doing this?\n * We are not working with the \"value\" prop of the input but rather the File instances that are created.\n * The consumer of this component should manage an array or File(s) and allow for a user to remove a selected file.\n * Since we can not modify the input value of files for browser security reasons,\n * and since setting the files property is less than ideal, we reset/toggle the input to a fresh state after a render.\n * This enables onChange to fire even if the user had just previously selected a file, removed it, and selected it again.\n */\n if (inputRef.current) inputRef.current.value = '';\n },\n [onFilesAdded]\n );\n\n const t = useI18n();\n const [dragOver, setDragOver] = useState(false);\n const { ltr, rtl } = useDirection();\n\n const fileInput = (\n <StyledFileInput>\n <input\n data-testid={testIds.control}\n {...restProps}\n ref={inputRef}\n type='file'\n id={id}\n disabled={disabled}\n onChange={onChange}\n multiple={multiple}\n />\n <Flex\n container={{ alignItems: 'center', justify: 'center' }}\n item={{ grow: 1 }}\n as={StyledDropZone}\n dragOver={dragOver}\n onClick={() => {\n inputRef.current?.focus();\n inputRef.current?.click();\n }}\n onDragOver={(e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n }}\n onDragEnter={() => setDragOver(true)}\n onDragLeave={() => setDragOver(false)}\n onDrop={(e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n setDragOver(false);\n onFilesAdded?.(Array.from(e.dataTransfer.files));\n }}\n >\n {ltr && icon}\n <Text variant='primary'>\n &nbsp;\n {t('file_upload_text_main', [\n <StyledInteractiveText>\n {t(multiple ? 'file_upload_text_multiple' : 'file_upload_text_one')}\n </StyledInteractiveText>\n ])}\n &nbsp;\n </Text>\n {rtl && icon}\n </Flex>\n </StyledFileInput>\n );\n\n return (\n <Grid container={{ rowGap: 1 }}>\n {label ? (\n <FormField\n {...{\n testId: testIds,\n label,\n labelHidden,\n id,\n info,\n required,\n disabled,\n status,\n additionalInfo\n }}\n >\n {fileInput}\n </FormField>\n ) : (\n fileInput\n )}\n {!!files?.length && (\n <Grid\n data-testid={testIds.files}\n container={{\n gap: 1,\n cols: 'repeat(2, minmax(0, 1fr))'\n }}\n as='ul'\n >\n {files.map((file, index) => {\n const key =\n file.id ?? (file.File ? `${file.File.name}_${file.File.lastModified}` : index);\n\n // When files is an array of native File objects, all properties (including name) are on the prototype, so spreading will not set any props.\n return <FileUploadItem key={key} {...file} name={file.name} />;\n })}\n </Grid>\n )}\n </Grid>\n );\n});\n\nexport default withTestIds(FileInput, getFileInputTestIds);\n"]}
1
+ {"version":3,"file":"FileInput.js","sourceRoot":"","sources":["../../../src/components/File/FileInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EAEV,WAAW,EAGX,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AASxC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,WAAiC,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,cAAuC,MAAM,kBA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AS,GACA,CACb,CAAC,CAAC,CAAC,CACF,SAAS,CACV,EACA,CAAC,CAAC,KAAK,EAAE,MAAM,IAAI,CAClB,KAAC,IAAI,mBACU,OAAO,CAAC,KAAK,EAC1B,SAAS,EAAE;oBACT,GAAG,EAAE,CAAC;oBACN,IAAI,EAAE,2BAA2B;iBAClC,EACD,EAAE,EAAC,IAAI,YAEN,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;oBACzB,MAAM,GAAG,GACP,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;oBAEjF,4IAA4I;oBAC5I,OAAO,KAAC,cAAc,OAAe,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,IAA9B,GAAG,CAA+B,CAAC;gBACjE,CAAC,CAAC,GACG,CACR,IACI,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import {\n FunctionComponent,\n Ref,\n forwardRef,\n ChangeEvent,\n useCallback,\n PropsWithoutRef,\n DragEvent,\n useState\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { hideVisually } from 'polished';\n\nimport {\n BaseProps,\n ForwardProps,\n NoChildrenProp,\n PropsWithDefaults,\n TestIdProp\n} from '../../types';\nimport { useConsolidatedRef, useI18n, useUID, useDirection, useTestIds } from '../../hooks';\nimport FormControl, { FormControlProps } from '../FormControl';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport Text from '../Text';\nimport Icon, { registerIcon } from '../Icon';\nimport * as paperClipIcon from '../Icon/icons/paper-clip.icon';\nimport FormField from '../FormField';\nimport Grid from '../Grid';\nimport { withTestIds } from '../../utils';\n\nimport FileUploadItem, { FileUploadItemProps } from './FileUploadItem';\nimport { getFileInputTestIds } from './File.test-ids';\n\nregisterIcon(paperClipIcon);\n\ntype FileInputPropsWithDefaults = PropsWithDefaults<FileInputProps>;\n\nexport interface FileInputProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** Called when files are added either via the input or drop zone. */\n onFilesAdded?: (files: File[]) => void;\n /**\n * Allow multiple files to be selected from the OS specific file browser.\n * NOTE: This does not restrict multiple files from being added via drag and drop.\n * Restrict multi file drag and drop via onFilesAdded and custom info message.\n * @default false\n */\n multiple?: boolean;\n /** An array of files that have been uploaded. */\n files?: FileUploadItemProps[];\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Pass a heading and content to show additional information on the field. */\n additionalInfo?: FormControlProps['additionalInfo'];\n /** Ref for the input element within the component's dom structure. */\n ref?: Ref<HTMLInputElement>;\n}\n\nexport const StyledDropZone = styled(FormControl)<{ dragOver: boolean }>(({ dragOver, theme }) => {\n return css`\n padding: calc(2 * ${theme.base.spacing});\n min-height: 4rem;\n border-style: dashed;\n cursor: pointer;\n\n ${dragOver &&\n css`\n border-style: solid;\n `}\n `;\n});\n\nexport const StyledFileInput = styled.div<FileInputPropsWithDefaults & ForwardProps>(\n ({ theme }) => {\n return css`\n position: relative;\n\n input {\n ${hideVisually}\n }\n\n input:enabled:focus + ${StyledDropZone} {\n box-shadow: ${theme.components['form-control'][':focus']['box-shadow']};\n }\n\n input[hidden] + ${StyledDropZone} {\n display: none;\n }\n `;\n }\n);\n\nStyledFileInput.defaultProps = defaultThemeProp;\n\nconst StyledInteractiveText = styled.span(({ theme }) => {\n return css`\n color: ${theme.base.palette.interactive};\n `;\n});\n\nStyledInteractiveText.defaultProps = defaultThemeProp;\n\nconst FileInput: FunctionComponent<FileInputProps & ForwardProps> = forwardRef(function FileInput(\n props: PropsWithoutRef<FileInputProps>,\n ref: FileInputProps['ref']\n) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n label,\n labelHidden,\n info,\n required = false,\n disabled = false,\n files,\n onFilesAdded,\n multiple = false,\n status,\n additionalInfo,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getFileInputTestIds);\n\n const icon = <Icon name='paper-clip' />;\n const inputRef = useConsolidatedRef(ref);\n\n const onChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.files) {\n onFilesAdded?.(Array.from(e.target.files));\n }\n /**\n * WHY are we doing this?\n * We are not working with the \"value\" prop of the input but rather the File instances that are created.\n * The consumer of this component should manage an array or File(s) and allow for a user to remove a selected file.\n * Since we can not modify the input value of files for browser security reasons,\n * and since setting the files property is less than ideal, we reset/toggle the input to a fresh state after a render.\n * This enables onChange to fire even if the user had just previously selected a file, removed it, and selected it again.\n */\n if (inputRef.current) inputRef.current.value = '';\n },\n [onFilesAdded]\n );\n\n const t = useI18n();\n const [dragOver, setDragOver] = useState(false);\n const { ltr, rtl } = useDirection();\n\n const fileInput = (\n <StyledFileInput>\n <input\n data-testid={testIds.control}\n {...restProps}\n ref={inputRef}\n type='file'\n id={id}\n disabled={disabled}\n onChange={onChange}\n multiple={multiple}\n />\n <Flex\n container={{ alignItems: 'center', justify: 'center' }}\n item={{ grow: 1 }}\n as={StyledDropZone}\n dragOver={dragOver}\n onClick={() => {\n inputRef.current?.focus();\n inputRef.current?.click();\n }}\n onDragOver={(e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n }}\n onDragEnter={() => setDragOver(true)}\n onDragLeave={() => setDragOver(false)}\n onDrop={(e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n setDragOver(false);\n onFilesAdded?.(Array.from(e.dataTransfer.files));\n }}\n >\n {ltr && icon}\n <Text variant='primary'>\n &nbsp;\n {t('file_upload_text_main', [\n <StyledInteractiveText>\n {t(multiple ? 'file_upload_text_multiple' : 'file_upload_text_one')}\n </StyledInteractiveText>\n ])}\n &nbsp;\n </Text>\n {rtl && icon}\n </Flex>\n </StyledFileInput>\n );\n\n return (\n <Grid container={{ rowGap: 1 }}>\n {label ? (\n <FormField\n testId={testIds}\n label={label}\n labelHidden={labelHidden}\n id={id}\n info={info}\n required={required}\n disabled={disabled}\n status={status}\n additionalInfo={additionalInfo}\n >\n {fileInput}\n </FormField>\n ) : (\n fileInput\n )}\n {!!files?.length && (\n <Grid\n data-testid={testIds.files}\n container={{\n gap: 1,\n cols: 'repeat(2, minmax(0, 1fr))'\n }}\n as='ul'\n >\n {files.map((file, index) => {\n const key =\n file.id ?? (file.File ? `${file.File.name}_${file.File.lastModified}` : index);\n\n // When files is an array of native File objects, all properties (including name) are on the prototype, so spreading will not set any props.\n return <FileUploadItem key={key} {...file} name={file.name} />;\n })}\n </Grid>\n )}\n </Grid>\n );\n});\n\nexport default withTestIds(FileInput, getFileInputTestIds);\n"]}
@@ -13,7 +13,7 @@ export interface FileVisualProps extends BaseProps {
13
13
  ref?: Ref<HTMLDivElement>;
14
14
  }
15
15
  export declare const StyledFileVisual: import("styled-components").StyledComponent<"div", DefaultTheme, {}, never>;
16
- export declare const StyledIconFrame: import("styled-components").StyledComponent<"div", DefaultTheme, {}, never>;
16
+ export declare const StyledTextFrame: import("styled-components").StyledComponent<"div", DefaultTheme, {}, never>;
17
17
  declare const FileVisual: FC<FileVisualProps & ForwardProps>;
18
18
  export default FileVisual;
19
19
  //# sourceMappingURL=FileVisual.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileVisual.d.ts","sourceRoot":"","sources":["../../../src/components/File/FileVisual.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,EAAE,EAAE,GAAG,EAAiB,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5F,OAAe,EAAO,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG9D,OAAO,EAAE,YAAY,EAAE,SAAS,EAAc,MAAM,aAAa,CAAC;AAMlE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAChD,oFAAoF;IACpF,IAAI,EAAE,cAAc,CAAC;IACrB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACjE,qCAAqC;IACrC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAmED,eAAO,MAAM,gBAAgB,6EAAe,CAAC;AAE7C,eAAO,MAAM,eAAe,6EAY1B,CAAC;AAsBH,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,GAAG,YAAY,CAkCjD,CAAC;AAEH,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"FileVisual.d.ts","sourceRoot":"","sources":["../../../src/components/File/FileVisual.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,EAAE,EAAE,GAAG,EAAiB,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5F,OAAe,EAAO,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG9D,OAAO,EAAE,YAAY,EAAE,SAAS,EAAc,MAAM,aAAa,CAAC;AAMlE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAChD,oFAAoF;IACpF,IAAI,EAAE,cAAc,CAAC;IACrB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACjE,qCAAqC;IACrC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAmED,eAAO,MAAM,gBAAgB,6EAAe,CAAC;AAE7C,eAAO,MAAM,eAAe,6EA0B1B,CAAC;AAsBH,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,GAAG,YAAY,CAmDjD,CAAC;AAEH,eAAe,UAAU,CAAC"}
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
4
  import Icon from '../Icon';
@@ -61,20 +61,21 @@ const mapping = {
61
61
  }
62
62
  };
63
63
  export const StyledFileVisual = styled.div ``;
64
- export const StyledIconFrame = styled(StyledFileVisual)(({ theme }) => {
64
+ export const StyledTextFrame = styled(StyledFileVisual)(({ theme }) => {
65
+ const { base: { palette: { light }, 'border-radius': baseBorderRadius, 'font-size': baseFontSize, 'font-weight': { 'semi-bold': semiBoldWeight } }, components: { icon: { size: { m: iconSize }, 'border-radius-multiplier': borderRadiusMultiplier } } } = theme;
65
66
  return css `
66
67
  background-color: var(--bg);
67
- color: ${theme.base.palette.light};
68
- height: ${theme.components.input.height};
69
- width: ${theme.components.input.height};
70
- border-radius: calc(0.25 * ${theme.base['border-radius']});
71
- font-size: calc(0.7 * ${theme.base['font-size']});
72
- font-weight: ${theme.base['font-weight']['semi-bold']};
68
+ color: ${light};
69
+ height: ${iconSize};
70
+ width: ${iconSize};
71
+ border-radius: calc(${borderRadiusMultiplier} * ${baseBorderRadius});
72
+ font-size: calc(0.7 * ${baseFontSize});
73
+ font-weight: ${semiBoldWeight};
73
74
  user-select: none;
74
75
  -webkit-user-select: none;
75
76
  `;
76
77
  });
77
- StyledIconFrame.defaultProps = defaultThemeProp;
78
+ StyledTextFrame.defaultProps = defaultThemeProp;
78
79
  const StyledThumbnailFrame = styled(StyledFileVisual)(({ theme }) => {
79
80
  return css `
80
81
  background-color: ${theme.base.palette['app-background']};
@@ -94,8 +95,11 @@ StyledThumbnailFrame.defaultProps = defaultThemeProp;
94
95
  const FileVisual = forwardRef(function FileVisual({ type, thumbnail, onThumbnailError, ...restProps }, ref) {
95
96
  const visualConfig = mapping[type];
96
97
  const [color, lightness] = visualConfig.backgroundColor.split('.', 2);
97
- const { base: { colors: { [color]: { [lightness]: backgroundColor } } } } = useTheme();
98
- return thumbnail ? (_jsx(Flex, { ...restProps, as: StyledThumbnailFrame, container: true, children: _jsx(Image, { src: thumbnail, onError: onThumbnailError, alt: '' }) })) : (_jsx(Flex, { ...restProps, as: StyledIconFrame, ref: ref, container: { justify: 'center', alignItems: 'center' }, style: { '--bg': backgroundColor }, children: visualConfig.iconName ? _jsx(Icon, { name: visualConfig.iconName }) : visualConfig.text }));
98
+ const { base: { colors: { [color]: { [lightness]: backgroundColor } }, palette: { light: foregroundColor } } } = useTheme();
99
+ if (thumbnail) {
100
+ return (_jsx(Flex, { ...restProps, as: StyledThumbnailFrame, container: true, children: _jsx(Image, { src: thumbnail, onError: onThumbnailError, alt: '' }) }));
101
+ }
102
+ return (_jsx(_Fragment, { children: visualConfig.iconName ? (_jsx(Icon, { ...restProps, ref: ref, name: visualConfig.iconName, background: backgroundColor, foreground: foregroundColor })) : (_jsx(Flex, { ...restProps, as: StyledTextFrame, ref: ref, container: { justify: 'center', alignItems: 'center' }, style: { '--bg': backgroundColor }, children: visualConfig.text })) }));
99
103
  });
100
104
  export default FileVisual;
101
105
  //# sourceMappingURL=FileVisual.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileVisual.js","sourceRoot":"","sources":["../../../src/components/File/FileVisual.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA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AAG,EAAE,CAAC,CAGnE,CAAC;IAEF,MAAM,EACJ,IAAI,EAAE,EACJ,MAAM,EAAE,EACN,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,eAAe,EAAE,EAC1C,EACF,EACF,GAAG,QAAQ,EAAE,CAAC;IAEf,OAAO,SAAS,CAAC,CAAC,CAAC,CACjB,KAAC,IAAI,OAAK,SAAS,EAAE,EAAE,EAAE,oBAAoB,EAAE,SAAS,kBACtD,KAAC,KAAK,IAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAC,EAAE,GAAG,GACtD,CACR,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,OACC,SAAS,EACb,EAAE,EAAE,eAAe,EACnB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,EACtD,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,EAAmB,YAElD,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,IAAI,EAAE,YAAY,CAAC,QAAQ,GAAI,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,GAC7E,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, PropsWithoutRef, FC, Ref, CSSProperties, SyntheticEvent } from 'react';\nimport styled, { css, DefaultTheme } from 'styled-components';\n\nimport Icon from '../Icon';\nimport { ForwardProps, BaseProps, OmitStrict } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport Image, { StyledImage } from '../Image';\nimport { useTheme } from '../../hooks';\n\nimport { AttachmentType } from './utils';\n\nexport interface FileVisualProps extends BaseProps {\n /** Attachment/File type, it has an impact on background color and icon rendered. */\n type: AttachmentType;\n /** A string to be used as an image src for a attachment thumbnail. */\n thumbnail?: string;\n /** Called when a thumbnail encounters an error while loading. */\n onThumbnailError?: (e: SyntheticEvent<HTMLImageElement>) => void;\n /** Reference to a button element. */\n ref?: Ref<HTMLDivElement>;\n}\ntype ThemeColor = keyof OmitStrict<DefaultTheme['base']['colors'], 'white' | 'black'>;\ntype ThemeColorVariant = 'extra-light' | 'light' | 'medium' | 'dark' | 'extra-dark';\n\ntype BackgroundColor = `${ThemeColor}.${ThemeColorVariant}`;\n\nconst mapping: Record<\n AttachmentType,\n { backgroundColor: BackgroundColor } & (\n | { iconName: string; text?: never }\n | { iconName?: never; text: string }\n )\n> = {\n generic: {\n iconName: 'paper-clip',\n backgroundColor: 'slate.dark'\n },\n video: {\n iconName: 'play-solid',\n backgroundColor: 'slate.dark'\n },\n audio: {\n iconName: 'speaker-on-solid',\n backgroundColor: 'slate.dark'\n },\n document: {\n iconName: 'filetype-text',\n backgroundColor: 'blue.medium'\n },\n message: {\n iconName: 'mail-solid',\n backgroundColor: 'blue.dark'\n },\n pdf: {\n text: 'PDF',\n backgroundColor: 'red.medium'\n },\n spreadsheet: {\n iconName: 'grid-solid',\n backgroundColor: 'green.medium'\n },\n presentation: {\n iconName: 'slideshow-solid',\n backgroundColor: 'orange.medium'\n },\n link: {\n iconName: 'chain',\n backgroundColor: 'purple.dark'\n },\n archive: {\n iconName: 'archive-solid',\n backgroundColor: 'slate.dark'\n },\n database: {\n iconName: 'disc-stack-solid',\n backgroundColor: 'slate.dark'\n },\n image: {\n iconName: 'picture-solid',\n backgroundColor: 'slate.dark'\n },\n text: {\n iconName: 'filetype-text',\n backgroundColor: 'slate.dark'\n }\n} as const;\n\nexport const StyledFileVisual = styled.div``;\n\nexport const StyledIconFrame = styled(StyledFileVisual)(({ theme }) => {\n return css`\n background-color: var(--bg);\n color: ${theme.base.palette.light};\n height: ${theme.components.input.height};\n width: ${theme.components.input.height};\n border-radius: calc(0.25 * ${theme.base['border-radius']});\n font-size: calc(0.7 * ${theme.base['font-size']});\n font-weight: ${theme.base['font-weight']['semi-bold']};\n user-select: none;\n -webkit-user-select: none;\n `;\n});\n\nStyledIconFrame.defaultProps = defaultThemeProp;\n\nconst StyledThumbnailFrame = styled(StyledFileVisual)(({ theme }) => {\n return css`\n background-color: ${theme.base.palette['app-background']};\n height: 100%;\n width: 100%;\n\n ${StyledImage} {\n margin: auto;\n height: unset;\n width: unset;\n max-height: 100%;\n max-width: 100%;\n }\n `;\n});\n\nStyledThumbnailFrame.defaultProps = defaultThemeProp;\n\nconst FileVisual: FC<FileVisualProps & ForwardProps> = forwardRef(function FileVisual(\n { type, thumbnail, onThumbnailError, ...restProps }: PropsWithoutRef<FileVisualProps>,\n ref: FileVisualProps['ref']\n) {\n const visualConfig = mapping[type];\n\n const [color, lightness] = visualConfig.backgroundColor.split('.', 2) as [\n ThemeColor,\n ThemeColorVariant\n ];\n\n const {\n base: {\n colors: {\n [color]: { [lightness]: backgroundColor }\n }\n }\n } = useTheme();\n\n return thumbnail ? (\n <Flex {...restProps} as={StyledThumbnailFrame} container>\n <Image src={thumbnail} onError={onThumbnailError} alt='' />\n </Flex>\n ) : (\n <Flex\n {...restProps}\n as={StyledIconFrame}\n ref={ref}\n container={{ justify: 'center', alignItems: 'center' }}\n style={{ '--bg': backgroundColor } as CSSProperties}\n >\n {visualConfig.iconName ? <Icon name={visualConfig.iconName} /> : visualConfig.text}\n </Flex>\n );\n});\n\nexport default FileVisual;\n"]}
1
+ {"version":3,"file":"FileVisual.js","sourceRoot":"","sources":["../../../src/components/File/FileVisual.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2D,MAAM,OAAO,CAAC;AAC5F,OAAO,MAAM,EAAE,EAAE,GAAG,EAAgB,MAAM,mBAAmB,CAAC;AAE9D,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO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AAK,EAAE,eAAe,EAAE,EACpC,EACF,GAAG,QAAQ,EAAE,CAAC;IAEf,IAAI,SAAS,EAAE;QACb,OAAO,CACL,KAAC,IAAI,OAAK,SAAS,EAAE,EAAE,EAAE,oBAAoB,EAAE,SAAS,kBACtD,KAAC,KAAK,IAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAC,EAAE,GAAG,GACtD,CACR,CAAC;KACH;IAED,OAAO,CACL,4BACG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CACvB,KAAC,IAAI,OACC,SAAS,EACb,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,YAAY,CAAC,QAAQ,EAC3B,UAAU,EAAE,eAAe,EAC3B,UAAU,EAAE,eAAe,GAC3B,CACH,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,OACC,SAAS,EACb,EAAE,EAAE,eAAe,EACnB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,EACtD,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,EAAmB,YAElD,YAAY,CAAC,IAAI,GACb,CACR,GACA,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, PropsWithoutRef, FC, Ref, CSSProperties, SyntheticEvent } from 'react';\nimport styled, { css, DefaultTheme } from 'styled-components';\n\nimport Icon from '../Icon';\nimport { ForwardProps, BaseProps, OmitStrict } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport Image, { StyledImage } from '../Image';\nimport { useTheme } from '../../hooks';\n\nimport { AttachmentType } from './utils';\n\nexport interface FileVisualProps extends BaseProps {\n /** Attachment/File type, it has an impact on background color and icon rendered. */\n type: AttachmentType;\n /** A string to be used as an image src for a attachment thumbnail. */\n thumbnail?: string;\n /** Called when a thumbnail encounters an error while loading. */\n onThumbnailError?: (e: SyntheticEvent<HTMLImageElement>) => void;\n /** Reference to a button element. */\n ref?: Ref<HTMLDivElement>;\n}\ntype ThemeColor = keyof OmitStrict<DefaultTheme['base']['colors'], 'white' | 'black'>;\ntype ThemeColorVariant = 'extra-light' | 'light' | 'medium' | 'dark' | 'extra-dark';\n\ntype BackgroundColor = `${ThemeColor}.${ThemeColorVariant}`;\n\nconst mapping: Record<\n AttachmentType,\n { backgroundColor: BackgroundColor } & (\n | { iconName: string; text?: never }\n | { iconName?: never; text: string }\n )\n> = {\n generic: {\n iconName: 'paper-clip',\n backgroundColor: 'slate.dark'\n },\n video: {\n iconName: 'play-solid',\n backgroundColor: 'slate.dark'\n },\n audio: {\n iconName: 'speaker-on-solid',\n backgroundColor: 'slate.dark'\n },\n document: {\n iconName: 'filetype-text',\n backgroundColor: 'blue.medium'\n },\n message: {\n iconName: 'mail-solid',\n backgroundColor: 'blue.dark'\n },\n pdf: {\n text: 'PDF',\n backgroundColor: 'red.medium'\n },\n spreadsheet: {\n iconName: 'grid-solid',\n backgroundColor: 'green.medium'\n },\n presentation: {\n iconName: 'slideshow-solid',\n backgroundColor: 'orange.medium'\n },\n link: {\n iconName: 'chain',\n backgroundColor: 'purple.dark'\n },\n archive: {\n iconName: 'archive-solid',\n backgroundColor: 'slate.dark'\n },\n database: {\n iconName: 'disc-stack-solid',\n backgroundColor: 'slate.dark'\n },\n image: {\n iconName: 'picture-solid',\n backgroundColor: 'slate.dark'\n },\n text: {\n iconName: 'filetype-text',\n backgroundColor: 'slate.dark'\n }\n} as const;\n\nexport const StyledFileVisual = styled.div``;\n\nexport const StyledTextFrame = styled(StyledFileVisual)(({ theme }) => {\n const {\n base: {\n palette: { light },\n 'border-radius': baseBorderRadius,\n 'font-size': baseFontSize,\n 'font-weight': { 'semi-bold': semiBoldWeight }\n },\n components: {\n icon: {\n size: { m: iconSize },\n 'border-radius-multiplier': borderRadiusMultiplier\n }\n }\n } = theme;\n return css`\n background-color: var(--bg);\n color: ${light};\n height: ${iconSize};\n width: ${iconSize};\n border-radius: calc(${borderRadiusMultiplier} * ${baseBorderRadius});\n font-size: calc(0.7 * ${baseFontSize});\n font-weight: ${semiBoldWeight};\n user-select: none;\n -webkit-user-select: none;\n `;\n});\n\nStyledTextFrame.defaultProps = defaultThemeProp;\n\nconst StyledThumbnailFrame = styled(StyledFileVisual)(({ theme }) => {\n return css`\n background-color: ${theme.base.palette['app-background']};\n height: 100%;\n width: 100%;\n\n ${StyledImage} {\n margin: auto;\n height: unset;\n width: unset;\n max-height: 100%;\n max-width: 100%;\n }\n `;\n});\n\nStyledThumbnailFrame.defaultProps = defaultThemeProp;\n\nconst FileVisual: FC<FileVisualProps & ForwardProps> = forwardRef(function FileVisual(\n { type, thumbnail, onThumbnailError, ...restProps }: PropsWithoutRef<FileVisualProps>,\n ref: FileVisualProps['ref']\n) {\n const visualConfig = mapping[type];\n\n const [color, lightness] = visualConfig.backgroundColor.split('.', 2) as [\n ThemeColor,\n ThemeColorVariant\n ];\n\n const {\n base: {\n colors: {\n [color]: { [lightness]: backgroundColor }\n },\n palette: { light: foregroundColor }\n }\n } = useTheme();\n\n if (thumbnail) {\n return (\n <Flex {...restProps} as={StyledThumbnailFrame} container>\n <Image src={thumbnail} onError={onThumbnailError} alt='' />\n </Flex>\n );\n }\n\n return (\n <>\n {visualConfig.iconName ? (\n <Icon\n {...restProps}\n ref={ref}\n name={visualConfig.iconName}\n background={backgroundColor}\n foreground={foregroundColor}\n />\n ) : (\n <Flex\n {...restProps}\n as={StyledTextFrame}\n ref={ref}\n container={{ justify: 'center', alignItems: 'center' }}\n style={{ '--bg': backgroundColor } as CSSProperties}\n >\n {visualConfig.text}\n </Flex>\n )}\n </>\n );\n});\n\nexport default FileVisual;\n"]}
@@ -1,10 +1,12 @@
1
1
  import { FC } from 'react';
2
- import { ForwardProps, OmitStrict } from '../../types';
2
+ import { ForwardProps, OmitStrict, TestIdProp } from '../../types';
3
3
  import { type BaseFormProps } from '../MultiStepForm/MultiStepForm.types';
4
- export interface FormProps extends OmitStrict<BaseFormProps, 'content'> {
4
+ export interface FormProps extends OmitStrict<BaseFormProps, 'content'>, TestIdProp {
5
5
  /** The Form content. Recommended composing form elements within a layout template such as Grid or Flex as the only child. */
6
6
  children: BaseFormProps['content'];
7
7
  }
8
- declare const Form: FC<FormProps & ForwardProps>;
9
- export default Form;
8
+ declare const _default: FC<FormProps & ForwardProps> & {
9
+ getTestIds: (testIdProp?: string | undefined) => import("../../types").TestIdsRecord<readonly []>;
10
+ };
11
+ export default _default;
10
12
  //# sourceMappingURL=Form.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,EAAE,EAAmB,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGvD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1E,MAAM,WAAW,SAAU,SAAQ,UAAU,CAAC,aAAa,EAAE,SAAS,CAAC;IACrE,6HAA6H;IAC7H,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CACpC;AAED,QAAA,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,GAAG,YAAY,CAkCrC,CAAC;AAEH,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,EAAE,EAAmB,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGnE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAK1E,MAAM,WAAW,SAAU,SAAQ,UAAU,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,UAAU;IACjF,6HAA6H;IAC7H,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CACpC;;;;AAyCD,wBAAiD"}
@@ -1,10 +1,13 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
- import { useUID } from '../../hooks';
3
+ import { useTestIds, useUID } from '../../hooks';
4
4
  import MultiStepForm from '../MultiStepForm';
5
- const Form = forwardRef(function Form({ children, actions, progress, heading, description, banners, ...restProps }, ref) {
5
+ import { withTestIds } from '../../utils';
6
+ import { getFormTestIds } from './Form.test-ids';
7
+ const Form = forwardRef(function Form({ testId, children, actions, progress, heading, description, banners, ...restProps }, ref) {
6
8
  const stepId = useUID();
7
- return (_jsx(MultiStepForm, { ...restProps, heading: heading, steps: [
9
+ const testIds = useTestIds(testId, getFormTestIds);
10
+ return (_jsx(MultiStepForm, { "data-testid": testIds.root, ...restProps, heading: heading, steps: [
8
11
  {
9
12
  id: stepId,
10
13
  name: '',
@@ -15,5 +18,5 @@ const Form = forwardRef(function Form({ children, actions, progress, heading, de
15
18
  }
16
19
  ], currentStepId: stepId, progress: progress, ref: ref, autoComplete: 'off' }));
17
20
  });
18
- export default Form;
21
+ export default withTestIds(Form, getFormTestIds);
19
22
  //# sourceMappingURL=Form.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Form.js","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAuB,MAAM,OAAO,CAAC;AAGxD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAQ7C,MAAM,IAAI,GAAiC,UAAU,CAAC,SAAS,IAAI,CACjE,EACE,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,OAAO,EACP,WAAW,EACX,OAAO,EACP,GAAG,SAAS,EACe,EAC7B,GAAqB;IAErB,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;IAExB,OAAO,CACL,KAAC,aAAa,OACR,SAAS,EACb,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE;YACL;gBACE,EAAE,EAAE,MAAM;gBACV,IAAI,EAAE,EAAE;gBACR,OAAO;gBACP,OAAO,EAAE,QAAQ;gBACjB,WAAW;gBACX,OAAO;aACR;SACF,EACD,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,YAAY,EAAC,KAAK,GAClB,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC","sourcesContent":["import { forwardRef, FC, PropsWithoutRef } from 'react';\n\nimport { ForwardProps, OmitStrict } from '../../types';\nimport { useUID } from '../../hooks';\nimport MultiStepForm from '../MultiStepForm';\nimport { type BaseFormProps } from '../MultiStepForm/MultiStepForm.types';\n\nexport interface FormProps extends OmitStrict<BaseFormProps, 'content'> {\n /** The Form content. Recommended composing form elements within a layout template such as Grid or Flex as the only child. */\n children: BaseFormProps['content'];\n}\n\nconst Form: FC<FormProps & ForwardProps> = forwardRef(function Form(\n {\n children,\n actions,\n progress,\n heading,\n description,\n banners,\n ...restProps\n }: PropsWithoutRef<FormProps>,\n ref: FormProps['ref']\n) {\n const stepId = useUID();\n\n return (\n <MultiStepForm\n {...restProps}\n heading={heading}\n steps={[\n {\n id: stepId,\n name: '',\n actions,\n content: children,\n description,\n banners\n }\n ]}\n currentStepId={stepId}\n progress={progress}\n ref={ref}\n autoComplete='off'\n />\n );\n});\n\nexport default Form;\n"]}
1
+ {"version":3,"file":"Form.js","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAuB,MAAM,OAAO,CAAC;AAGxD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAOjD,MAAM,IAAI,GAAiC,UAAU,CAAC,SAAS,IAAI,CACjE,EACE,MAAM,EACN,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,OAAO,EACP,WAAW,EACX,OAAO,EACP,GAAG,SAAS,EACe,EAC7B,GAAqB;IAErB,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEnD,OAAO,CACL,KAAC,aAAa,mBACC,OAAO,CAAC,IAAI,KACrB,SAAS,EACb,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE;YACL;gBACE,EAAE,EAAE,MAAM;gBACV,IAAI,EAAE,EAAE;gBACR,OAAO;gBACP,OAAO,EAAE,QAAQ;gBACjB,WAAW;gBACX,OAAO;aACR;SACF,EACD,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,YAAY,EAAC,KAAK,GAClB,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { forwardRef, FC, PropsWithoutRef } from 'react';\n\nimport { ForwardProps, OmitStrict, TestIdProp } from '../../types';\nimport { useTestIds, useUID } from '../../hooks';\nimport MultiStepForm from '../MultiStepForm';\nimport { type BaseFormProps } from '../MultiStepForm/MultiStepForm.types';\nimport { withTestIds } from '../../utils';\n\nimport { getFormTestIds } from './Form.test-ids';\n\nexport interface FormProps extends OmitStrict<BaseFormProps, 'content'>, TestIdProp {\n /** The Form content. Recommended composing form elements within a layout template such as Grid or Flex as the only child. */\n children: BaseFormProps['content'];\n}\n\nconst Form: FC<FormProps & ForwardProps> = forwardRef(function Form(\n {\n testId,\n children,\n actions,\n progress,\n heading,\n description,\n banners,\n ...restProps\n }: PropsWithoutRef<FormProps>,\n ref: FormProps['ref']\n) {\n const stepId = useUID();\n const testIds = useTestIds(testId, getFormTestIds);\n\n return (\n <MultiStepForm\n data-testid={testIds.root}\n {...restProps}\n heading={heading}\n steps={[\n {\n id: stepId,\n name: '',\n actions,\n content: children,\n description,\n banners\n }\n ]}\n currentStepId={stepId}\n progress={progress}\n ref={ref}\n autoComplete='off'\n />\n );\n});\n\nexport default withTestIds(Form, getFormTestIds);\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const getFormTestIds: (testIdProp?: string | undefined) => import("../..").TestIdsRecord<readonly []>;
2
+ //# sourceMappingURL=Form.test-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Form.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Form.test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,iFAAqC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { createTestIds } from '../../utils';
2
+ export const getFormTestIds = createTestIds('form', []);
3
+ //# sourceMappingURL=Form.test-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Form.test-ids.js","sourceRoot":"","sources":["../../../src/components/Form/Form.test-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC,MAAM,EAAE,EAAW,CAAC,CAAC","sourcesContent":["import { createTestIds } from '../../utils';\n\nexport const getFormTestIds = createTestIds('form', [] as const);\n"]}
@@ -1,7 +1,7 @@
1
1
  import { FunctionComponent, Ref } from 'react';
2
2
  import { DefaultTheme } from 'styled-components';
3
- import { BaseProps, ForwardProps, NoChildrenProp } from '../../types';
4
- export interface HTMLProps extends BaseProps, NoChildrenProp {
3
+ import { BaseProps, ForwardProps, NoChildrenProp, TestIdProp } from '../../types';
4
+ export interface HTMLProps extends BaseProps, NoChildrenProp, TestIdProp {
5
5
  content: string;
6
6
  customTags?: string[];
7
7
  ref?: Ref<HTMLDivElement>;
@@ -10,6 +10,8 @@ export declare const listStyles: import("styled-components").FlattenSimpleInterp
10
10
  export declare const getTableStyles: (theme: DefaultTheme) => import("styled-components").FlattenSimpleInterpolation;
11
11
  export declare const getHtmlStyles: (theme: DefaultTheme) => string;
12
12
  export declare const StyledHTML: import("styled-components").StyledComponent<"div", DefaultTheme, {}, never>;
13
- declare const HTML: FunctionComponent<HTMLProps & ForwardProps>;
14
- export default HTML;
13
+ declare const _default: FunctionComponent<HTMLProps & ForwardProps> & {
14
+ getTestIds: (testIdProp?: string | undefined) => import("../../types").TestIdsRecord<readonly []>;
15
+ };
16
+ export default _default;
15
17
  //# sourceMappingURL=HTML.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HTML.d.ts","sourceRoot":"","sources":["../../../src/components/HTML/HTML.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAEjB,GAAG,EAIJ,MAAM,OAAO,CAAC;AACf,OAAe,EAAO,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAM9D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKtE,MAAM,WAAW,SAAU,SAAQ,SAAS,EAAE,cAAc;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,UAAU,wDA2CtB,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,YAAY,2DA2BjD,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,YAAY,WAwDhD,CAAC;AAEF,eAAO,MAAM,UAAU,6EAoBrB,CAAC;AA4CH,QAAA,MAAM,IAAI,EAAE,iBAAiB,CAAC,SAAS,GAAG,YAAY,CAuBpD,CAAC;AAEH,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"HTML.d.ts","sourceRoot":"","sources":["../../../src/components/HTML/HTML.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAEjB,GAAG,EAIJ,MAAM,OAAO,CAAC;AACf,OAAe,EAAO,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAM9D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAQlF,MAAM,WAAW,SAAU,SAAQ,SAAS,EAAE,cAAc,EAAE,UAAU;IACtE,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,UAAU,wDA2CtB,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,YAAY,2DA2BjD,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,YAAY,WAwDhD,CAAC;AAEF,eAAO,MAAM,UAAU,6EAoBrB,CAAC;;;;AA2EH,wBAAiD"}
@@ -5,7 +5,9 @@ import createDOMPurify from 'dompurify';
5
5
  import { StyledPopover } from '../Popover';
6
6
  import { defaultThemeProp } from '../../theme';
7
7
  import { calculateFontSize } from '../../styles';
8
- import { sameOrigin } from '../../utils';
8
+ import { sameOrigin, withTestIds } from '../../utils';
9
+ import { useTestIds } from '../../hooks';
10
+ import { getHTMLTestIds } from './HTML.test-ids';
9
11
  const DOMPurify = createDOMPurify();
10
12
  export const listStyles = css `
11
13
  ul,
@@ -189,7 +191,7 @@ if (DOMPurify.isSupported) {
189
191
  }
190
192
  });
191
193
  }
192
- const HTML = forwardRef(function HTML({ content, customTags, ...restProps }, ref) {
194
+ const HTML = forwardRef(function HTML({ testId, content, customTags, ...restProps }, ref) {
193
195
  const [mounted, setMounted] = useState(false);
194
196
  const sanitizedHtml = useMemo(() => {
195
197
  // Don't render content on the server at all.
@@ -201,10 +203,11 @@ const HTML = forwardRef(function HTML({ content, customTags, ...restProps }, ref
201
203
  })
202
204
  : '';
203
205
  }, [content, customTags, mounted]);
206
+ const testIds = useTestIds(testId, getHTMLTestIds);
204
207
  useEffect(() => {
205
208
  setMounted(true);
206
209
  }, []);
207
- return (_jsx(StyledHTML, { ...restProps, dangerouslySetInnerHTML: { __html: sanitizedHtml }, ref: ref }));
210
+ return (_jsx(StyledHTML, { "data-testid": testIds.root, ...restProps, dangerouslySetInnerHTML: { __html: sanitizedHtml }, ref: ref }));
208
211
  });
209
- export default HTML;
212
+ export default withTestIds(HTML, getHTMLTestIds);
210
213
  //# sourceMappingURL=HTML.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HTML.js","sourceRoot":"","sources":["../../../src/components/HTML/HTML.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAIV,QAAQ,EACR,SAAS,EACT,OAAO,EACR,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAgB,MAAM,mBAAmB,CAAC;AAC9D,OAAO,eAAe,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAY,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,SAAS,GAAG,eAAe,EAAE,CAAC;AAQpC,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C5B,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,GAAG,CAAA;;;;8BAI5B,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;CAuB9D,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAmB,EAAE,EAAE;IACnD,MAAM,EACJ,IAAI,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,a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CAAC,CAAC;IAEP,OAAO,CACL,KAAC,UAAU,OAAK,SAAS,EAAE,uBAAuB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,GAAG,EAAE,GAAG,GAAI,CAC5F,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n useState,\n useEffect,\n useMemo\n} from 'react';\nimport styled, { css, DefaultTheme } from 'styled-components';\nimport createDOMPurify from 'dompurify';\n\nimport { StyledPopover } from '../Popover';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize, FontSize } from '../../styles';\nimport { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport { sameOrigin } from '../../utils';\n\nconst DOMPurify = createDOMPurify();\n\nexport interface HTMLProps extends BaseProps, NoChildrenProp {\n content: string;\n customTags?: string[];\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const listStyles = css`\n ul,\n ol {\n padding-inline-start: 2.5rem;\n }\n\n li {\n margin: 0.5rem 0;\n }\n\n ul li {\n ul {\n margin-inline-start: 1rem;\n list-style-type: circle;\n }\n\n ul ul {\n margin-inline-start: 2rem;\n list-style-type: square;\n }\n\n ul ul ul {\n margin-inline-start: 3rem;\n list-style-type: disc;\n }\n }\n\n ol li {\n ol {\n margin-inline-start: 1rem;\n list-style-type: lower-alpha;\n }\n\n ol ol {\n margin-inline-start: 2rem;\n list-style-type: lower-roman;\n }\n\n ol ol ol {\n margin-inline-start: 3rem;\n list-style-type: decimal;\n }\n }\n`;\n\nexport const getTableStyles = (theme: DefaultTheme) => css`\n border-collapse: collapse;\n\n td {\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n min-width: 6.25rem;\n }\n\n tr:first-child {\n td:first-child {\n border-top-left-radius: 0.125rem;\n }\n\n td:last-child {\n border-top-right-radius: 0.125rem;\n }\n }\n\n tr:last-child {\n td:first-child {\n border-bottom-left-radius: 0.125rem;\n }\n\n td:last-child {\n border-bottom-right-radius: 0.125rem;\n }\n }\n`;\n\nexport const getHtmlStyles = (theme: DefaultTheme) => {\n const {\n base: { 'font-size': baseFontSize, 'font-scale': baseFontScale, palette },\n components: { text }\n } = theme;\n const fontSize = calculateFontSize(baseFontSize, baseFontScale);\n return `\n ${listStyles}\n table {\n ${getTableStyles(theme)}\n }\n img {\n max-width: 100%;\n height: auto;\n border-radius: 0.25rem;\n }\n a {\n color: ${palette.interactive};\n }\n pre {\n white-space: break-spaces;\n }\n p {\n min-height: ${fontSize[text.primary['font-size'] as FontSize]};\n }\n h1 {\n font-size: ${fontSize[text.h1['font-size'] as FontSize]};\n font-weight: ${text.h1['font-weight']};\n min-height: ${fontSize[text.h1['font-size'] as FontSize]};\n }\n h2 {\n font-size: ${fontSize[text.h2['font-size'] as FontSize]};\n font-weight: ${text.h2['font-weight']};\n min-height: ${fontSize[text.h2['font-size'] as FontSize]};\n }\n h3 {\n font-size: ${fontSize[text.h3['font-size'] as FontSize]};\n font-weight: ${text.h3['font-weight']};\n min-height: ${fontSize[text.h3['font-size'] as FontSize]};\n }\n h4 {\n font-size: ${fontSize[text.h4['font-size'] as FontSize]};\n font-weight: ${text.h4['font-weight']};\n min-height: ${fontSize[text.h4['font-size'] as FontSize]};\n }\n h5 {\n font-size: ${fontSize[text.h5['font-size'] as FontSize]};\n font-weight: ${text.h5['font-weight']};\n min-height: ${fontSize[text.h5['font-size'] as FontSize]};\n }\n h6 {\n font-size: ${fontSize[text.h6['font-size'] as FontSize]};\n font-weight: ${text.h6['font-weight']};\n min-height: ${fontSize[text.h6['font-size'] as FontSize]};\n }\n `;\n};\n\nexport const StyledHTML = styled.div(({ theme }) => {\n return css`\n width: 100%;\n overflow-x: auto;\n overflow-wrap: break-word;\n ${getHtmlStyles(theme)}\n\n ${StyledPopover} ul {\n ul {\n padding-inline-start: 0;\n }\n ol {\n padding-inline-start: 0;\n }\n }\n\n ${StyledPopover} li {\n margin: 0;\n }\n `;\n});\n\nStyledHTML.defaultProps = defaultThemeProp;\n\nif (DOMPurify.isSupported) {\n const targetBlankSet = new WeakSet<HTMLAnchorElement>();\n\n DOMPurify.addHook('beforeSanitizeAttributes', node => {\n // Can be passed text nodes\n if (!(node instanceof HTMLElement || node instanceof SVGElement)) return;\n\n node.removeAttribute('class');\n\n if (\n node.tagName === 'A' &&\n node.hasAttribute('href') &&\n node.getAttribute('target') === '_blank'\n ) {\n targetBlankSet.add(node as HTMLAnchorElement);\n }\n });\n\n DOMPurify.addHook('afterSanitizeAttributes', node => {\n if (node.tagName === 'A' && node.hasAttribute('href')) {\n const href = node.getAttribute('href')!;\n\n let fullURL: URL;\n try {\n fullURL = new URL(href, window.location.href);\n } catch (e) {\n return;\n }\n\n if (!sameOrigin(window.location, fullURL)) {\n node.setAttribute('target', '_blank');\n node.setAttribute('rel', 'noopener');\n } else if (targetBlankSet.has(node as HTMLAnchorElement)) {\n node.setAttribute('target', '_blank');\n targetBlankSet.delete(node as HTMLAnchorElement);\n }\n }\n });\n}\n\nconst HTML: FunctionComponent<HTMLProps & ForwardProps> = forwardRef(function HTML(\n { content, customTags, ...restProps }: PropsWithoutRef<HTMLProps>,\n ref: HTMLProps['ref']\n) {\n const [mounted, setMounted] = useState(false);\n const sanitizedHtml = useMemo(() => {\n // Don't render content on the server at all.\n return mounted && DOMPurify.isSupported\n ? DOMPurify.sanitize(content, {\n CUSTOM_ELEMENT_HANDLING: {\n tagNameCheck: customTags ? tagName => customTags.includes(tagName) : null\n }\n })\n : '';\n }, [content, customTags, mounted]);\n\n useEffect(() => {\n setMounted(true);\n }, []);\n\n return (\n <StyledHTML {...restProps} dangerouslySetInnerHTML={{ __html: sanitizedHtml }} ref={ref} />\n );\n});\n\nexport default HTML;\n"]}
1
+ {"version":3,"file":"HTML.js","sourceRoot":"","sources":["../../../src/components/HTML/HTML.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAIV,QAAQ,EACR,SAAS,EACT,OAAO,EACR,MAAM,OAAO,CA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,\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n useState,\n useEffect,\n useMemo\n} from 'react';\nimport styled, { css, DefaultTheme } from 'styled-components';\nimport createDOMPurify from 'dompurify';\n\nimport { StyledPopover } from '../Popover';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize, FontSize } from '../../styles';\nimport { BaseProps, ForwardProps, NoChildrenProp, TestIdProp } from '../../types';\nimport { sameOrigin, withTestIds } from '../../utils';\nimport { useTestIds } from '../../hooks';\n\nimport { getHTMLTestIds } from './HTML.test-ids';\n\nconst DOMPurify = createDOMPurify();\n\nexport interface HTMLProps extends BaseProps, NoChildrenProp, TestIdProp {\n content: string;\n customTags?: string[];\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const listStyles = css`\n ul,\n ol {\n padding-inline-start: 2.5rem;\n }\n\n li {\n margin: 0.5rem 0;\n }\n\n ul li {\n ul {\n margin-inline-start: 1rem;\n list-style-type: circle;\n }\n\n ul ul {\n margin-inline-start: 2rem;\n list-style-type: square;\n }\n\n ul ul ul {\n margin-inline-start: 3rem;\n list-style-type: disc;\n }\n }\n\n ol li {\n ol {\n margin-inline-start: 1rem;\n list-style-type: lower-alpha;\n }\n\n ol ol {\n margin-inline-start: 2rem;\n list-style-type: lower-roman;\n }\n\n ol ol ol {\n margin-inline-start: 3rem;\n list-style-type: decimal;\n }\n }\n`;\n\nexport const getTableStyles = (theme: DefaultTheme) => css`\n border-collapse: collapse;\n\n td {\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n min-width: 6.25rem;\n }\n\n tr:first-child {\n td:first-child {\n border-top-left-radius: 0.125rem;\n }\n\n td:last-child {\n border-top-right-radius: 0.125rem;\n }\n }\n\n tr:last-child {\n td:first-child {\n border-bottom-left-radius: 0.125rem;\n }\n\n td:last-child {\n border-bottom-right-radius: 0.125rem;\n }\n }\n`;\n\nexport const getHtmlStyles = (theme: DefaultTheme) => {\n const {\n base: { 'font-size': baseFontSize, 'font-scale': baseFontScale, palette },\n components: { text }\n } = theme;\n const fontSize = calculateFontSize(baseFontSize, baseFontScale);\n return `\n ${listStyles}\n table {\n ${getTableStyles(theme)}\n }\n img {\n max-width: 100%;\n height: auto;\n border-radius: 0.25rem;\n }\n a {\n color: ${palette.interactive};\n }\n pre {\n white-space: break-spaces;\n }\n p {\n min-height: ${fontSize[text.primary['font-size'] as FontSize]};\n }\n h1 {\n font-size: ${fontSize[text.h1['font-size'] as FontSize]};\n font-weight: ${text.h1['font-weight']};\n min-height: ${fontSize[text.h1['font-size'] as FontSize]};\n }\n h2 {\n font-size: ${fontSize[text.h2['font-size'] as FontSize]};\n font-weight: ${text.h2['font-weight']};\n min-height: ${fontSize[text.h2['font-size'] as FontSize]};\n }\n h3 {\n font-size: ${fontSize[text.h3['font-size'] as FontSize]};\n font-weight: ${text.h3['font-weight']};\n min-height: ${fontSize[text.h3['font-size'] as FontSize]};\n }\n h4 {\n font-size: ${fontSize[text.h4['font-size'] as FontSize]};\n font-weight: ${text.h4['font-weight']};\n min-height: ${fontSize[text.h4['font-size'] as FontSize]};\n }\n h5 {\n font-size: ${fontSize[text.h5['font-size'] as FontSize]};\n font-weight: ${text.h5['font-weight']};\n min-height: ${fontSize[text.h5['font-size'] as FontSize]};\n }\n h6 {\n font-size: ${fontSize[text.h6['font-size'] as FontSize]};\n font-weight: ${text.h6['font-weight']};\n min-height: ${fontSize[text.h6['font-size'] as FontSize]};\n }\n `;\n};\n\nexport const StyledHTML = styled.div(({ theme }) => {\n return css`\n width: 100%;\n overflow-x: auto;\n overflow-wrap: break-word;\n ${getHtmlStyles(theme)}\n\n ${StyledPopover} ul {\n ul {\n padding-inline-start: 0;\n }\n ol {\n padding-inline-start: 0;\n }\n }\n\n ${StyledPopover} li {\n margin: 0;\n }\n `;\n});\n\nStyledHTML.defaultProps = defaultThemeProp;\n\nif (DOMPurify.isSupported) {\n const targetBlankSet = new WeakSet<HTMLAnchorElement>();\n\n DOMPurify.addHook('beforeSanitizeAttributes', node => {\n // Can be passed text nodes\n if (!(node instanceof HTMLElement || node instanceof SVGElement)) return;\n\n node.removeAttribute('class');\n\n if (\n node.tagName === 'A' &&\n node.hasAttribute('href') &&\n node.getAttribute('target') === '_blank'\n ) {\n targetBlankSet.add(node as HTMLAnchorElement);\n }\n });\n\n DOMPurify.addHook('afterSanitizeAttributes', node => {\n if (node.tagName === 'A' && node.hasAttribute('href')) {\n const href = node.getAttribute('href')!;\n\n let fullURL: URL;\n try {\n fullURL = new URL(href, window.location.href);\n } catch (e) {\n return;\n }\n\n if (!sameOrigin(window.location, fullURL)) {\n node.setAttribute('target', '_blank');\n node.setAttribute('rel', 'noopener');\n } else if (targetBlankSet.has(node as HTMLAnchorElement)) {\n node.setAttribute('target', '_blank');\n targetBlankSet.delete(node as HTMLAnchorElement);\n }\n }\n });\n}\n\nconst HTML: FunctionComponent<HTMLProps & ForwardProps> = forwardRef(function HTML(\n { testId, content, customTags, ...restProps }: PropsWithoutRef<HTMLProps>,\n ref: HTMLProps['ref']\n) {\n const [mounted, setMounted] = useState(false);\n const sanitizedHtml = useMemo(() => {\n // Don't render content on the server at all.\n return mounted && DOMPurify.isSupported\n ? DOMPurify.sanitize(content, {\n CUSTOM_ELEMENT_HANDLING: {\n tagNameCheck: customTags ? tagName => customTags.includes(tagName) : null\n }\n })\n : '';\n }, [content, customTags, mounted]);\n const testIds = useTestIds(testId, getHTMLTestIds);\n\n useEffect(() => {\n setMounted(true);\n }, []);\n\n return (\n <StyledHTML\n data-testid={testIds.root}\n {...restProps}\n dangerouslySetInnerHTML={{ __html: sanitizedHtml }}\n ref={ref}\n />\n );\n});\n\nexport default withTestIds(HTML, getHTMLTestIds);\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const getHTMLTestIds: (testIdProp?: string | undefined) => import("../..").TestIdsRecord<readonly []>;
2
+ //# sourceMappingURL=HTML.test-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HTML.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/HTML/HTML.test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,iFAAqC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { createTestIds } from '../../utils';
2
+ export const getHTMLTestIds = createTestIds('html', []);
3
+ //# sourceMappingURL=HTML.test-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HTML.test-ids.js","sourceRoot":"","sources":["../../../src/components/HTML/HTML.test-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC,MAAM,EAAE,EAAW,CAAC,CAAC","sourcesContent":["import { createTestIds } from '../../utils';\n\nexport const getHTMLTestIds = createTestIds('html', [] as const);\n"]}
@@ -1,6 +1,6 @@
1
- import { FunctionComponent, Ref, ComponentType } from 'react';
2
- import { BaseProps, ForwardProps, NoChildrenProp } from '../../types';
3
- export interface IconProps extends BaseProps, NoChildrenProp {
1
+ import { ComponentType, ForwardRefExoticComponent } from 'react';
2
+ import { NoChildrenProp, WithAttributes } from '../../types';
3
+ type BaseIconProps = NoChildrenProp & {
4
4
  /**
5
5
  * The name of the icon set.
6
6
  * @default theme.base['icon-set']
@@ -8,9 +8,30 @@ export interface IconProps extends BaseProps, NoChildrenProp {
8
8
  set?: string;
9
9
  /** The name indicating the Cosmos Icon. Reference the catalog above for the available names. */
10
10
  name: string;
11
- /** Ref for the wrapping element. */
12
- ref?: Ref<SVGSVGElement>;
13
- }
11
+ /**
12
+ * Background & svg size.
13
+ * @default "s" without background, "m" with background.
14
+ */
15
+ size?: 's' | 'm' | 'l' | 'font-size';
16
+ };
17
+ export type IconProps = WithAttributes<'div', BaseIconProps & {
18
+ /** Background color. */
19
+ background: string;
20
+ /**
21
+ * Foreground color (svg fill).
22
+ * Applies readable color off background if undefined.
23
+ */
24
+ foreground?: string;
25
+ /**
26
+ * Shape of the background.
27
+ * @default 'square'
28
+ */
29
+ shape?: 'square' | 'circle';
30
+ }> | WithAttributes<'svg', BaseIconProps & {
31
+ background?: never;
32
+ foreground?: never;
33
+ shape?: never;
34
+ }>;
14
35
  export interface IconDefinition {
15
36
  Component: ComponentType;
16
37
  viewBox?: string;
@@ -21,7 +42,15 @@ export interface IconModule extends IconDefinition {
21
42
  }
22
43
  export declare const registerIcon: (...icons: IconModule[]) => void;
23
44
  export declare const forceRegisterIcon: (...icons: IconModule[]) => void;
24
- export declare const StyledIcon: import("styled-components").StyledComponent<"svg", import("styled-components").DefaultTheme, {}, never>;
25
- declare const Icon: FunctionComponent<IconProps & ForwardProps>;
45
+ export declare const StyledIcon: import("styled-components").StyledComponent<"svg", import("styled-components").DefaultTheme, {
46
+ size?: IconProps['size'];
47
+ }, never>;
48
+ export declare const StyledIconShape: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
49
+ background: NonNullable<IconProps['background']>;
50
+ foreground?: IconProps['foreground'];
51
+ size?: IconProps['size'];
52
+ shape?: IconProps['shape'];
53
+ }, never>;
54
+ declare const Icon: ForwardRefExoticComponent<IconProps>;
26
55
  export default Icon;
27
56
  //# sourceMappingURL=Icon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../../../src/components/Icon/Icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EACjB,GAAG,EAEH,aAAa,EACd,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEtE,MAAM,WAAW,SAAU,SAAQ,SAAS,EAAE,cAAc;IAC1D;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gGAAgG;IAChG,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,aAAa,CAAC;IACzB,OAAO,CAA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;CACf,CACF,CAAC;AAEN,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,aAAa,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAW,SAAQ,cAAc;IAChD,GAAG,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;CACzB;AAID,eAAO,MAAM,YAAY,aAAc,UAAU,EAAE,SAUlD,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAc,UAAU,EAAE,SAUvD,CAAC;AAEF,eAAO,MAAM,UAAU;WAAuB,SAAS,CAAC,MAAM,CAAC;SA0C7D,CAAC;AAIH,eAAO,MAAM,eAAe;gBACd,YAAY,SAAS,CAAC,YAAY,CAAC,CAAC;iBACnC,SAAS,CAAC,YAAY,CAAC;WAC7B,SAAS,CAAC,MAAM,CAAC;YAChB,SAAS,CAAC,OAAO,CAAC;SAgE1B,CAAC;AAIH,QAAA,MAAM,IAAI,sCA6EgC,CAAC;AAE3C,eAAe,IAAI,CAAC"}
@@ -1,7 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef, useState, useEffect } from 'react';
3
- import styled from 'styled-components';
3
+ import styled, { css } from 'styled-components';
4
+ import { readableColor } from 'polished';
4
5
  import { useTheme } from '../../hooks';
6
+ import { defaultThemeProp } from '../../theme';
5
7
  const iconRegistry = new Map([]);
6
8
  export const registerIcon = (...icons) => {
7
9
  icons.forEach(({ set: modSet, name, ...iconDef }) => {
@@ -25,16 +27,100 @@ export const forceRegisterIcon = (...icons) => {
25
27
  }
26
28
  });
27
29
  };
28
- export const StyledIcon = styled.svg `
29
- display: inline-block;
30
- fill: currentColor;
31
- height: 1.125rem;
32
- width: 1.125rem;
33
- vertical-align: middle;
34
- flex-shrink: 0;
35
- `;
30
+ export const StyledIcon = styled.svg(({ theme, size = 's' }) => {
31
+ const { components: { icon: { size: { s, m, l } } } } = theme;
32
+ return css `
33
+ display: inline-block;
34
+ fill: currentColor;
35
+ vertical-align: middle;
36
+ flex-shrink: 0;
37
+ /* stylelint-disable unit-allowed-list */
38
+ min-width: 14px;
39
+ min-height: 14px;
40
+ /* stylelint-enable unit-allowed-list */
41
+
42
+ ${size === 's' &&
43
+ css `
44
+ width: ${s};
45
+ height: ${s};
46
+ `}
47
+
48
+ ${size === 'm' &&
49
+ css `
50
+ width: ${m};
51
+ height: ${m};
52
+ `}
53
+
54
+ ${size === 'l' &&
55
+ css `
56
+ width: ${l};
57
+ height: ${l};
58
+ `}
59
+
60
+ ${size === 'font-size' &&
61
+ css `
62
+ width: 1em;
63
+ height: 1em;
64
+ `}
65
+ `;
66
+ });
67
+ StyledIcon.defaultProps = defaultThemeProp;
68
+ export const StyledIconShape = styled.div(({ theme, background, foreground, size = 'm', shape = 'square' }) => {
69
+ const readableFg = readableColor(background);
70
+ const { base: { 'border-radius': baseRadius }, components: { icon: { size: { s, m, l }, 'border-radius-multiplier': borderRadiusMultiplier } } } = theme;
71
+ return css `
72
+ color: ${foreground ?? readableFg};
73
+ background-color: ${background};
74
+ display: flex;
75
+ justify-content: center;
76
+ align-items: center;
77
+
78
+ ${size === 's' &&
79
+ css `
80
+ width: ${s};
81
+ height: ${s};
82
+ `}
83
+
84
+ ${size === 'm' &&
85
+ css `
86
+ width: ${m};
87
+ height: ${m};
88
+ `}
89
+
90
+ ${size === 'l' &&
91
+ css `
92
+ width: ${l};
93
+ height: ${l};
94
+ `}
95
+
96
+ ${size === 'font-size' &&
97
+ css `
98
+ width: 1em;
99
+ height: 1em;
100
+ `}
101
+
102
+ ${shape === 'square' &&
103
+ css `
104
+ border-radius: calc(${borderRadiusMultiplier} * ${baseRadius});
105
+ `}
106
+
107
+ ${shape === 'circle' &&
108
+ css `
109
+ border-radius: 50%;
110
+ `}
111
+
112
+ ${StyledIcon} {
113
+ width: 50%;
114
+ height: 50%;
115
+ /* stylelint-disable unit-allowed-list */
116
+ min-width: min(14px, 90%);
117
+ min-height: min(14px, 90%);
118
+ /* stylelint-enable unit-allowed-list */
119
+ }
120
+ `;
121
+ });
36
122
  const emptyIconDefinition = Object.freeze({ Component: () => null });
37
- const Icon = forwardRef(function Icon({ set: setProp, name, ...restProps }, ref) {
123
+ const Icon = forwardRef(function Icon({ set: setProp, name, size, ...restProps }, ref) {
38
124
  const { base: { 'icon-set': setTheme } } = useTheme();
39
125
  const set = setProp ?? setTheme ?? 'budicon';
40
126
  const [iconDef, setIconDef] = useState(iconRegistry.get(set)?.get(name) ?? emptyIconDefinition);
@@ -71,7 +157,7 @@ const Icon = forwardRef(function Icon({ set: setProp, name, ...restProps }, ref)
71
157
  })();
72
158
  return () => controller.abort();
73
159
  }, [name, set]);
74
- return (_jsx(StyledIcon, { role: 'presentation', ...restProps, viewBox: iconDef.viewBox, ref: ref, children: _jsx(iconDef.Component, {}) }));
160
+ return typeof restProps.background === 'string' ? (_jsx(StyledIconShape, { role: 'presentation', ...restProps, background: restProps.background, foreground: restProps.foreground, shape: restProps.shape, size: size, ref: ref, children: _jsx(StyledIcon, { viewBox: iconDef.viewBox, children: _jsx(iconDef.Component, {}) }) })) : (_jsx(StyledIcon, { role: 'presentation', ...restProps, viewBox: iconDef.viewBox, size: size, ref: ref, children: _jsx(iconDef.Component, {}) }));
75
161
  });
76
162
  export default Icon;
77
163
  //# sourceMappingURL=Icon.js.map