@spaced-out/ui-design-system 0.3.38 → 0.3.39

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 (307) hide show
  1. package/.cspell/custom-words.txt +4 -0
  2. package/.github/workflows/publish_to_npm.yml +32 -4
  3. package/CHANGELOG.md +21 -0
  4. package/dts-generator/.editorconfig +10 -0
  5. package/dts-generator/.gitattributes +4 -0
  6. package/dts-generator/README.md +63 -0
  7. package/dts-generator/convert.js +101 -0
  8. package/dts-generator/package.json +16 -0
  9. package/gulpfile.js +20 -1
  10. package/lib/components/Avatar/Avatar.d.ts +264 -0
  11. package/lib/components/Avatar/index.d.ts +1 -0
  12. package/lib/components/AvatarGroup/AvatarGroup.d.ts +161 -0
  13. package/lib/components/AvatarGroup/index.d.ts +1 -0
  14. package/lib/components/Badge/Badge.d.ts +138 -0
  15. package/lib/components/Badge/index.d.ts +1 -0
  16. package/lib/components/Banner/Banner.d.ts +52 -0
  17. package/lib/components/Banner/index.d.ts +1 -0
  18. package/lib/components/Breadcrumbs/BreadcrumbLink/BreadcrumbLink.d.ts +50 -0
  19. package/lib/components/Breadcrumbs/BreadcrumbLink/index.d.ts +1 -0
  20. package/lib/components/Breadcrumbs/Breadcrumbs.d.ts +64 -0
  21. package/lib/components/Breadcrumbs/index.d.ts +2 -0
  22. package/lib/components/Button/Button.d.ts +288 -0
  23. package/lib/components/Button/index.d.ts +14 -0
  24. package/lib/components/ButtonDropdown/ButtonDropdown.d.ts +192 -0
  25. package/lib/components/ButtonDropdown/SimpleButtonDropdown.d.ts +148 -0
  26. package/lib/components/ButtonDropdown/index.d.ts +2 -0
  27. package/lib/components/ButtonTabs/ButtonTab/ButtonTab.d.ts +82 -0
  28. package/lib/components/ButtonTabs/ButtonTab/index.d.ts +1 -0
  29. package/lib/components/ButtonTabs/ButtonTabDropdown.d.ts +118 -0
  30. package/lib/components/ButtonTabs/ButtonTabs.d.ts +113 -0
  31. package/lib/components/ButtonTabs/index.d.ts +2 -0
  32. package/lib/components/Card/Card.d.ts +163 -0
  33. package/lib/components/Card/index.d.ts +1 -0
  34. package/lib/components/Charts/ChartTooltip/index.d.ts +10 -0
  35. package/lib/components/Charts/ChartWrapper/ChartWrapper.d.ts +184 -0
  36. package/lib/components/Charts/ChartWrapper/index.d.ts +1 -0
  37. package/lib/components/Charts/ColumnChart/ColumnChart.d.ts +111 -0
  38. package/lib/components/Charts/ColumnChart/index.d.ts +1 -0
  39. package/lib/components/Charts/DonutChart/DonutChart.d.ts +142 -0
  40. package/lib/components/Charts/DonutChart/index.d.ts +1 -0
  41. package/lib/components/Charts/FunnelChart/FunnelChart.d.ts +99 -0
  42. package/lib/components/Charts/FunnelChart/index.d.ts +1 -0
  43. package/lib/components/Charts/LineChart/LineChart.d.ts +97 -0
  44. package/lib/components/Charts/LineChart/index.d.ts +1 -0
  45. package/lib/components/Charts/SpiderChart/SpiderChart.d.ts +95 -0
  46. package/lib/components/Charts/SpiderChart/index.d.ts +1 -0
  47. package/lib/components/Charts/index.d.ts +7 -0
  48. package/lib/components/ChatBubble/ChatBubble.d.ts +203 -0
  49. package/lib/components/ChatBubble/index.d.ts +1 -0
  50. package/lib/components/Checkbox/Checkbox.d.ts +165 -0
  51. package/lib/components/Checkbox/CheckboxGroup.d.ts +113 -0
  52. package/lib/components/Checkbox/index.d.ts +2 -0
  53. package/lib/components/Chip/Chip.d.ts +181 -0
  54. package/lib/components/Chip/index.d.ts +2 -0
  55. package/lib/components/CircularLoader/CircularLoader.d.ts +56 -0
  56. package/lib/components/CircularLoader/index.d.ts +1 -0
  57. package/lib/components/CollapsibleCard/CollapsibleCard.d.ts +134 -0
  58. package/lib/components/CollapsibleCard/index.d.ts +1 -0
  59. package/lib/components/Combobox/Combobox.d.ts +292 -0
  60. package/lib/components/Combobox/helper.d.ts +205 -0
  61. package/lib/components/Combobox/index.d.ts +1 -0
  62. package/lib/components/ConditionalWrapper/ConditionalWrapper.d.ts +12 -0
  63. package/lib/components/ConditionalWrapper/index.d.ts +1 -0
  64. package/lib/components/DateRangePicker/Calendar.d.ts +119 -0
  65. package/lib/components/DateRangePicker/DateRangePicker.d.ts +196 -0
  66. package/lib/components/DateRangePicker/DateRangeWrapper.d.ts +311 -0
  67. package/lib/components/DateRangePicker/Day.d.ts +70 -0
  68. package/lib/components/DateRangePicker/index.d.ts +1 -0
  69. package/lib/components/Dialog/Dialog.d.ts +208 -0
  70. package/lib/components/Dialog/index.d.ts +1 -0
  71. package/lib/components/Disclaimer/Disclaimer.d.ts +32 -0
  72. package/lib/components/Disclaimer/index.d.ts +1 -0
  73. package/lib/components/Dropdown/Dropdown.d.ts +145 -0
  74. package/lib/components/Dropdown/SimpleDropdown.d.ts +142 -0
  75. package/lib/components/Dropdown/index.d.ts +2 -0
  76. package/lib/components/EmptyState/EmptyImages/CalendarEmptyImage.d.ts +108 -0
  77. package/lib/components/EmptyState/EmptyImages/ChartEmptyImage.d.ts +194 -0
  78. package/lib/components/EmptyState/EmptyImages/DataEmptyImage.d.ts +116 -0
  79. package/lib/components/EmptyState/EmptyImages/FileEmptyImage.d.ts +133 -0
  80. package/lib/components/EmptyState/EmptyImages/MessageEmptyImage.d.ts +64 -0
  81. package/lib/components/EmptyState/EmptyImages/UploadEmptyImage.d.ts +67 -0
  82. package/lib/components/EmptyState/EmptyImages/index.d.ts +6 -0
  83. package/lib/components/EmptyState/EmptyState.d.ts +82 -0
  84. package/lib/components/EmptyState/index.d.ts +1 -0
  85. package/lib/components/ErrorMessage/ErrorImages/ForbiddenImage.d.ts +85 -0
  86. package/lib/components/ErrorMessage/ErrorImages/NotFoundImage.d.ts +117 -0
  87. package/lib/components/ErrorMessage/ErrorImages/ServerErrorImage.d.ts +237 -0
  88. package/lib/components/ErrorMessage/ErrorImages/UnauthorizedImage.d.ts +73 -0
  89. package/lib/components/ErrorMessage/ErrorImages/index.d.ts +4 -0
  90. package/lib/components/ErrorMessage/ErrorMessage.d.ts +86 -0
  91. package/lib/components/ErrorMessage/index.d.ts +1 -0
  92. package/lib/components/FileUpload/FileBlock/FileBlock.d.ts +137 -0
  93. package/lib/components/FileUpload/FileBlock/index.d.ts +1 -0
  94. package/lib/components/FileUpload/FileUpload.d.ts +190 -0
  95. package/lib/components/FileUpload/index.d.ts +2 -0
  96. package/lib/components/FocusManager/FocusManager.d.ts +52 -0
  97. package/lib/components/FocusManager/index.d.ts +1 -0
  98. package/lib/components/FocusManagerWithArrowKeyNavigation/FocusManagerWithArrowKeyNavigation.d.ts +137 -0
  99. package/lib/components/FocusManagerWithArrowKeyNavigation/index.d.ts +1 -0
  100. package/lib/components/FormTitleWrapper/FormTitleWrapper.d.ts +62 -0
  101. package/lib/components/FormTitleWrapper/index.d.ts +1 -0
  102. package/lib/components/Grid/Grid.d.ts +104 -0
  103. package/lib/components/Grid/index.d.ts +1 -0
  104. package/lib/components/Icon/ClickableIcon.d.ts +101 -0
  105. package/lib/components/Icon/Icon.d.ts +71 -0
  106. package/lib/components/Icon/Icon.docs.d.ts +138 -0
  107. package/lib/components/Icon/SemanticIcon.d.ts +42 -0
  108. package/lib/components/Icon/index.d.ts +3 -0
  109. package/lib/components/InContextAlert/InContextAlert.d.ts +210 -0
  110. package/lib/components/InContextAlert/index.d.ts +1 -0
  111. package/lib/components/InlineDropdown/InlineDropdown.d.ts +146 -0
  112. package/lib/components/InlineDropdown/SimpleInlineDropdown.d.ts +145 -0
  113. package/lib/components/InlineDropdown/index.d.ts +2 -0
  114. package/lib/components/Input/Input.d.ts +327 -0
  115. package/lib/components/Input/index.d.ts +1 -0
  116. package/lib/components/KPIBox/KPIBox.d.ts +89 -0
  117. package/lib/components/KPIBox/index.d.ts +1 -0
  118. package/lib/components/LinearLoader/LinearLoader.d.ts +44 -0
  119. package/lib/components/LinearLoader/index.d.ts +1 -0
  120. package/lib/components/Link/Link.d.ts +225 -0
  121. package/lib/components/Link/index.d.ts +1 -0
  122. package/lib/components/Menu/Menu.d.ts +379 -0
  123. package/lib/components/Menu/MenuOptionButton.d.ts +199 -0
  124. package/lib/components/Menu/index.d.ts +2 -0
  125. package/lib/components/Modal/Modal.d.ts +354 -0
  126. package/lib/components/Modal/index.d.ts +14 -0
  127. package/lib/components/Notification/Notification.d.ts +147 -0
  128. package/lib/components/Notification/index.d.ts +1 -0
  129. package/lib/components/OptionButton/OptionButton.d.ts +150 -0
  130. package/lib/components/OptionButton/SimpleOptionButton.d.ts +150 -0
  131. package/lib/components/OptionButton/index.d.ts +2 -0
  132. package/lib/components/PageTitle/PageTitle.d.ts +256 -0
  133. package/lib/components/PageTitle/index.d.ts +1 -0
  134. package/lib/components/Pagination/Pagination.d.ts +144 -0
  135. package/lib/components/Pagination/PaginationItem.d.ts +136 -0
  136. package/lib/components/Pagination/index.d.ts +1 -0
  137. package/lib/components/Panel/Panel.d.ts +168 -0
  138. package/lib/components/Panel/index.d.ts +9 -0
  139. package/lib/components/ProgressDonut/ProgressDonut.d.ts +102 -0
  140. package/lib/components/ProgressDonut/index.d.ts +1 -0
  141. package/lib/components/PromptChip/PromptChip.d.ts +167 -0
  142. package/lib/components/PromptChip/index.d.ts +1 -0
  143. package/lib/components/PromptInput/PromptInput.d.ts +189 -0
  144. package/lib/components/PromptInput/index.d.ts +1 -0
  145. package/lib/components/RadioButton/RadioButton.d.ts +132 -0
  146. package/lib/components/RadioButton/RadioGroup.d.ts +88 -0
  147. package/lib/components/RadioButton/index.d.ts +2 -0
  148. package/lib/components/RadioTile/RadioTile.d.ts +109 -0
  149. package/lib/components/RadioTile/index.d.ts +1 -0
  150. package/lib/components/RangeSlider/RangeSlider.d.ts +207 -0
  151. package/lib/components/RangeSlider/index.d.ts +1 -0
  152. package/lib/components/Rating/Rating.d.ts +131 -0
  153. package/lib/components/Rating/index.d.ts +1 -0
  154. package/lib/components/ScoreBar/ScoreBar.d.ts +122 -0
  155. package/lib/components/ScoreBar/index.d.ts +1 -0
  156. package/lib/components/SearchInput/SearchInput.d.ts +79 -0
  157. package/lib/components/SearchInput/index.d.ts +2 -0
  158. package/lib/components/Separator/Separator.d.ts +51 -0
  159. package/lib/components/Separator/index.d.ts +1 -0
  160. package/lib/components/Shimmer/Shimmer.d.ts +131 -0
  161. package/lib/components/Shimmer/index.d.ts +1 -0
  162. package/lib/components/SideMenuLink/SideMenuLink.d.ts +336 -0
  163. package/lib/components/SideMenuLink/index.d.ts +1 -0
  164. package/lib/components/StatusIndicator/StatusIndicator.d.ts +60 -0
  165. package/lib/components/StatusIndicator/index.d.ts +1 -0
  166. package/lib/components/Stepper/Step/Step.d.ts +119 -0
  167. package/lib/components/Stepper/Step/StepContent.d.ts +35 -0
  168. package/lib/components/Stepper/Step/StepLabel.d.ts +35 -0
  169. package/lib/components/Stepper/Step/index.d.ts +3 -0
  170. package/lib/components/Stepper/Stepper.d.ts +60 -0
  171. package/lib/components/Stepper/index.d.ts +2 -0
  172. package/lib/components/StickyBar/StickyBar.d.ts +55 -0
  173. package/lib/components/StickyBar/index.d.ts +1 -0
  174. package/lib/components/SubMenu/SubMenu.d.ts +89 -0
  175. package/lib/components/SubMenu/SubMenuGroup.d.ts +156 -0
  176. package/lib/components/SubMenu/SubMenuItem.d.ts +161 -0
  177. package/lib/components/SubMenu/SubMenuLink.d.ts +81 -0
  178. package/lib/components/SubMenu/index.d.ts +4 -0
  179. package/lib/components/Table/Cell.d.ts +107 -0
  180. package/lib/components/Table/DefaultRow.d.ts +144 -0
  181. package/lib/components/Table/DefaultTableHeader.d.ts +236 -0
  182. package/lib/components/Table/StaticTable.d.ts +198 -0
  183. package/lib/components/Table/Table.d.ts +113 -0
  184. package/lib/components/Table/Table.docs.d.ts +532 -0
  185. package/lib/components/Table/TableActionBar.d.ts +48 -0
  186. package/lib/components/Table/TableBottomBar.d.ts +20 -0
  187. package/lib/components/Table/TableTopBar.d.ts +20 -0
  188. package/lib/components/Table/dummyTableData.d.ts +2189 -0
  189. package/lib/components/Table/hooks.d.ts +98 -0
  190. package/lib/components/Table/index.d.ts +8 -0
  191. package/lib/components/Tabs/Tab/Tab.d.ts +146 -0
  192. package/lib/components/Tabs/Tab/index.d.ts +1 -0
  193. package/lib/components/Tabs/TabList/TabDropdown.d.ts +100 -0
  194. package/lib/components/Tabs/TabList/TabList.d.ts +157 -0
  195. package/lib/components/Tabs/TabList/index.d.ts +1 -0
  196. package/lib/components/Tabs/index.d.ts +2 -0
  197. package/lib/components/Text/Text.d.ts +1021 -0
  198. package/lib/components/Text/index.d.ts +30 -0
  199. package/lib/components/TextTile/TextTile.d.ts +40 -0
  200. package/lib/components/TextTile/index.d.ts +1 -0
  201. package/lib/components/Textarea/Textarea.d.ts +132 -0
  202. package/lib/components/Textarea/index.d.ts +2 -0
  203. package/lib/components/Timeline/Timeline.d.ts +40 -0
  204. package/lib/components/Timeline/TimelineItem/TimelineItem.d.ts +121 -0
  205. package/lib/components/Timeline/TimelineItem/index.d.ts +1 -0
  206. package/lib/components/Timeline/index.d.ts +2 -0
  207. package/lib/components/Toast/Toast.d.ts +248 -0
  208. package/lib/components/Toast/ToastContainer.d.ts +140 -0
  209. package/lib/components/Toast/ToastManager.d.ts +58 -0
  210. package/lib/components/Toast/index.d.ts +10 -0
  211. package/lib/components/Toggle/Toggle.d.ts +111 -0
  212. package/lib/components/Toggle/index.d.ts +1 -0
  213. package/lib/components/TokenListInput/TokenListInput.d.ts +333 -0
  214. package/lib/components/TokenListInput/TokenValueChips.d.ts +64 -0
  215. package/lib/components/TokenListInput/index.d.ts +1 -0
  216. package/lib/components/Tooltip/Tooltip.d.ts +186 -0
  217. package/lib/components/Tooltip/index.d.ts +1 -0
  218. package/lib/components/Truncate/Truncate.d.ts +87 -0
  219. package/lib/components/Truncate/index.d.ts +2 -0
  220. package/lib/components/TruncatedTextWithTooltip/TruncatedTextWithTooltip.d.ts +95 -0
  221. package/lib/components/TruncatedTextWithTooltip/index.d.ts +1 -0
  222. package/lib/components/Typeahead/SimpleTypeahead.d.ts +141 -0
  223. package/lib/components/Typeahead/Typeahead.d.ts +217 -0
  224. package/lib/components/Typeahead/index.d.ts +2 -0
  225. package/lib/components/WeekdayPicker/WeekdayPicker.d.ts +242 -0
  226. package/lib/components/WeekdayPicker/index.d.ts +1 -0
  227. package/lib/components/index.d.ts +71 -0
  228. package/lib/hooks/index.d.ts +12 -0
  229. package/lib/hooks/useArbitraryOptionAddition/index.d.ts +1 -0
  230. package/lib/hooks/useArbitraryOptionAddition/useArbitraryOptionAddition.d.ts +124 -0
  231. package/lib/hooks/useCopyToClipboard/index.d.ts +1 -0
  232. package/lib/hooks/useCopyToClipboard/useCopyToClipboard.d.ts +27 -0
  233. package/lib/hooks/useFileUpload/index.d.ts +1 -0
  234. package/lib/hooks/useFileUpload/useFileUpload.d.ts +342 -0
  235. package/lib/hooks/useFilteredOptions/index.d.ts +1 -0
  236. package/lib/hooks/useFilteredOptions/useFilteredOptions.d.ts +87 -0
  237. package/lib/hooks/useInputState/index.d.ts +1 -0
  238. package/lib/hooks/useInputState/useInputState.d.ts +22 -0
  239. package/lib/hooks/useLockedBody/index.d.ts +1 -0
  240. package/lib/hooks/useLockedBody/useLockedBody.d.ts +46 -0
  241. package/lib/hooks/useModal/index.d.ts +1 -0
  242. package/lib/hooks/useModal/useModal.d.ts +32 -0
  243. package/lib/hooks/useMountTransition/index.d.ts +24 -0
  244. package/lib/hooks/usePagination/index.d.ts +1 -0
  245. package/lib/hooks/usePagination/usePagination.d.ts +140 -0
  246. package/lib/hooks/useToastPortal/index.d.ts +1 -0
  247. package/lib/hooks/useToastPortal/useToastPortal.d.ts +31 -0
  248. package/lib/hooks/useToggle/index.d.ts +1 -0
  249. package/lib/hooks/useToggle/useToggle.d.ts +11 -0
  250. package/lib/hooks/useWindowSize/index.d.ts +1 -0
  251. package/lib/hooks/useWindowSize/useWindowSize.d.ts +28 -0
  252. package/lib/index.d.ts +5 -0
  253. package/lib/styles/index.d.ts +267 -0
  254. package/lib/styles/variables/_border.d.ts +12 -0
  255. package/lib/styles/variables/_color.d.ts +104 -0
  256. package/lib/styles/variables/_elevation.d.ts +7 -0
  257. package/lib/styles/variables/_font.d.ts +30 -0
  258. package/lib/styles/variables/_motion.d.ts +6 -0
  259. package/lib/styles/variables/_opacity.d.ts +15 -0
  260. package/lib/styles/variables/_shadow.d.ts +24 -0
  261. package/lib/styles/variables/_size.d.ts +57 -0
  262. package/lib/styles/variables/_space.d.ts +12 -0
  263. package/lib/types/charts.d.ts +225 -0
  264. package/lib/types/common.d.ts +10 -0
  265. package/lib/types/date-range-picker.d.ts +17 -0
  266. package/lib/types/date-range-picker.js.flow +2 -3
  267. package/lib/types/index.d.ts +6 -0
  268. package/lib/types/menu.d.ts +13 -0
  269. package/lib/types/toast.d.ts +32 -0
  270. package/lib/types/typography.d.ts +17 -0
  271. package/lib/utils/array/are-arrays-equal.d.ts +11 -0
  272. package/lib/utils/array/index.d.ts +1 -0
  273. package/lib/utils/charts/charts.d.ts +102 -0
  274. package/lib/utils/charts/columnChart.d.ts +51 -0
  275. package/lib/utils/charts/donutChart.d.ts +116 -0
  276. package/lib/utils/charts/funnelChart.d.ts +94 -0
  277. package/lib/utils/charts/helpers.d.ts +44 -0
  278. package/lib/utils/charts/index.d.ts +7 -0
  279. package/lib/utils/charts/lineChart.d.ts +44 -0
  280. package/lib/utils/charts/spiderChart.d.ts +46 -0
  281. package/lib/utils/charts/typography.d.ts +42 -0
  282. package/lib/utils/classify/index.d.ts +27 -0
  283. package/lib/utils/click-away/click-away.d.ts +194 -0
  284. package/lib/utils/click-away/index.d.ts +1 -0
  285. package/lib/utils/date-range-picker/date-range-picker.d.ts +391 -0
  286. package/lib/utils/date-range-picker/index.d.ts +2 -0
  287. package/lib/utils/date-range-picker/timezones.d.ts +262 -0
  288. package/lib/utils/dom/dom.d.ts +245 -0
  289. package/lib/utils/dom/index.d.ts +1 -0
  290. package/lib/utils/helpers/helpers.d.ts +48 -0
  291. package/lib/utils/helpers/index.d.ts +1 -0
  292. package/lib/utils/index.d.ts +14 -0
  293. package/lib/utils/makeClassNameComponent/index.d.ts +1 -0
  294. package/lib/utils/makeClassNameComponent/makeClassNameComponent.d.ts +73 -0
  295. package/lib/utils/menu/index.d.ts +1 -0
  296. package/lib/utils/merge-refs/index.d.ts +1 -0
  297. package/lib/utils/merge-refs/merge-refs.d.ts +15 -0
  298. package/lib/utils/rating/index.d.ts +1 -0
  299. package/lib/utils/rating/rating.d.ts +31 -0
  300. package/lib/utils/score-bar/index.d.ts +1 -0
  301. package/lib/utils/score-bar/score-bar.d.ts +54 -0
  302. package/lib/utils/string/index.d.ts +1 -0
  303. package/lib/utils/string/string.d.ts +30 -0
  304. package/lib/utils/token-list-input/token-list-input.d.ts +32 -0
  305. package/lib/utils/tokens/index.d.ts +1 -0
  306. package/lib/utils/tokens/tokens.d.ts +230 -0
  307. package/package.json +1 -1
