@quillsql/react 1.0.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 (272) hide show
  1. package/.eslintrc.json +19 -0
  2. package/.prettierrc +11 -0
  3. package/example/README.md +46 -0
  4. package/example/package-lock.json +12111 -0
  5. package/example/package.json +43 -0
  6. package/example/public/favicon.ico +0 -0
  7. package/example/public/index.html +43 -0
  8. package/example/public/logo192.png +0 -0
  9. package/example/public/logo512.png +0 -0
  10. package/example/public/manifest.json +25 -0
  11. package/example/public/robots.txt +3 -0
  12. package/example/src/App.css +38 -0
  13. package/example/src/App.test.tsx +9 -0
  14. package/example/src/App.tsx +46 -0
  15. package/example/src/index.css +13 -0
  16. package/example/src/index.tsx +19 -0
  17. package/example/src/logo.svg +1 -0
  18. package/example/src/react-app-env.d.ts +1 -0
  19. package/example/src/reportWebVitals.ts +15 -0
  20. package/example/src/setupTests.ts +5 -0
  21. package/example/tsconfig.json +26 -0
  22. package/lib/AppContext.d.ts +29 -0
  23. package/lib/AppContext.js +94 -0
  24. package/lib/AppContext.js.map +1 -0
  25. package/lib/BarList.d.ts +17 -0
  26. package/lib/BarList.js +81 -0
  27. package/lib/BarList.js.map +1 -0
  28. package/lib/Button.d.ts +26 -0
  29. package/lib/Button.js +151 -0
  30. package/lib/Button.js.map +1 -0
  31. package/lib/Chart.d.ts +26 -0
  32. package/lib/Chart.js +532 -0
  33. package/lib/Chart.js.map +1 -0
  34. package/lib/Context.d.ts +28 -0
  35. package/lib/Context.js +126 -0
  36. package/lib/Context.js.map +1 -0
  37. package/lib/ContextProvider.d.ts +28 -0
  38. package/lib/ContextProvider.js +93 -0
  39. package/lib/ContextProvider.js.map +1 -0
  40. package/lib/Dashboard.d.ts +9 -0
  41. package/lib/Dashboard.js +271 -0
  42. package/lib/Dashboard.js.map +1 -0
  43. package/lib/DateRangePicker/Calendar.d.ts +15 -0
  44. package/lib/DateRangePicker/Calendar.js +94 -0
  45. package/lib/DateRangePicker/Calendar.js.map +1 -0
  46. package/lib/DateRangePicker/DateRangePicker.d.ts +31 -0
  47. package/lib/DateRangePicker/DateRangePicker.js +105 -0
  48. package/lib/DateRangePicker/DateRangePicker.js.map +1 -0
  49. package/lib/DateRangePicker/DateRangePickerButton.d.ts +21 -0
  50. package/lib/DateRangePicker/DateRangePickerButton.js +39 -0
  51. package/lib/DateRangePicker/DateRangePickerButton.js.map +1 -0
  52. package/lib/DateRangePicker/dateRangePickerUtils.d.ts +13 -0
  53. package/lib/DateRangePicker/dateRangePickerUtils.js +313 -0
  54. package/lib/DateRangePicker/dateRangePickerUtils.js.map +1 -0
  55. package/lib/DateRangePicker/index.d.ts +2 -0
  56. package/lib/DateRangePicker/index.js +2 -0
  57. package/lib/DateRangePicker/index.js.map +1 -0
  58. package/lib/DateRangePicker.d.ts +32 -0
  59. package/lib/DateRangePicker.js +105 -0
  60. package/lib/DateRangePicker.js.map +1 -0
  61. package/lib/PieChart.d.ts +63 -0
  62. package/lib/PieChart.js +589 -0
  63. package/lib/PieChart.js.map +1 -0
  64. package/lib/QuillProvider.d.ts +13 -0
  65. package/lib/QuillProvider.js +19 -0
  66. package/lib/QuillProvider.js.map +1 -0
  67. package/lib/assets/ArrowDownHeadIcon.d.ts +5 -0
  68. package/lib/assets/ArrowDownHeadIcon.js +29 -0
  69. package/lib/assets/ArrowDownHeadIcon.js.map +1 -0
  70. package/lib/assets/ArrowDownIcon.d.ts +5 -0
  71. package/lib/assets/ArrowDownIcon.js +29 -0
  72. package/lib/assets/ArrowDownIcon.js.map +1 -0
  73. package/lib/assets/ArrowDownRightIcon.d.ts +5 -0
  74. package/lib/assets/ArrowDownRightIcon.js +29 -0
  75. package/lib/assets/ArrowDownRightIcon.js.map +1 -0
  76. package/lib/assets/ArrowLeftHeadIcon.d.ts +5 -0
  77. package/lib/assets/ArrowLeftHeadIcon.js +29 -0
  78. package/lib/assets/ArrowLeftHeadIcon.js.map +1 -0
  79. package/lib/assets/ArrowRightHeadIcon.d.ts +5 -0
  80. package/lib/assets/ArrowRightHeadIcon.js +29 -0
  81. package/lib/assets/ArrowRightHeadIcon.js.map +1 -0
  82. package/lib/assets/ArrowRightIcon.d.ts +5 -0
  83. package/lib/assets/ArrowRightIcon.js +29 -0
  84. package/lib/assets/ArrowRightIcon.js.map +1 -0
  85. package/lib/assets/ArrowUpHeadIcon.d.ts +5 -0
  86. package/lib/assets/ArrowUpHeadIcon.js +29 -0
  87. package/lib/assets/ArrowUpHeadIcon.js.map +1 -0
  88. package/lib/assets/ArrowUpIcon.d.ts +5 -0
  89. package/lib/assets/ArrowUpIcon.js +29 -0
  90. package/lib/assets/ArrowUpIcon.js.map +1 -0
  91. package/lib/assets/ArrowUpRightIcon.d.ts +5 -0
  92. package/lib/assets/ArrowUpRightIcon.js +29 -0
  93. package/lib/assets/ArrowUpRightIcon.js.map +1 -0
  94. package/lib/assets/CalendarIcon.d.ts +5 -0
  95. package/lib/assets/CalendarIcon.js +29 -0
  96. package/lib/assets/CalendarIcon.js.map +1 -0
  97. package/lib/assets/DoubleArrowLeftHeadIcon.d.ts +5 -0
  98. package/lib/assets/DoubleArrowLeftHeadIcon.js +29 -0
  99. package/lib/assets/DoubleArrowLeftHeadIcon.js.map +1 -0
  100. package/lib/assets/DoubleArrowRightHeadIcon.d.ts +5 -0
  101. package/lib/assets/DoubleArrowRightHeadIcon.js +29 -0
  102. package/lib/assets/DoubleArrowRightHeadIcon.js.map +1 -0
  103. package/lib/assets/ExclamationFilledIcon.d.ts +5 -0
  104. package/lib/assets/ExclamationFilledIcon.js +29 -0
  105. package/lib/assets/ExclamationFilledIcon.js.map +1 -0
  106. package/lib/assets/LoadingSpinner.d.ts +5 -0
  107. package/lib/assets/LoadingSpinner.js +29 -0
  108. package/lib/assets/LoadingSpinner.js.map +1 -0
  109. package/lib/assets/SearchIcon.d.ts +5 -0
  110. package/lib/assets/SearchIcon.js +29 -0
  111. package/lib/assets/SearchIcon.js.map +1 -0
  112. package/lib/assets/XCircleIcon.d.ts +5 -0
  113. package/lib/assets/XCircleIcon.js +29 -0
  114. package/lib/assets/XCircleIcon.js.map +1 -0
  115. package/lib/assets/index.d.ts +16 -0
  116. package/lib/assets/index.js +17 -0
  117. package/lib/assets/index.js.map +1 -0
  118. package/lib/components/Dropdown/Dropdown.d.ts +12 -0
  119. package/lib/components/Dropdown/Dropdown.js +60 -0
  120. package/lib/components/Dropdown/Dropdown.js.map +1 -0
  121. package/lib/components/Dropdown/DropdownItem.d.ts +8 -0
  122. package/lib/components/Dropdown/DropdownItem.js +54 -0
  123. package/lib/components/Dropdown/DropdownItem.js.map +1 -0
  124. package/lib/components/Dropdown/index.d.ts +2 -0
  125. package/lib/components/Dropdown/index.js +3 -0
  126. package/lib/components/Dropdown/index.js.map +1 -0
  127. package/lib/components/Modal/Dropdown/Dropdown.d.ts +12 -0
  128. package/lib/components/Modal/Dropdown/Dropdown.js +52 -0
  129. package/lib/components/Modal/Dropdown/Dropdown.js.map +1 -0
  130. package/lib/components/Modal/Dropdown/DropdownItem.d.ts +8 -0
  131. package/lib/components/Modal/Dropdown/DropdownItem.js +51 -0
  132. package/lib/components/Modal/Dropdown/DropdownItem.js.map +1 -0
  133. package/lib/components/Modal/Dropdown/index.d.ts +2 -0
  134. package/lib/components/Modal/Dropdown/index.js +3 -0
  135. package/lib/components/Modal/Dropdown/index.js.map +1 -0
  136. package/lib/components/Modal/Modal.d.ts +13 -0
  137. package/lib/components/Modal/Modal.js +71 -0
  138. package/lib/components/Modal/Modal.js.map +1 -0
  139. package/lib/components/Modal/index.d.ts +1 -0
  140. package/lib/components/Modal/index.js +2 -0
  141. package/lib/components/Modal/index.js.map +1 -0
  142. package/lib/components/selectUtils.d.ts +9 -0
  143. package/lib/components/selectUtils.js +37 -0
  144. package/lib/components/selectUtils.js.map +1 -0
  145. package/lib/contexts/BaseColorContext.d.ts +3 -0
  146. package/lib/contexts/BaseColorContext.js +5 -0
  147. package/lib/contexts/BaseColorContext.js.map +1 -0
  148. package/lib/contexts/HoveredValueContext.d.ts +7 -0
  149. package/lib/contexts/HoveredValueContext.js +6 -0
  150. package/lib/contexts/HoveredValueContext.js.map +1 -0
  151. package/lib/contexts/RootStylesContext.d.ts +3 -0
  152. package/lib/contexts/RootStylesContext.js +4 -0
  153. package/lib/contexts/RootStylesContext.js.map +1 -0
  154. package/lib/contexts/SelectedValueContext.d.ts +7 -0
  155. package/lib/contexts/SelectedValueContext.js +7 -0
  156. package/lib/contexts/SelectedValueContext.js.map +1 -0
  157. package/lib/contexts/index.d.ts +4 -0
  158. package/lib/contexts/index.js +5 -0
  159. package/lib/contexts/index.js.map +1 -0
  160. package/lib/hooks/index.d.ts +4 -0
  161. package/lib/hooks/index.js +5 -0
  162. package/lib/hooks/index.js.map +1 -0
  163. package/lib/hooks/useInternalState.d.ts +3 -0
  164. package/lib/hooks/useInternalState.js +15 -0
  165. package/lib/hooks/useInternalState.js.map +1 -0
  166. package/lib/hooks/useOnClickOutside.d.ts +2 -0
  167. package/lib/hooks/useOnClickOutside.js +19 -0
  168. package/lib/hooks/useOnClickOutside.js.map +1 -0
  169. package/lib/hooks/useOnWindowResize.d.ts +4 -0
  170. package/lib/hooks/useOnWindowResize.js +15 -0
  171. package/lib/hooks/useOnWindowResize.js.map +1 -0
  172. package/lib/hooks/useSelectOnKeyDown.d.ts +2 -0
  173. package/lib/hooks/useSelectOnKeyDown.js +64 -0
  174. package/lib/hooks/useSelectOnKeyDown.js.map +1 -0
  175. package/lib/index.d.ts +3 -0
  176. package/lib/index.js +5 -0
  177. package/lib/index.js.map +1 -0
  178. package/lib/lib/colorClassNames.d.ts +19 -0
  179. package/lib/lib/colorClassNames.js +3175 -0
  180. package/lib/lib/colorClassNames.js.map +1 -0
  181. package/lib/lib/constants.d.ts +16 -0
  182. package/lib/lib/constants.js +47 -0
  183. package/lib/lib/constants.js.map +1 -0
  184. package/lib/lib/font.d.ts +13 -0
  185. package/lib/lib/font.js +14 -0
  186. package/lib/lib/font.js.map +1 -0
  187. package/lib/lib/hexColors.d.ts +3 -0
  188. package/lib/lib/hexColors.js +29 -0
  189. package/lib/lib/hexColors.js.map +1 -0
  190. package/lib/lib/index.d.ts +10 -0
  191. package/lib/lib/index.js +11 -0
  192. package/lib/lib/index.js.map +1 -0
  193. package/lib/lib/inputTypes.d.ts +20 -0
  194. package/lib/lib/inputTypes.js +37 -0
  195. package/lib/lib/inputTypes.js.map +1 -0
  196. package/lib/lib/shape.d.ts +73 -0
  197. package/lib/lib/shape.js +74 -0
  198. package/lib/lib/shape.js.map +1 -0
  199. package/lib/lib/sizing.d.ts +46 -0
  200. package/lib/lib/sizing.js +43 -0
  201. package/lib/lib/sizing.js.map +1 -0
  202. package/lib/lib/spacing.d.ts +264 -0
  203. package/lib/lib/spacing.js +265 -0
  204. package/lib/lib/spacing.js.map +1 -0
  205. package/lib/lib/theme.d.ts +22 -0
  206. package/lib/lib/theme.js +46 -0
  207. package/lib/lib/theme.js.map +1 -0
  208. package/lib/lib/utils.d.ts +12 -0
  209. package/lib/lib/utils.js +69 -0
  210. package/lib/lib/utils.js.map +1 -0
  211. package/lib/styles.css +12019 -0
  212. package/package.json +48 -0
  213. package/postcss.config.js +6 -0
  214. package/src/BarList.tsx +236 -0
  215. package/src/Chart.tsx +934 -0
  216. package/src/Context.tsx +204 -0
  217. package/src/Dashboard.tsx +379 -0
  218. package/src/DateRangePicker/Calendar.tsx +425 -0
  219. package/src/DateRangePicker/DateRangePicker.tsx +251 -0
  220. package/src/DateRangePicker/DateRangePickerButton.tsx +176 -0
  221. package/src/DateRangePicker/dateRangePickerUtils.tsx +460 -0
  222. package/src/DateRangePicker/index.ts +3 -0
  223. package/src/PieChart.tsx +838 -0
  224. package/src/QuillProvider.tsx +28 -0
  225. package/src/assets/ArrowDownHeadIcon.tsx +11 -0
  226. package/src/assets/ArrowDownIcon.tsx +14 -0
  227. package/src/assets/ArrowDownRightIcon.tsx +14 -0
  228. package/src/assets/ArrowLeftHeadIcon.tsx +11 -0
  229. package/src/assets/ArrowRightHeadIcon.tsx +11 -0
  230. package/src/assets/ArrowRightIcon.tsx +14 -0
  231. package/src/assets/ArrowUpHeadIcon.tsx +11 -0
  232. package/src/assets/ArrowUpIcon.tsx +14 -0
  233. package/src/assets/ArrowUpRightIcon.tsx +14 -0
  234. package/src/assets/CalendarIcon.tsx +14 -0
  235. package/src/assets/DoubleArrowLeftHeadIcon.tsx +18 -0
  236. package/src/assets/DoubleArrowRightHeadIcon.tsx +20 -0
  237. package/src/assets/ExclamationFilledIcon.tsx +14 -0
  238. package/src/assets/LoadingSpinner.tsx +11 -0
  239. package/src/assets/SearchIcon.tsx +14 -0
  240. package/src/assets/XCircleIcon.tsx +14 -0
  241. package/src/assets/index.ts +16 -0
  242. package/src/components/Dropdown/Dropdown.tsx +179 -0
  243. package/src/components/Dropdown/DropdownItem.tsx +86 -0
  244. package/src/components/Dropdown/index.ts +2 -0
  245. package/src/components/Modal/Modal.tsx +113 -0
  246. package/src/components/Modal/index.ts +1 -0
  247. package/src/components/selectUtils.ts +67 -0
  248. package/src/contexts/BaseColorContext.tsx +8 -0
  249. package/src/contexts/HoveredValueContext.tsx +12 -0
  250. package/src/contexts/RootStylesContext.tsx +5 -0
  251. package/src/contexts/SelectedValueContext.tsx +13 -0
  252. package/src/contexts/index.ts +4 -0
  253. package/src/hooks/index.ts +4 -0
  254. package/src/hooks/useInternalState.tsx +18 -0
  255. package/src/hooks/useOnClickOutside.tsx +23 -0
  256. package/src/hooks/useOnWindowResize.tsx +17 -0
  257. package/src/hooks/useSelectOnKeyDown.tsx +80 -0
  258. package/src/index.ts +4 -0
  259. package/src/lib/colorClassNames.ts +3191 -0
  260. package/src/lib/constants.ts +52 -0
  261. package/src/lib/font.ts +14 -0
  262. package/src/lib/hexColors.ts +28 -0
  263. package/src/lib/index.ts +10 -0
  264. package/src/lib/inputTypes.ts +62 -0
  265. package/src/lib/shape.ts +75 -0
  266. package/src/lib/sizing.ts +47 -0
  267. package/src/lib/spacing.ts +264 -0
  268. package/src/lib/theme.ts +49 -0
  269. package/src/lib/utils.tsx +81 -0
  270. package/src/styles.css +5 -0
  271. package/tailwind.config.js +16 -0
  272. package/tsconfig.json +22 -0