@@ -0,0 +1,86 @@
1
+ import {$ReadOnly} from 'utility-types';
2
+ import * as React from 'react';
3
+ import classify from '../../utils/classify';
4
+ import {
5
+ ForbiddenImage,
6
+ NotFoundImage,
7
+ ServerErrorImage,
8
+ UnauthorizedImage,
9
+ } from './ErrorImages';
10
+ import css from './ErrorMessage.module.css';
11
+ type ClassNames = $ReadOnly<{
12
+ wrapper?: string;
13
+ image?: string;
14
+ heading?: string;
15
+ title?: string;
16
+ description?: string;
17
+ children?: string;
18
+ }>;
19
+ export type ErrorMessageProps = {
20
+ classNames?: ClassNames;
21
+ children?: React.ReactNode;
22
+ imageVariant?: 'unauthorized' | 'forbidden' | 'notFound' | 'serverError';
23
+ title?: React.ReactNode;
24
+ description?: React.ReactNode;
25
+ heading?: React.ReactNode;
26
+ customImageUrl?: string;
27
+ };
28
+ export const ErrorMessage: React$AbstractComponent<
29
+ ErrorMessageProps,
30
+ HTMLDivElement
31
+ > = React.forwardRef<ErrorMessageProps, HTMLDivElement>(
32
+ (
33
+ {
34
+ classNames,
35
+ children,
36
+ imageVariant,
37
+ title,
38
+ description,
39
+ customImageUrl,
40
+ heading,
41
+ ...props
42
+ }: ErrorMessageProps,
43
+ ref,
44
+ ): React.ReactNode => (
45
+ <div
46
+ {...props}
47
+ data-testid="ErrorMessage"
48
+ className={classify(css.wrapper, classNames?.wrapper)}
49
+ ref={ref}
50
+ >
51
+ {!!imageVariant && !customImageUrl && (
52
+ <div className={classify(css.image, classNames?.image)}>
53
+ {imageVariant === 'unauthorized' && <UnauthorizedImage />}
54
+ {imageVariant === 'forbidden' && <ForbiddenImage />}
55
+ {imageVariant === 'notFound' && <NotFoundImage />}
56
+ {imageVariant === 'serverError' && <ServerErrorImage />}
57
+ </div>
58
+ )}
59
+ {customImageUrl && (
60
+ <img
61
+ className={classify(css.image, classNames?.image)}
62
+ src={customImageUrl}
63
+ alt="Empty State"
64
+ />
65
+ )}
66
+ {!!heading && (
67
+ <div className={classify(css.heading, classNames?.heading)}>
68
+ {heading}
69
+ </div>
70
+ )}
71
+ {!!title && (
72
+ <div className={classify(css.title, classNames?.title)}>{title}</div>
73
+ )}
74
+ {!!description && (
75
+ <div className={classify(css.description, classNames?.description)}>
76
+ {description}
77
+ </div>
78
+ )}
79
+ {!!children && (
80
+ <div className={classify(css.childrenWrapper, classNames?.children)}>
81
+ {children}
82
+ </div>
83
+ )}
84
+ </div>
85
+ ),
86
+ );
@@ -0,0 +1 @@
1
+ export * from './ErrorMessage';
@@ -0,0 +1,137 @@
1
+ import {$ReadOnly} from 'utility-types';
2
+ import * as React from 'react';
3
+ import classify from '../../../utils/classify';
4
+ import {ClickableIcon, CloseIcon, Icon} from '../../Icon';
5
+ import {LinearLoader} from '../../LinearLoader';
6
+ import {Truncate} from '../../Truncate';
7
+ import type {FileObject} from '../FileUpload';
8
+ import css from '../FileUpload.module.css';
9
+ type ClassNames = $ReadOnly<{
10
+ wrapper?: string;
11
+ }>;
12
+ export type FileBlockProps = {
13
+ classNames?: ClassNames;
14
+ fileObject: FileObject;
15
+ onFileRefreshClick?: (file: FileObject) => unknown;
16
+ handleFileClear?: (id: string) => unknown;
17
+ };
18
+ export const FileBlock: React$AbstractComponent<
19
+ FileBlockProps,
20
+ HTMLDivElement
21
+ > = React.forwardRef<FileBlockProps, HTMLDivElement>(
22
+ (
23
+ {
24
+ classNames,
25
+ fileObject,
26
+ onFileRefreshClick,
27
+ handleFileClear,
28
+ }: FileBlockProps,
29
+ ref,
30
+ ): React.ReactNode => (
31
+ <>
32
+ <div className={classify(css.file, classNames?.wrapper)} ref={ref}>
33
+ <div className={css.fileInfo}>
34
+ <div className={css.fileNameBlock}>
35
+ <div className={css.icon}>
36
+ <FileStatusIcon fileObject={fileObject} />
37
+ </div>
38
+ <div className={css.fileName}>
39
+ <Truncate>{fileObject.file.name}</Truncate>
40
+ </div>
41
+ </div>
42
+
43
+ {fileObject.success &&
44
+ !!fileObject.successMessage &&
45
+ !fileObject.progress && (
46
+ <div className={css.fileSuccess}>
47
+ <Truncate>{fileObject.successMessage}</Truncate>
48
+ </div>
49
+ )}
50
+
51
+ {fileObject.reject &&
52
+ !!fileObject.rejectReason &&
53
+ !fileObject.progress && (
54
+ <div className={css.fileError}>
55
+ <Truncate>{fileObject.rejectReason}</Truncate>
56
+ </div>
57
+ )}
58
+
59
+ {!!fileObject.progress && (
60
+ <div className={css.progress}>
61
+ <LinearLoader
62
+ size="small"
63
+ value={
64
+ fileObject.progress === 'indeterminate'
65
+ ? 0
66
+ : fileObject.progress
67
+ }
68
+ indeterminate={fileObject.progress === 'indeterminate'}
69
+ ></LinearLoader>
70
+ </div>
71
+ )}
72
+ </div>
73
+ <div className={css.rightSection}>
74
+ {fileObject.showReUpload && (
75
+ <div className={css.rightBlock}>
76
+ <ClickableIcon
77
+ name="refresh"
78
+ size="small"
79
+ onClick={() => onFileRefreshClick?.(fileObject)}
80
+ />
81
+ </div>
82
+ )}
83
+
84
+ <div className={css.rightBlock}>
85
+ <CloseIcon
86
+ size="small"
87
+ onClick={() => handleFileClear?.(fileObject.id)}
88
+ />
89
+ </div>
90
+ </div>
91
+ </div>
92
+ </>
93
+ ),
94
+ );
95
+
96
+ // This function returns the status of a file
97
+ const getFileStatus = (fileObject: FileObject) => {
98
+ if (fileObject.progress) {
99
+ return 'progress';
100
+ }
101
+
102
+ if (fileObject.success) {
103
+ return 'success';
104
+ }
105
+
106
+ if (fileObject.reject) {
107
+ return 'error';
108
+ }
109
+
110
+ return 'default';
111
+ };
112
+
113
+ // This component renders the status icon for a file
114
+ const FileStatusIcon = ({fileObject}: {fileObject: FileObject}) => {
115
+ const status = getFileStatus(fileObject);
116
+
117
+ switch (status) {
118
+ case 'progress':
119
+ return <Icon size="small" name="loader" color="tertiary" />;
120
+
121
+ case 'success':
122
+ return <Icon size="small" name="check" color="success" />;
123
+
124
+ case 'error':
125
+ return (
126
+ <Icon
127
+ size="small"
128
+ name="circle-exclamation"
129
+ color="danger"
130
+ type="solid"
131
+ />
132
+ );
133
+
134
+ default:
135
+ return <Icon size="small" name="check" color="success" />;
136
+ }
137
+ };
@@ -0,0 +1 @@
1
+ export * from './FileBlock';
@@ -0,0 +1,190 @@
1
+ import {$ReadOnly} from 'utility-types';
2
+ import * as React from 'react';
3
+ // @ts-expect-error[untyped-import] -- this should be fixed soon
4
+ import type {UseFileUploadReturnProps} from '../../hooks/useFileUpload';
5
+ import {useFileUpload} from '../../hooks/useFileUpload';
6
+ import classify from '../../utils/classify';
7
+ import {UnstyledButton} from '../Button';
8
+ import {Truncate} from '../Truncate';
9
+ import {FileBlock} from './FileBlock';
10
+ import css from './FileUpload.module.css';
11
+ type ClassNames = $ReadOnly<{
12
+ wrapper?: string;
13
+ instruction?: string;
14
+ secondaryInstruction?: string;
15
+ dropZone?: string;
16
+ files?: string;
17
+ }>;
18
+ export type FileProgress = number | 'indeterminate';
19
+ export type FileObject = {
20
+ file: File;
21
+ id: string;
22
+ reject?: boolean;
23
+ rejectReason?: string;
24
+ progress?: FileProgress;
25
+ success?: boolean;
26
+ successMessage?: string;
27
+ // This is a flag that is used to show/hide re-upload button
28
+ showReUpload?: boolean;
29
+ };
30
+ // This is a file error object that is passed to onRejectedFilesDrop callback in useFileUpload hook
31
+ export type FileError = {
32
+ code: string;
33
+ };
34
+ // This is a file rejection object that is passed to handleDropRejected function in useFileUpload hook
35
+ export type FileRejection = {
36
+ errors: Array<FileError>;
37
+ file: File;
38
+ };
39
+ // This is a ref object that is passed to FileUpload component for managing state of a single file
40
+ export type FileUploadRef = {
41
+ moveFileToProgress: (id: string, progress: FileProgress) => unknown;
42
+ moveFileToSuccess: (id: string, successMessage?: string) => unknown;
43
+ moveFileToReject: (id: string, rejectReason?: string) => unknown;
44
+ setShowReUpload: (id: string, showReUpload?: boolean) => unknown;
45
+ handleFileClear: (id: string) => unknown;
46
+ validFiles: Array<FileObject>;
47
+ rejectedFiles: Array<FileObject>;
48
+ files: Array<FileObject>;
49
+ };
50
+ // These props are shared between FileUpload component and useFileUpload hook
51
+ export type FileUploadBaseProps = {
52
+ maxFiles?: number;
53
+ maxSize?: number;
54
+ accept?: Record<string, string[]>;
55
+ disabled?: boolean;
56
+ // File drop callbacks
57
+ onValidFilesDrop?: (acceptedFiles: Array<FileObject>) => unknown;
58
+ onRejectedFilesDrop?: (fileRejections: Array<FileObject>) => unknown;
59
+ // File clear callbacks
60
+ onFileClear?: (id: string) => unknown;
61
+ onClear?: () => unknown;
62
+ };
63
+ export type FileUploadProps = FileUploadBaseProps & {
64
+ classNames?: ClassNames;
65
+ label?: React.ReactNode;
66
+ instruction?: React.ReactNode;
67
+ draggingInstruction?: React.ReactNode;
68
+ secondaryInstruction?: React.ReactNode;
69
+ required?: boolean;
70
+ handleFileDeletionExternally?: boolean;
71
+ // File refresh callback
72
+ onFileRefreshClick?: (file: FileObject) => unknown;
73
+ };
74
+
75
+ const FileUploadBase = (props: FileUploadProps, ref) => {
76
+ const {
77
+ classNames,
78
+ label = 'Upload File',
79
+ disabled = false,
80
+ instruction = 'Drag and drop or click to upload',
81
+ draggingInstruction = 'Drop here to start uploading..',
82
+ error = false,
83
+ required = false,
84
+ secondaryInstruction = '',
85
+ maxSize,
86
+ accept,
87
+ onValidFilesDrop,
88
+ onRejectedFilesDrop,
89
+ onFileClear,
90
+ onFileRefreshClick,
91
+ maxFiles = 1,
92
+ handleFileDeletionExternally,
93
+ } = props;
94
+ // Get file upload state from useFileUpload hook
95
+ const {
96
+ validFiles,
97
+ rejectedFiles,
98
+ isDragActive,
99
+ getRootProps,
100
+ shouldAcceptFiles,
101
+ getInputProps,
102
+ handleFileClear,
103
+ moveFileToProgress,
104
+ moveFileToSuccess,
105
+ moveFileToReject,
106
+ setShowReUpload,
107
+ }: UseFileUploadReturnProps = useFileUpload({
108
+ maxFiles,
109
+ maxSize,
110
+ accept,
111
+ disabled,
112
+ onValidFilesDrop,
113
+ onRejectedFilesDrop,
114
+ onFileClear,
115
+ });
116
+ // Expose file upload actions to parent component
117
+ React.useImperativeHandle(ref, () => ({
118
+ moveFileToProgress,
119
+ moveFileToSuccess,
120
+ moveFileToReject,
121
+ handleFileClear,
122
+ setShowReUpload,
123
+ validFiles,
124
+ rejectedFiles,
125
+ files: [...validFiles, ...rejectedFiles],
126
+ }));
127
+ // Merge valid and rejected files
128
+ const files = [...validFiles, ...rejectedFiles];
129
+ return (
130
+ <div className={classify(css.wrapper, classNames?.wrapper)}>
131
+ {Boolean(label) && (
132
+ <div className={css.label}>
133
+ <Truncate>{label}</Truncate>
134
+ {required && <span className={css.required}>{'*'}</span>}
135
+ </div>
136
+ )}
137
+
138
+ <UnstyledButton
139
+ disabled={disabled || !shouldAcceptFiles}
140
+ {...getRootProps()}
141
+ className={classify(
142
+ css.dropzone,
143
+ {
144
+ [css.disabled]: disabled || !shouldAcceptFiles,
145
+ [css.dragActive]: isDragActive,
146
+ [css.error]: error,
147
+ },
148
+ classNames?.dropZone,
149
+ )}
150
+ >
151
+ <input {...getInputProps()} />
152
+ <div className={classify(css.instruction, classNames?.instruction)}>
153
+ {isDragActive ? draggingInstruction : instruction}
154
+ </div>
155
+ <div
156
+ className={classify(
157
+ css.secondaryInstruction,
158
+ classNames?.secondaryInstruction,
159
+ )}
160
+ >
161
+ {secondaryInstruction}
162
+ </div>
163
+ </UnstyledButton>
164
+
165
+ {files.length > 0 && (
166
+ <div className={css.files}>
167
+ {files.map((fileObject: FileObject) => (
168
+ <React.Fragment key={fileObject.id}>
169
+ <FileBlock
170
+ fileObject={fileObject}
171
+ onFileRefreshClick={onFileRefreshClick}
172
+ handleFileClear={
173
+ handleFileDeletionExternally ? onFileClear : handleFileClear
174
+ }
175
+ classNames={{
176
+ wrapper: classNames?.files,
177
+ }}
178
+ />
179
+ </React.Fragment>
180
+ ))}
181
+ </div>
182
+ )}
183
+ </div>
184
+ );
185
+ };
186
+
187
+ export const FileUpload: React.AbstractComponent<
188
+ FileUploadProps,
189
+ FileUploadRef
190
+ > = React.forwardRef<FileUploadProps, FileUploadRef>(FileUploadBase);
@@ -0,0 +1,2 @@
1
+ export * from './FileBlock';
2
+ export * from './FileUpload';
@@ -0,0 +1,52 @@
1
+ import {$ReadOnly} from 'utility-types';
2
+ import * as React from 'react';
3
+ import {
4
+ // $FlowFixMe[untyped-import]
5
+ FloatingFocusManager, // $FlowFixMe[untyped-import]
6
+ useFloating,
7
+ } from '@floating-ui/react';
8
+ import classify from '../../utils/classify';
9
+ import css from './FocusManager.module.css';
10
+ type ClassNames = $ReadOnly<{
11
+ wrapper?: string;
12
+ }>;
13
+ export type FocusManagerProps = {
14
+ classNames?: ClassNames;
15
+ children?: React.ReactNode;
16
+ initialFocus?: number;
17
+ returnFocus?: boolean;
18
+ guards?: boolean;
19
+ modal?: boolean;
20
+ };
21
+ export const FocusManager = (props: FocusManagerProps): React.ReactNode => {
22
+ const {refs, context} = useFloating({
23
+ open: true,
24
+ });
25
+ const {
26
+ classNames,
27
+ children,
28
+ initialFocus = -1,
29
+ returnFocus = true,
30
+ modal = true,
31
+ guards = true,
32
+ ...restFloatingFocusManagerProps
33
+ } = props;
34
+ return (
35
+ <FloatingFocusManager
36
+ context={context}
37
+ initialFocus={initialFocus}
38
+ modal={modal}
39
+ guards={guards}
40
+ returnFocus={returnFocus}
41
+ {...restFloatingFocusManagerProps}
42
+ >
43
+ <div
44
+ ref={refs.setFloating}
45
+ data-testid="FocusManager"
46
+ className={classify(css.wrapper, classNames?.wrapper)}
47
+ >
48
+ {children}
49
+ </div>
50
+ </FloatingFocusManager>
51
+ );
52
+ };
@@ -0,0 +1 @@
1
+ export * from './FocusManager';
@@ -0,0 +1,137 @@
1
+ import * as React from 'react';
2
+ import {
3
+ // $FlowFixMe[untyped-import]
4
+ FloatingFocusManager, // $FlowFixMe[untyped-import]
5
+ useFloating, // $FlowFixMe[untyped-import]
6
+ useInteractions, // $FlowFixMe[untyped-import]
7
+ useListNavigation,
8
+ } from '@floating-ui/react';
9
+ import classify from '../../utils/classify';
10
+ import type {FocusManagerProps} from '../FocusManager';
11
+ import css from './FocusManagerWithArrowKeyNavigation.module.css';
12
+ const SKIP_ELEMENT_DISPLAY_NAME = 'SkipElementFromNavigation';
13
+ export type SkipElementFromNavigationProps = {
14
+ children: React.ReactNode;
15
+ className?: string;
16
+ };
17
+ export const SkipElementFromNavigation: React$AbstractComponent<
18
+ SkipElementFromNavigationProps,
19
+ HTMLDivElement
20
+ > = React.forwardRef<SkipElementFromNavigationProps, HTMLDivElement>(
21
+ (
22
+ {children, className, ...restProps}: SkipElementFromNavigationProps,
23
+ ref,
24
+ ) => (
25
+ <div {...restProps} className={className} tabIndex={-1} ref={ref}>
26
+ {children}
27
+ </div>
28
+ ),
29
+ );
30
+ SkipElementFromNavigation.displayName = SKIP_ELEMENT_DISPLAY_NAME;
31
+ export type FocusManagerWithArrowKeyNavigationProps = FocusManagerProps & {
32
+ cols?: number;
33
+ orientation?: 'horizontal' | 'vertical';
34
+ focusItemOnOpen?: 'auto' | boolean;
35
+ loop?: boolean;
36
+ listReference?: {
37
+ current: Array<HTMLElement>;
38
+ };
39
+ };
40
+ export const FocusManagerWithArrowKeyNavigation = (
41
+ props: FocusManagerWithArrowKeyNavigationProps,
42
+ ): React.ReactNode => {
43
+ const {
44
+ classNames,
45
+ children,
46
+ initialFocus = -1,
47
+ orientation = 'vertical',
48
+ modal = false,
49
+ cols = 1,
50
+ focusItemOnOpen = 'auto',
51
+ loop = false,
52
+ listReference,
53
+ ...restFloatingFocusManagerProps
54
+ } = props;
55
+ const {refs, context} = useFloating({
56
+ open: true,
57
+ });
58
+ const [activeIndex, setActiveIndex] = React.useState(null);
59
+ const listRef = React.useRef([]);
60
+ const childrenArray = React.Children.toArray(children).filter(Boolean);
61
+
62
+ // Note(Nishant): This is to correctly call the onClick handler which could have been on child
63
+ // we also need to set the active index correctly on click for list navigation to work
64
+ const childOnClickPassthrough = (childOnClickHandler, index, ...args) => {
65
+ if (childOnClickHandler) {
66
+ childOnClickHandler(...args);
67
+ }
68
+
69
+ setActiveIndex(index);
70
+ };
71
+
72
+ // Add childOnClickPassthrough for the list of references passed in case of custom nodes passed
73
+ if (listReference) {
74
+ listReference.current.map((element, index) => {
75
+ const childClickHandler = element.onclick;
76
+
77
+ element.onclick = (...args) => {
78
+ childOnClickPassthrough(childClickHandler, index, ...args);
79
+ };
80
+ });
81
+ }
82
+
83
+ // Note(Nishant): Force the list navigation props onto the children
84
+ // while using this component make sure your all the passed children have a focus state
85
+ let skippedChildrenCount = 0;
86
+ const clonedChildren = listReference
87
+ ? children
88
+ : childrenArray.map((child, index) => {
89
+ const {onClick: childClickHandler} = child.props;
90
+ let adjustedIndex = index - skippedChildrenCount;
91
+
92
+ if (child?.type?.displayName === SKIP_ELEMENT_DISPLAY_NAME) {
93
+ skippedChildrenCount++;
94
+ adjustedIndex = null;
95
+ }
96
+
97
+ return React.cloneElement(child, {
98
+ ...child.props,
99
+ tabIndex: activeIndex === index ? 0 : -1,
100
+ ref: (node) => {
101
+ if (adjustedIndex !== null) {
102
+ listRef.current[adjustedIndex] = node;
103
+ }
104
+ },
105
+ onClick: (...args) => {
106
+ childOnClickPassthrough(childClickHandler, adjustedIndex, ...args);
107
+ },
108
+ });
109
+ });
110
+ const listNavigation = useListNavigation(context, {
111
+ orientation,
112
+ cols,
113
+ listRef: listReference ? listReference : listRef,
114
+ activeIndex,
115
+ onNavigate: setActiveIndex,
116
+ focusItemOnOpen,
117
+ loop,
118
+ });
119
+ const {getFloatingProps} = useInteractions([listNavigation]);
120
+ return (
121
+ <FloatingFocusManager
122
+ context={context}
123
+ modal={modal}
124
+ initialFocus={initialFocus}
125
+ {...restFloatingFocusManagerProps}
126
+ >
127
+ <div
128
+ ref={refs.setFloating}
129
+ data-testid="FocusManagerWithArrowKeyNavigation"
130
+ {...getFloatingProps()}
131
+ className={classify(css.wrapper, classNames?.wrapper)}
132
+ >
133
+ {clonedChildren}
134
+ </div>
135
+ </FloatingFocusManager>
136
+ );
137
+ };
@@ -0,0 +1 @@
1
+ export * from './FocusManagerWithArrowKeyNavigation';
@@ -0,0 +1,62 @@
1
+ import {$ReadOnly} from 'utility-types';
2
+ import * as React from 'react';
3
+ import type {ColorTypes} from '../../types/typography';
4
+ import classify from '../../utils/classify';
5
+ import type {IconSize, IconType} from '../Icon';
6
+ import {Icon} from '../Icon';
7
+ import css from './FormTitleWrapper.module.css';
8
+ type ClassNames = $ReadOnly<{
9
+ wrapper?: string;
10
+ title?: string;
11
+ rightSlot?: string;
12
+ }>;
13
+ export type FormTitleWrapperProps = {
14
+ classNames?: ClassNames;
15
+ iconType?: IconType;
16
+ iconName?: string;
17
+ iconSize?: IconSize;
18
+ iconColor?: ColorTypes;
19
+ title: React.ReactNode;
20
+ // Should always atleast have a title
21
+ rightSlot?: React.ReactNode;
22
+ };
23
+ export const FormTitleWrapper: React$AbstractComponent<
24
+ FormTitleWrapperProps,
25
+ HTMLDivElement
26
+ > = React.forwardRef<FormTitleWrapperProps, HTMLDivElement>(
27
+ (
28
+ {
29
+ classNames,
30
+ iconType,
31
+ iconName,
32
+ iconSize = 'small',
33
+ iconColor,
34
+ title,
35
+ rightSlot,
36
+ }: FormTitleWrapperProps,
37
+ ref,
38
+ ) => (
39
+ <div ref={ref} data-testid="FormTitleWrapper" className={css.container}>
40
+ <div className={classify(css.leftSection, classNames?.wrapper)}>
41
+ {!!iconName && (
42
+ <Icon
43
+ type={iconType}
44
+ name={iconName}
45
+ size={iconSize}
46
+ color={iconColor}
47
+ />
48
+ )}
49
+ {/* This is to safeguard semantics as it internally composes from a subTitleSmall className
50
+ we don't fix the component here as <SubtitleSmall> resolves to <h4> and since title is a React.Node,
51
+ this would break semantics in case custom components are passed inside
52
+ */}
53
+ <div className={classify(css.componentHousing, classNames?.title)}>
54
+ {title}
55
+ </div>
56
+ </div>
57
+ <div className={classify(css.rightSection, classNames?.rightSlot)}>
58
+ {rightSlot}
59
+ </div>
60
+ </div>
61
+ ),
62
+ );
@@ -0,0 +1 @@
1
+ export * from './FormTitleWrapper';