@@ -0,0 +1,28 @@
1
+ import React, { useContext, useEffect } from 'react';
2
+ import { ContextProvider } from './Context';
3
+
4
+ const QuillProvider = ({
5
+ organizationId,
6
+ authToken,
7
+ publicKey,
8
+ theme,
9
+ containerStyle,
10
+ runQueryButton,
11
+ saveQueryButton,
12
+ exportQueryButton,
13
+ children,
14
+ }) => {
15
+ return (
16
+ <ContextProvider
17
+ containerStyle={containerStyle}
18
+ initialTheme={theme}
19
+ authToken={authToken}
20
+ publicKey={publicKey}
21
+ customerId={organizationId}
22
+ >
23
+ {children}
24
+ </ContextProvider>
25
+ );
26
+ };
27
+
28
+ export default QuillProvider;
@@ -0,0 +1,11 @@
1
+ /* eslint-disable max-len */
2
+ import React from "react";
3
+
4
+ const ArrowDownHeadIcon = ({ ...props }) => (
5
+ <svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
6
+ <path fill="none" d="M0 0h24v24H0z" />
7
+ <path fill="currentColor" d="M12 13.172l4.95-4.95 1.414 1.414L12 16 5.636 9.636 7.05 8.222z" />
8
+ </svg>
9
+ );
10
+
11
+ export default ArrowDownHeadIcon;
@@ -0,0 +1,14 @@
1
+ /* eslint-disable max-len */
2
+ import React from "react";
3
+
4
+ const ArrowDownIcon = ({ ...props }) => (
5
+ <svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
6
+ <path fill="none" d="M0 0h24v24H0z" />
7
+ <path
8
+ fill="currentColor"
9
+ d="M13 16.172l5.364-5.364 1.414 1.414L12 20l-7.778-7.778 1.414-1.414L11 16.172V4h2v12.172z"
10
+ />
11
+ </svg>
12
+ );
13
+
14
+ export default ArrowDownIcon;
@@ -0,0 +1,14 @@
1
+ /* eslint-disable max-len */
2
+ import React from "react";
3
+
4
+ const ArrowDownRightIcon = ({ ...props }) => (
5
+ <svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
6
+ <path fill="none" d="M0 0h24v24H0z" />
7
+ <path
8
+ fill="currentColor"
9
+ d="M14.59 16.004L5.982 7.397l1.414-1.414 8.607 8.606V7.004h2v11h-11v-2z"
10
+ />
11
+ </svg>
12
+ );
13
+
14
+ export default ArrowDownRightIcon;
@@ -0,0 +1,11 @@
1
+ /* eslint-disable max-len */
2
+ import React from "react";
3
+
4
+ const ArrowLeftHeadIcon = ({ ...props }) => (
5
+ <svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
6
+ <path fill="none" d="M0 0h24v24H0z" />
7
+ <path d="M10.828 12l4.95 4.95-1.414 1.414L8 12l6.364-6.364 1.414 1.414z" />
8
+ </svg>
9
+ );
10
+
11
+ export default ArrowLeftHeadIcon;
@@ -0,0 +1,11 @@
1
+ /* eslint-disable max-len */
2
+ import React from "react";
3
+
4
+ const ArrowRightHeadIcon = ({ ...props }) => (
5
+ <svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
6
+ <path fill="none" d="M0 0h24v24H0z" />
7
+ <path d="M13.172 12l-4.95-4.95 1.414-1.414L16 12l-6.364 6.364-1.414-1.414z" />
8
+ </svg>
9
+ );
10
+
11
+ export default ArrowRightHeadIcon;
@@ -0,0 +1,14 @@
1
+ /* eslint-disable max-len */
2
+ import React from "react";
3
+
4
+ const ArrowRightIcon = ({ ...props }) => (
5
+ <svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
6
+ <path fill="none" d="M0 0h24v24H0z" />
7
+ <path
8
+ fill="currentColor"
9
+ d="M16.172 11l-5.364-5.364 1.414-1.414L20 12l-7.778 7.778-1.414-1.414L16.172 13H4v-2z"
10
+ />
11
+ </svg>
12
+ );
13
+
14
+ export default ArrowRightIcon;
@@ -0,0 +1,11 @@
1
+ /* eslint-disable max-len */
2
+ import React from "react";
3
+
4
+ const ArrowUpHeadIcon = ({ ...props }) => (
5
+ <svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
6
+ <path fill="none" d="M0 0h24v24H0z" />
7
+ <path fill="currentColor" d="M12 10.828l-4.95 4.95-1.414-1.414L12 8l6.364 6.364-1.414 1.414z" />
8
+ </svg>
9
+ );
10
+
11
+ export default ArrowUpHeadIcon;
@@ -0,0 +1,14 @@
1
+ /* eslint-disable max-len */
2
+ import React from "react";
3
+
4
+ const ArrowUpIcon = ({ ...props }) => (
5
+ <svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
6
+ <path fill="none" d="M0 0h24v24H0z" />
7
+ <path
8
+ fill="currentColor"
9
+ d="M13 7.828V20h-2V7.828l-5.364 5.364-1.414-1.414L12 4l7.778 7.778-1.414 1.414L13 7.828z"
10
+ />
11
+ </svg>
12
+ );
13
+
14
+ export default ArrowUpIcon;
@@ -0,0 +1,14 @@
1
+ /* eslint-disable max-len */
2
+ import React from "react";
3
+
4
+ const ArrowUpRightIcon = ({ ...props }) => (
5
+ <svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
6
+ <path fill="none" d="M0 0h24v24H0z" />
7
+ <path
8
+ fill="currentColor"
9
+ d="M16.004 9.414l-8.607 8.607-1.414-1.414L14.589 8H7.004V6h11v11h-2V9.414z"
10
+ />
11
+ </svg>
12
+ );
13
+
14
+ export default ArrowUpRightIcon;
@@ -0,0 +1,14 @@
1
+ /* eslint-disable max-len */
2
+ import React from "react";
3
+
4
+ const CalendarIcon = ({ ...props }) => (
5
+ <svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
6
+ <path
7
+ fillRule="evenodd"
8
+ d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z"
9
+ clipRule="evenodd"
10
+ />
11
+ </svg>
12
+ );
13
+
14
+ export default CalendarIcon;
@@ -0,0 +1,18 @@
1
+ /* eslint-disable max-len */
2
+ import React from "react";
3
+
4
+ const DoubleArrowLeftHeadIcon = ({ ...props }) => (
5
+ <svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
6
+ <path id="svg_1" d="m0,0l24,0l0,24l-24,0l0,-24z" fill="none" />
7
+ <path
8
+ id="svg_2"
9
+ d="m14.1247,12l4.95,4.95l-1.414,1.414l-6.364,-6.364l6.364,-6.364l1.414,1.414l-4.95,4.95z"
10
+ />
11
+ <path
12
+ id="svg_3"
13
+ d="m7.31152,12l4.95,4.95l-1.414,1.414l-6.364,-6.364l6.364,-6.364l1.414,1.414l-4.95,4.95z"
14
+ />
15
+ </svg>
16
+ );
17
+
18
+ export default DoubleArrowLeftHeadIcon;
@@ -0,0 +1,20 @@
1
+ /* eslint-disable max-len */
2
+ import React from "react";
3
+
4
+ const DoubleArrowRightHeadIcon = ({ ...props }) => (
5
+ <svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
6
+ <path id="svg_1" d="m0,0l24,0l0,24l-24,0l0,-24z" fill="none" />
7
+ <path
8
+ transform="rotate(180 15.1857 12)"
9
+ id="svg_2"
10
+ d="m14.1247,12l4.95,4.95l-1.414,1.414l-6.364,-6.364l6.364,-6.364l1.414,1.414l-4.95,4.95z"
11
+ />
12
+ <path
13
+ transform="rotate(180 8.37252 12)"
14
+ id="svg_3"
15
+ d="m7.31152,12l4.95,4.95l-1.414,1.414l-6.364,-6.364l6.364,-6.364l1.414,1.414l-4.95,4.95z"
16
+ />
17
+ </svg>
18
+ );
19
+
20
+ export default DoubleArrowRightHeadIcon;
@@ -0,0 +1,14 @@
1
+ /* eslint-disable max-len */
2
+ import React from "react";
3
+
4
+ const ExclamationFilledIcon = ({ ...props }) => (
5
+ <svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
6
+ <path
7
+ fillRule="evenodd"
8
+ d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z"
9
+ clipRule="evenodd"
10
+ />
11
+ </svg>
12
+ );
13
+
14
+ export default ExclamationFilledIcon;
@@ -0,0 +1,11 @@
1
+ /* eslint-disable max-len */
2
+ import React from "react";
3
+
4
+ const LoadingSpinner = ({ ...props }) => (
5
+ <svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
6
+ <path fill="none" d="M0 0h24v24H0z" />
7
+ <path d="M18.364 5.636L16.95 7.05A7 7 0 1 0 19 12h2a9 9 0 1 1-2.636-6.364z" />
8
+ </svg>
9
+ );
10
+
11
+ export default LoadingSpinner;
@@ -0,0 +1,14 @@
1
+ /* eslint-disable max-len */
2
+ import React from "react";
3
+
4
+ const SearchIcon = ({ ...props }) => (
5
+ <svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
6
+ <path
7
+ fillRule="evenodd"
8
+ d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z"
9
+ clipRule="evenodd"
10
+ />
11
+ </svg>
12
+ );
13
+
14
+ export default SearchIcon;
@@ -0,0 +1,14 @@
1
+ /* eslint-disable max-len */
2
+ import React from "react";
3
+
4
+ const XCircleIcon = ({ ...props }) => (
5
+ <svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
6
+ <path
7
+ fillRule="evenodd"
8
+ d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z"
9
+ clipRule="evenodd"
10
+ />
11
+ </svg>
12
+ );
13
+
14
+ export default XCircleIcon;
@@ -0,0 +1,16 @@
1
+ export { default as ArrowDownHeadIcon } from "./ArrowDownHeadIcon";
2
+ export { default as ArrowDownRightIcon } from "./ArrowDownRightIcon";
3
+ export { default as ArrowDownIcon } from "./ArrowDownIcon";
4
+ export { default as ArrowRightIcon } from "./ArrowRightIcon";
5
+ export { default as ArrowRightHeadIcon } from "./ArrowRightHeadIcon";
6
+ export { default as ArrowLeftHeadIcon } from "./ArrowLeftHeadIcon";
7
+ export { default as DoubleArrowLeftHeadIcon } from "./DoubleArrowLeftHeadIcon";
8
+ export { default as DoubleArrowRightHeadIcon } from "./DoubleArrowRightHeadIcon";
9
+ export { default as ArrowUpHeadIcon } from "./ArrowUpHeadIcon";
10
+ export { default as ArrowUpIcon } from "./ArrowUpIcon";
11
+ export { default as ArrowUpRightIcon } from "./ArrowUpRightIcon";
12
+ export { default as CalendarIcon } from "./CalendarIcon";
13
+ export { default as ExclamationFilledIcon } from "./ExclamationFilledIcon";
14
+ export { default as LoadingSpinner } from "./LoadingSpinner";
15
+ export { default as SearchIcon } from "./SearchIcon";
16
+ export { default as XCircleIcon } from "./XCircleIcon";
@@ -0,0 +1,179 @@
1
+ /* eslint-disable react/display-name */
2
+ import React, { useRef, useState } from 'react';
3
+ import { twMerge } from 'tailwind-merge';
4
+
5
+ import { HoveredValueContext, SelectedValueContext } from '../../contexts';
6
+
7
+ import { useInternalState, useSelectOnKeyDown } from '../../hooks';
8
+
9
+ import { ArrowDownHeadIcon } from '../../assets';
10
+
11
+ import {
12
+ BaseColors,
13
+ border,
14
+ borderRadius,
15
+ boxShadow,
16
+ fontSize,
17
+ fontWeight,
18
+ getColorClassNames,
19
+ makeClassName,
20
+ mergeRefs,
21
+ sizing,
22
+ spacing,
23
+ } from '../../lib';
24
+ import {
25
+ constructValueToNameMapping,
26
+ getSelectButtonColors,
27
+ hasValue,
28
+ } from '../selectUtils';
29
+ import { DropdownItemProps } from './DropdownItem';
30
+ import Modal from '../Modal';
31
+ import { DEFAULT_COLOR, colorPalette } from '../../lib/theme';
32
+
33
+ const makeDropdownClassName = makeClassName('Dropdown');
34
+
35
+ export interface DropdownProps extends React.HTMLAttributes<HTMLDivElement> {
36
+ value?: string;
37
+ defaultValue?: string;
38
+ onValueChange?: (value: string) => void;
39
+ placeholder?: string;
40
+ disabled?: boolean;
41
+ icon?: React.JSXElementConstructor<any>;
42
+ children: React.ReactElement[] | React.ReactElement;
43
+ }
44
+
45
+ const Dropdown = React.forwardRef<HTMLDivElement, DropdownProps>(
46
+ (props, ref) => {
47
+ const {
48
+ defaultValue,
49
+ value,
50
+ onValueChange,
51
+ placeholder = 'Select...',
52
+ disabled = false,
53
+ icon,
54
+ children,
55
+ className,
56
+ ...other
57
+ } = props;
58
+ const [selectedValue, setSelectedValue] = useInternalState(
59
+ defaultValue,
60
+ value
61
+ );
62
+ const [isFocused, setIsFocused] = useState(false);
63
+
64
+ const dropdownRef = useRef(null);
65
+
66
+ const Icon = icon;
67
+ const valueToNameMapping = constructValueToNameMapping(children);
68
+ const optionValues = React.Children.map(
69
+ children,
70
+ (child: { props: DropdownItemProps }) => child.props.value
71
+ );
72
+
73
+ const handleValueChange = (value: string) => {
74
+ setSelectedValue(value);
75
+ setIsFocused(false);
76
+ onValueChange?.(value);
77
+ };
78
+
79
+ const [hoveredValue, handleKeyDown] = useSelectOnKeyDown(
80
+ handleValueChange,
81
+ optionValues,
82
+ isFocused,
83
+ setIsFocused,
84
+ selectedValue
85
+ );
86
+
87
+ const hasSelection = hasValue(selectedValue);
88
+
89
+ return (
90
+ <div
91
+ ref={mergeRefs([dropdownRef, ref])}
92
+ onKeyDown={handleKeyDown}
93
+ className={twMerge(
94
+ makeDropdownClassName('root'),
95
+ 'relative w-full min-w-[10rem]',
96
+ className
97
+ )}
98
+ {...other}
99
+ >
100
+ <button
101
+ type="button"
102
+ className={twMerge(
103
+ makeDropdownClassName('button'),
104
+ 'flex justify-between items-center w-full focus:outline-none focus:ring-2',
105
+ getSelectButtonColors(hasSelection, disabled),
106
+ getColorClassNames(BaseColors.Blue, colorPalette.lightRing)
107
+ .focusRingColor,
108
+ Icon ? spacing.xl.paddingLeft : spacing.twoXl.paddingLeft,
109
+ spacing.twoXl.paddingRight,
110
+ spacing.sm.paddingY,
111
+ borderRadius.md.all,
112
+ border.sm.all,
113
+ boxShadow.sm
114
+ )}
115
+ onClick={() => setIsFocused(!isFocused)}
116
+ disabled={disabled}
117
+ >
118
+ <div className="flex justify-start items-center truncate">
119
+ {Icon ? (
120
+ <Icon
121
+ className={twMerge(
122
+ makeDropdownClassName('icon'),
123
+ 'shrink-0',
124
+ sizing.lg.height,
125
+ sizing.lg.width,
126
+ getColorClassNames(DEFAULT_COLOR, colorPalette.lightText)
127
+ .textColor,
128
+ spacing.lg.marginRight
129
+ )}
130
+ aria-hidden="true"
131
+ />
132
+ ) : null}
133
+ <p
134
+ className={twMerge(
135
+ makeDropdownClassName('text'),
136
+ 'whitespace-nowrap truncate',
137
+ fontSize.sm,
138
+ fontWeight.md
139
+ )}
140
+ >
141
+ {selectedValue
142
+ ? valueToNameMapping.get(selectedValue)
143
+ : placeholder}
144
+ </p>
145
+ </div>
146
+ <ArrowDownHeadIcon
147
+ className={twMerge(
148
+ makeDropdownClassName('arrowDownIcon'),
149
+ 'flex-none',
150
+ sizing.lg.height,
151
+ sizing.lg.width,
152
+ spacing.twoXs.negativeMarginRight,
153
+ getColorClassNames(DEFAULT_COLOR, colorPalette.lightText)
154
+ .textColor
155
+ )}
156
+ aria-hidden="true"
157
+ />
158
+ </button>
159
+ <Modal
160
+ showModal={isFocused}
161
+ setShowModal={setIsFocused}
162
+ parentRef={dropdownRef}
163
+ >
164
+ <SelectedValueContext.Provider
165
+ value={{ selectedValue, handleValueChange }}
166
+ >
167
+ <HoveredValueContext.Provider value={{ hoveredValue }}>
168
+ {React.Children.map(children, (child: React.ReactElement) =>
169
+ React.cloneElement(child)
170
+ )}
171
+ </HoveredValueContext.Provider>
172
+ </SelectedValueContext.Provider>
173
+ </Modal>
174
+ </div>
175
+ );
176
+ }
177
+ );
178
+
179
+ export default Dropdown;
@@ -0,0 +1,86 @@
1
+ /* eslint-disable react/display-name */
2
+ import React, { useContext } from 'react';
3
+ import { twMerge } from 'tailwind-merge';
4
+
5
+ import { HoveredValueContext, SelectedValueContext } from '../../contexts';
6
+
7
+ import { fontSize } from '../../lib/font';
8
+ import { sizing } from '../../lib/sizing';
9
+ import { spacing } from '../../lib/spacing';
10
+
11
+ import { getColorClassNames, makeClassName } from '../../lib';
12
+ import { DEFAULT_COLOR, colorPalette } from '../../lib/theme';
13
+
14
+ const makeDropdownItemClassName = makeClassName('DropdownItem');
15
+
16
+ export interface DropdownItemProps
17
+ extends React.ButtonHTMLAttributes<HTMLButtonElement> {
18
+ value: string;
19
+ text?: string;
20
+ icon?: React.ElementType;
21
+ }
22
+
23
+ const DropdownItem = React.forwardRef<HTMLButtonElement, DropdownItemProps>(
24
+ (props, ref) => {
25
+ const { value, text, icon, className, ...other } = props;
26
+ const { selectedValue, handleValueChange } =
27
+ useContext(SelectedValueContext);
28
+ const { hoveredValue } = useContext(HoveredValueContext);
29
+ const isActive = selectedValue === value;
30
+ const isHovered = hoveredValue === value;
31
+ const bgColor = isActive
32
+ ? getColorClassNames(DEFAULT_COLOR, colorPalette.lightBackground).bgColor
33
+ : isHovered
34
+ ? getColorClassNames(DEFAULT_COLOR, colorPalette.canvasBackground).bgColor
35
+ : getColorClassNames(DEFAULT_COLOR, colorPalette.canvasBackground)
36
+ .hoverBgColor;
37
+ const textColor = isActive
38
+ ? getColorClassNames(DEFAULT_COLOR, colorPalette.darkestText).textColor
39
+ : getColorClassNames(DEFAULT_COLOR, colorPalette.darkText).textColor;
40
+
41
+ const Icon = icon ? icon : null;
42
+ return (
43
+ <button
44
+ ref={ref}
45
+ type="button"
46
+ onClick={() => handleValueChange?.(value)}
47
+ className={twMerge(
48
+ makeDropdownItemClassName('root'),
49
+ 'flex items-center justify-start w-full truncate',
50
+ spacing.twoXl.paddingX,
51
+ spacing.md.paddingY,
52
+ fontSize.sm,
53
+ bgColor,
54
+ textColor,
55
+ className
56
+ )}
57
+ {...other}
58
+ >
59
+ {Icon ? (
60
+ <Icon
61
+ className={twMerge(
62
+ makeDropdownItemClassName('icon'),
63
+ 'flex-none',
64
+ sizing.lg.height,
65
+ sizing.lg.width,
66
+ spacing.lg.marginRight,
67
+ getColorClassNames(DEFAULT_COLOR, colorPalette.lightText)
68
+ .textColor
69
+ )}
70
+ aria-hidden="true"
71
+ />
72
+ ) : null}
73
+ <p
74
+ className={twMerge(
75
+ makeDropdownItemClassName('text'),
76
+ 'text-sm whitespace-nowrap truncate'
77
+ )}
78
+ >
79
+ {text ?? value}
80
+ </p>
81
+ </button>
82
+ );
83
+ }
84
+ );
85
+
86
+ export default DropdownItem;
@@ -0,0 +1,2 @@
1
+ export { default as Dropdown } from "./Dropdown";
2
+ export { default as DropdownItem } from "./DropdownItem";
@@ -0,0 +1,113 @@
1
+ /* eslint-disable react/display-name */
2
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
3
+ import { twMerge } from 'tailwind-merge';
4
+
5
+ import { useOnClickOutside, useOnWindowResize } from '../../hooks';
6
+
7
+ import { HorizontalPosition } from '../../lib/inputTypes';
8
+ import {
9
+ border,
10
+ borderRadius,
11
+ boxShadow,
12
+ getColorClassNames,
13
+ mergeRefs,
14
+ spacing,
15
+ } from '../../lib';
16
+ import { DEFAULT_COLOR, colorPalette } from '../../lib/theme';
17
+
18
+ export interface ModalProps extends React.HTMLAttributes<HTMLDivElement> {
19
+ showModal: boolean;
20
+ setShowModal:
21
+ | React.Dispatch<React.SetStateAction<boolean>>
22
+ | ((nextState: boolean) => void);
23
+ parentRef: React.RefObject<HTMLElement>;
24
+ width?: number;
25
+ maxHeight?: string;
26
+ anchorPosition?: HorizontalPosition;
27
+ children: React.ReactNode;
28
+ }
29
+
30
+ const Modal = React.forwardRef<HTMLDivElement, ModalProps>((props, ref) => {
31
+ const {
32
+ showModal,
33
+ setShowModal,
34
+ parentRef,
35
+ width,
36
+ maxHeight = 'max-h-72',
37
+ children,
38
+ className,
39
+ ...other
40
+ } = props;
41
+ const [modalExceedsWindow, setModalExceedsWindow] = useState(false);
42
+
43
+ const modalRef = useRef<HTMLDivElement>(null);
44
+
45
+ const checkModalExceedsWindow = useCallback(
46
+ (modalWidth: number, windowWidth: number): boolean => {
47
+ if (!parentRef.current) {
48
+ return false;
49
+ }
50
+ const modalBoundingRight =
51
+ parentRef.current.getBoundingClientRect().left + modalWidth;
52
+ return windowWidth - modalBoundingRight < 0;
53
+ },
54
+ [parentRef]
55
+ );
56
+
57
+ const getAbsoluteSpacing = () => {
58
+ if (!modalExceedsWindow) {
59
+ return spacing.none.left;
60
+ }
61
+ return spacing.none.right;
62
+ };
63
+
64
+ useOnClickOutside(modalRef, e => {
65
+ // Exclude click on trigger button (e.g. Dropdown Button) from outside click handler
66
+ const isTriggerElem = parentRef
67
+ ? parentRef.current?.contains(e.target)
68
+ : false;
69
+ if (!isTriggerElem) {
70
+ setShowModal(false);
71
+ }
72
+ });
73
+
74
+ // Execute only when modal is of absolute size
75
+ useEffect(() => {
76
+ if (width) {
77
+ setModalExceedsWindow(checkModalExceedsWindow(width, window.innerWidth));
78
+ }
79
+ }, [checkModalExceedsWindow, parentRef, width]);
80
+
81
+ useOnWindowResize(() => {
82
+ if (width) {
83
+ setModalExceedsWindow(checkModalExceedsWindow(width, window.innerWidth));
84
+ }
85
+ });
86
+
87
+ return showModal ? (
88
+ <div
89
+ ref={mergeRefs([modalRef, ref])}
90
+ className={twMerge(
91
+ 'absolute z-10 divide-y overflow-y-auto',
92
+ width ? '' : 'w-full',
93
+ getAbsoluteSpacing(),
94
+ maxHeight,
95
+ getColorClassNames('white').bgColor,
96
+ getColorClassNames(DEFAULT_COLOR, colorPalette.lightBorder).borderColor,
97
+ getColorClassNames(DEFAULT_COLOR, colorPalette.lightBorder).divideColor,
98
+ spacing.twoXs.marginTop,
99
+ spacing.twoXs.marginBottom,
100
+ borderRadius.md.all,
101
+ border.sm.all,
102
+ boxShadow.lg,
103
+ className
104
+ )}
105
+ style={{ width }}
106
+ {...other}
107
+ >
108
+ {children}
109
+ </div>
110
+ ) : null;
111
+ });
112
+
113
+ export default Modal;
@@ -0,0 +1 @@
1
+ export { default } from "./Modal";