@darajs/ui-components 1.0.0-a.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/LICENSE +201 -0
  2. package/dist/accordion/accordion-item.d.ts +25 -0
  3. package/dist/accordion/accordion-item.d.ts.map +1 -0
  4. package/dist/accordion/accordion-item.js +90 -0
  5. package/dist/accordion/accordion-item.js.map +1 -0
  6. package/dist/accordion/accordion.d.ts +33 -0
  7. package/dist/accordion/accordion.d.ts.map +1 -0
  8. package/dist/accordion/accordion.js +86 -0
  9. package/dist/accordion/accordion.js.map +1 -0
  10. package/dist/badge/badge.d.ts +21 -0
  11. package/dist/badge/badge.d.ts.map +1 -0
  12. package/dist/badge/badge.js +42 -0
  13. package/dist/badge/badge.js.map +1 -0
  14. package/dist/button/button.d.ts +35 -0
  15. package/dist/button/button.d.ts.map +1 -0
  16. package/dist/button/button.js +169 -0
  17. package/dist/button/button.js.map +1 -0
  18. package/dist/button-bar/button-bar.d.ts +19 -0
  19. package/dist/button-bar/button-bar.d.ts.map +1 -0
  20. package/dist/button-bar/button-bar.js +123 -0
  21. package/dist/button-bar/button-bar.js.map +1 -0
  22. package/dist/carousel/carousel.d.ts +24 -0
  23. package/dist/carousel/carousel.d.ts.map +1 -0
  24. package/dist/carousel/carousel.js +175 -0
  25. package/dist/carousel/carousel.js.map +1 -0
  26. package/dist/checkbox/checkbox-group.d.ts +36 -0
  27. package/dist/checkbox/checkbox-group.d.ts.map +1 -0
  28. package/dist/checkbox/checkbox-group.js +116 -0
  29. package/dist/checkbox/checkbox-group.js.map +1 -0
  30. package/dist/checkbox/checkbox.d.ts +28 -0
  31. package/dist/checkbox/checkbox.d.ts.map +1 -0
  32. package/dist/checkbox/checkbox.js +162 -0
  33. package/dist/checkbox/checkbox.js.map +1 -0
  34. package/dist/checkbox/tri-state-checkbox.d.ts +23 -0
  35. package/dist/checkbox/tri-state-checkbox.d.ts.map +1 -0
  36. package/dist/checkbox/tri-state-checkbox.js +87 -0
  37. package/dist/checkbox/tri-state-checkbox.js.map +1 -0
  38. package/dist/combo-box/combo-box.d.ts +328 -0
  39. package/dist/combo-box/combo-box.d.ts.map +1 -0
  40. package/dist/combo-box/combo-box.js +213 -0
  41. package/dist/combo-box/combo-box.js.map +1 -0
  42. package/dist/component-select-list/component-select-list.d.ts +27 -0
  43. package/dist/component-select-list/component-select-list.d.ts.map +1 -0
  44. package/dist/component-select-list/component-select-list.js +129 -0
  45. package/dist/component-select-list/component-select-list.js.map +1 -0
  46. package/dist/constants.d.ts +33 -0
  47. package/dist/constants.d.ts.map +1 -0
  48. package/dist/constants.js +47 -0
  49. package/dist/constants.js.map +1 -0
  50. package/dist/context-menu/context-menu.d.ts +24 -0
  51. package/dist/context-menu/context-menu.d.ts.map +1 -0
  52. package/dist/context-menu/context-menu.js +112 -0
  53. package/dist/context-menu/context-menu.js.map +1 -0
  54. package/dist/datepicker/datepicker-select.d.ts +50 -0
  55. package/dist/datepicker/datepicker-select.d.ts.map +1 -0
  56. package/dist/datepicker/datepicker-select.js +211 -0
  57. package/dist/datepicker/datepicker-select.js.map +1 -0
  58. package/dist/datepicker/datepicker.d.ts +57 -0
  59. package/dist/datepicker/datepicker.d.ts.map +1 -0
  60. package/dist/datepicker/datepicker.js +608 -0
  61. package/dist/datepicker/datepicker.js.map +1 -0
  62. package/dist/dropzone/dropzone.d.ts +20 -0
  63. package/dist/dropzone/dropzone.d.ts.map +1 -0
  64. package/dist/dropzone/dropzone.js +77 -0
  65. package/dist/dropzone/dropzone.js.map +1 -0
  66. package/dist/error-boundary/error-boundary.d.ts +33 -0
  67. package/dist/error-boundary/error-boundary.d.ts.map +1 -0
  68. package/dist/error-boundary/error-boundary.js +72 -0
  69. package/dist/error-boundary/error-boundary.js.map +1 -0
  70. package/dist/filter/categorical-filter.d.ts +27 -0
  71. package/dist/filter/categorical-filter.d.ts.map +1 -0
  72. package/dist/filter/categorical-filter.js +150 -0
  73. package/dist/filter/categorical-filter.js.map +1 -0
  74. package/dist/filter/datetime-filter.d.ts +29 -0
  75. package/dist/filter/datetime-filter.d.ts.map +1 -0
  76. package/dist/filter/datetime-filter.js +196 -0
  77. package/dist/filter/datetime-filter.js.map +1 -0
  78. package/dist/filter/numeric-filter.d.ts +25 -0
  79. package/dist/filter/numeric-filter.d.ts.map +1 -0
  80. package/dist/filter/numeric-filter.js +146 -0
  81. package/dist/filter/numeric-filter.js.map +1 -0
  82. package/dist/hierarchy-selector/hierarchy-selector.d.ts +31 -0
  83. package/dist/hierarchy-selector/hierarchy-selector.d.ts.map +1 -0
  84. package/dist/hierarchy-selector/hierarchy-selector.js +65 -0
  85. package/dist/hierarchy-selector/hierarchy-selector.js.map +1 -0
  86. package/dist/hierarchy-selector/node/branch.d.ts +47 -0
  87. package/dist/hierarchy-selector/node/branch.d.ts.map +1 -0
  88. package/dist/hierarchy-selector/node/branch.js +133 -0
  89. package/dist/hierarchy-selector/node/branch.js.map +1 -0
  90. package/dist/index.d.ts +54 -0
  91. package/dist/index.d.ts.map +1 -0
  92. package/dist/index.js +52 -0
  93. package/dist/index.js.map +1 -0
  94. package/dist/input/input.d.ts +58 -0
  95. package/dist/input/input.d.ts.map +1 -0
  96. package/dist/input/input.js +102 -0
  97. package/dist/input/input.js.map +1 -0
  98. package/dist/jest-setup.d.ts +18 -0
  99. package/dist/jest-setup.d.ts.map +1 -0
  100. package/dist/jest-setup.js +18 -0
  101. package/dist/jest-setup.js.map +1 -0
  102. package/dist/modal/modal.d.ts +37 -0
  103. package/dist/modal/modal.d.ts.map +1 -0
  104. package/dist/modal/modal.js +120 -0
  105. package/dist/modal/modal.js.map +1 -0
  106. package/dist/multiselect/multiselect.d.ts +31 -0
  107. package/dist/multiselect/multiselect.d.ts.map +1 -0
  108. package/dist/multiselect/multiselect.js +282 -0
  109. package/dist/multiselect/multiselect.js.map +1 -0
  110. package/dist/numeric-input/input-stepper.d.ts +33 -0
  111. package/dist/numeric-input/input-stepper.d.ts.map +1 -0
  112. package/dist/numeric-input/input-stepper.js +54 -0
  113. package/dist/numeric-input/input-stepper.js.map +1 -0
  114. package/dist/numeric-input/numeric-input.d.ts +48 -0
  115. package/dist/numeric-input/numeric-input.d.ts.map +1 -0
  116. package/dist/numeric-input/numeric-input.js +199 -0
  117. package/dist/numeric-input/numeric-input.js.map +1 -0
  118. package/dist/progress-bar/progress-bar.d.ts +23 -0
  119. package/dist/progress-bar/progress-bar.d.ts.map +1 -0
  120. package/dist/progress-bar/progress-bar.js +88 -0
  121. package/dist/progress-bar/progress-bar.js.map +1 -0
  122. package/dist/radio/radio-group.d.ts +20 -0
  123. package/dist/radio/radio-group.d.ts.map +1 -0
  124. package/dist/radio/radio-group.js +158 -0
  125. package/dist/radio/radio-group.js.map +1 -0
  126. package/dist/search-bar/search-bar.d.ts +34 -0
  127. package/dist/search-bar/search-bar.d.ts.map +1 -0
  128. package/dist/search-bar/search-bar.js +39 -0
  129. package/dist/search-bar/search-bar.js.map +1 -0
  130. package/dist/sectioned-list/sectioned-list.d.ts +29 -0
  131. package/dist/sectioned-list/sectioned-list.d.ts.map +1 -0
  132. package/dist/sectioned-list/sectioned-list.js +208 -0
  133. package/dist/sectioned-list/sectioned-list.js.map +1 -0
  134. package/dist/select/select.d.ts +54 -0
  135. package/dist/select/select.d.ts.map +1 -0
  136. package/dist/select/select.js +159 -0
  137. package/dist/select/select.js.map +1 -0
  138. package/dist/slider/slider-inputs.d.ts +36 -0
  139. package/dist/slider/slider-inputs.d.ts.map +1 -0
  140. package/dist/slider/slider-inputs.js +85 -0
  141. package/dist/slider/slider-inputs.js.map +1 -0
  142. package/dist/slider/slider.d.ts +53 -0
  143. package/dist/slider/slider.d.ts.map +1 -0
  144. package/dist/slider/slider.js +267 -0
  145. package/dist/slider/slider.js.map +1 -0
  146. package/dist/spinner/spinner.d.ts +20 -0
  147. package/dist/spinner/spinner.d.ts.map +1 -0
  148. package/dist/spinner/spinner.js +132 -0
  149. package/dist/spinner/spinner.js.map +1 -0
  150. package/dist/switch/sun-icon.d.ts +3 -0
  151. package/dist/switch/sun-icon.d.ts.map +1 -0
  152. package/dist/switch/sun-icon.js +24 -0
  153. package/dist/switch/sun-icon.js.map +1 -0
  154. package/dist/switch/switch.d.ts +17 -0
  155. package/dist/switch/switch.d.ts.map +1 -0
  156. package/dist/switch/switch.js +92 -0
  157. package/dist/switch/switch.js.map +1 -0
  158. package/dist/table/cells/action-cell.d.ts +34 -0
  159. package/dist/table/cells/action-cell.d.ts.map +1 -0
  160. package/dist/table/cells/action-cell.js +68 -0
  161. package/dist/table/cells/action-cell.js.map +1 -0
  162. package/dist/table/cells/datetime-cell.d.ts +12 -0
  163. package/dist/table/cells/datetime-cell.d.ts.map +1 -0
  164. package/dist/table/cells/datetime-cell.js +36 -0
  165. package/dist/table/cells/datetime-cell.js.map +1 -0
  166. package/dist/table/cells/edit-cell-utils.d.ts +32 -0
  167. package/dist/table/cells/edit-cell-utils.d.ts.map +1 -0
  168. package/dist/table/cells/edit-cell-utils.js +2 -0
  169. package/dist/table/cells/edit-cell-utils.js.map +1 -0
  170. package/dist/table/cells/edit-input-cell.d.ts +10 -0
  171. package/dist/table/cells/edit-input-cell.d.ts.map +1 -0
  172. package/dist/table/cells/edit-input-cell.js +61 -0
  173. package/dist/table/cells/edit-input-cell.js.map +1 -0
  174. package/dist/table/cells/edit-select-cell.d.ts +12 -0
  175. package/dist/table/cells/edit-select-cell.d.ts.map +1 -0
  176. package/dist/table/cells/edit-select-cell.js +55 -0
  177. package/dist/table/cells/edit-select-cell.js.map +1 -0
  178. package/dist/table/filters.d.ts +46 -0
  179. package/dist/table/filters.d.ts.map +1 -0
  180. package/dist/table/filters.js +223 -0
  181. package/dist/table/filters.js.map +1 -0
  182. package/dist/table/headers/select-header.d.ts +14 -0
  183. package/dist/table/headers/select-header.d.ts.map +1 -0
  184. package/dist/table/headers/select-header.js +41 -0
  185. package/dist/table/headers/select-header.js.map +1 -0
  186. package/dist/table/options-menu.d.ts +25 -0
  187. package/dist/table/options-menu.d.ts.map +1 -0
  188. package/dist/table/options-menu.js +120 -0
  189. package/dist/table/options-menu.js.map +1 -0
  190. package/dist/table/table.d.ts +95 -0
  191. package/dist/table/table.d.ts.map +1 -0
  192. package/dist/table/table.js +524 -0
  193. package/dist/table/table.js.map +1 -0
  194. package/dist/table/types.d.ts +30 -0
  195. package/dist/table/types.d.ts.map +1 -0
  196. package/dist/table/types.js +2 -0
  197. package/dist/table/types.js.map +1 -0
  198. package/dist/tabs/tabs.d.ts +22 -0
  199. package/dist/tabs/tabs.d.ts.map +1 -0
  200. package/dist/tabs/tabs.js +88 -0
  201. package/dist/tabs/tabs.js.map +1 -0
  202. package/dist/textarea/textarea.d.ts +45 -0
  203. package/dist/textarea/textarea.d.ts.map +1 -0
  204. package/dist/textarea/textarea.js +77 -0
  205. package/dist/textarea/textarea.js.map +1 -0
  206. package/dist/tooltip/tooltip.d.ts +46 -0
  207. package/dist/tooltip/tooltip.d.ts.map +1 -0
  208. package/dist/tooltip/tooltip.js +116 -0
  209. package/dist/tooltip/tooltip.js.map +1 -0
  210. package/dist/types.d.ts +66 -0
  211. package/dist/types.d.ts.map +1 -0
  212. package/dist/types.js +2 -0
  213. package/dist/types.js.map +1 -0
  214. package/dist/utils/chevron.d.ts +34 -0
  215. package/dist/utils/chevron.d.ts.map +1 -0
  216. package/dist/utils/chevron.js +40 -0
  217. package/dist/utils/chevron.js.map +1 -0
  218. package/dist/utils/index.d.ts +22 -0
  219. package/dist/utils/index.d.ts.map +1 -0
  220. package/dist/utils/index.js +22 -0
  221. package/dist/utils/index.js.map +1 -0
  222. package/dist/utils/label.d.ts +3 -0
  223. package/dist/utils/label.d.ts.map +1 -0
  224. package/dist/utils/label.js +24 -0
  225. package/dist/utils/label.js.map +1 -0
  226. package/dist/utils/list-styles.d.ts +12 -0
  227. package/dist/utils/list-styles.d.ts.map +1 -0
  228. package/dist/utils/list-styles.js +58 -0
  229. package/dist/utils/list-styles.js.map +1 -0
  230. package/dist/utils/same-width-modifier.d.ts +23 -0
  231. package/dist/utils/same-width-modifier.d.ts.map +1 -0
  232. package/dist/utils/same-width-modifier.js +17 -0
  233. package/dist/utils/same-width-modifier.js.map +1 -0
  234. package/dist/utils/use-infinite-loader.d.ts +32 -0
  235. package/dist/utils/use-infinite-loader.d.ts.map +1 -0
  236. package/dist/utils/use-infinite-loader.js +114 -0
  237. package/dist/utils/use-infinite-loader.js.map +1 -0
  238. package/dist/utils/use-on-click-outside.d.ts +3 -0
  239. package/dist/utils/use-on-click-outside.d.ts.map +1 -0
  240. package/dist/utils/use-on-click-outside.js +36 -0
  241. package/dist/utils/use-on-click-outside.js.map +1 -0
  242. package/package.json +105 -0
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * Copyright 2023 Impulse Innovations Limited
4
+ *
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import TriStateCheckbox, { CheckboxState } from '../../checkbox/tri-state-checkbox';
19
+ import { Action } from '../cells/action-cell';
20
+ /**
21
+ * A table header with a tri-state checkbox, for bulk selection actions
22
+ *
23
+ * @param {selectHeaderProps} props - the component props
24
+ */
25
+ function SelectHeader(props) {
26
+ const allValues = props.rows.map((r) => r.original.selected);
27
+ const countSelected = allValues.filter(Boolean).length;
28
+ const allSelected = countSelected > 0 && countSelected === allValues.length;
29
+ const noneSelected = countSelected === 0;
30
+ const onChange = (state) => {
31
+ if (state === CheckboxState.UNCHECKED) {
32
+ props.onAction(Action.UNSELECT_ALL);
33
+ }
34
+ else if (state === CheckboxState.CHECKED) {
35
+ props.onAction(Action.SELECT_ALL, props.rows.map((r) => r.original));
36
+ }
37
+ };
38
+ return (_jsx(TriStateCheckbox, { allSelected: allSelected, noneSelected: noneSelected, onChange: onChange, style: { display: 'flex', justifyContent: 'center' } }));
39
+ }
40
+ export default SelectHeader;
41
+ //# sourceMappingURL=select-header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select-header.js","sourceRoot":"","sources":["../../../src/table/headers/select-header.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,gBAAgB,EAAE,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAS9C;;;;GAIG;AACH,SAAS,YAAY,CAAC,KAAwB;IAC1C,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAClE,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;IAEvD,MAAM,WAAW,GAAG,aAAa,GAAG,CAAC,IAAI,aAAa,KAAK,SAAS,CAAC,MAAM,CAAC;IAC5E,MAAM,YAAY,GAAG,aAAa,KAAK,CAAC,CAAC;IAEzC,MAAM,QAAQ,GAAG,CAAC,KAAoB,EAAQ,EAAE;QAC5C,IAAI,KAAK,KAAK,aAAa,CAAC,SAAS,EAAE;YACnC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;SACvC;aAAM,IAAI,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE;YACxC,KAAK,CAAC,QAAQ,CACV,MAAM,CAAC,UAAU,EACjB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CACzC,CAAC;SACL;IACL,CAAC,CAAC;IACF,OAAO,CACH,KAAC,gBAAgB,IACb,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,GACtD,CACL,CAAC;AACN,CAAC;AAED,eAAe,YAAY,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ColumnInstance, Filters } from 'react-table';
3
+ interface OptionsMenuProps {
4
+ /** all columns from the table component */
5
+ allColumns: ColumnInstance<any>[];
6
+ /** Optional flag to enable column hiding */
7
+ allowColumnHiding?: boolean;
8
+ /** count of currently visible columns */
9
+ numVisibleColumns: number;
10
+ /** column resizing reset function callback from useTable */
11
+ resetResizing: () => void;
12
+ /** filter setter from useTable */
13
+ setAllFilters: (updater: Filters<any> | ((filters: Filters<any>) => Filters<any>)) => void;
14
+ /** Pass through of the style prop to the table options Dropdown */
15
+ style: React.CSSProperties;
16
+ }
17
+ /**
18
+ * The OptionsMenu component adds a sectioned list menu to the Table component.
19
+ * It inherits the ability to reset column widths and filters from react-table's useTable hook
20
+ *
21
+ * @param props - the component props
22
+ */
23
+ declare const OptionsMenu: FunctionComponent<OptionsMenuProps>;
24
+ export default OptionsMenu;
25
+ //# sourceMappingURL=options-menu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options-menu.d.ts","sourceRoot":"","sources":["../../src/table/options-menu.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAE,iBAAiB,EAAgC,MAAM,OAAO,CAAC;AAGxE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA8BtD,UAAU,gBAAgB;IACtB,2CAA2C;IAC3C,UAAU,EAAE,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,4CAA4C;IAC5C,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,yCAAyC;IACzC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,4DAA4D;IAC5D,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,kCAAkC;IAClC,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC;IAC3F,mEAAmE;IACnE,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC;CAC9B;AAED;;;;;GAKG;AACH,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,CA0GpD,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,120 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Copyright 2023 Impulse Innovations Limited
4
+ *
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import { faEllipsisV } from '@fortawesome/free-solid-svg-icons';
19
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
20
+ import { useEffect, useMemo, useState } from 'react';
21
+ import ReactDOM from 'react-dom';
22
+ import { usePopper } from 'react-popper';
23
+ import styled from '@darajs/styled-components';
24
+ import { useOnClickOutside } from '@darajs/ui-utils';
25
+ import SectionedList from '../sectioned-list/sectioned-list';
26
+ import { List } from '../utils';
27
+ const HeaderOptionsIcon = styled(FontAwesomeIcon) `
28
+ cursor: pointer;
29
+ align-items: center;
30
+ color: ${(props) => props.theme.colors.grey5};
31
+ `;
32
+ const HeaderOptions = styled.div `
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: center;
36
+
37
+ width: 12px;
38
+
39
+ background-color: ${(props) => props.theme.colors.grey3};
40
+ `;
41
+ const OptionsDropdownList = styled(List) `
42
+ background-color: ${(props) => props.theme.colors.background};
43
+ box-shadow: ${(props) => props.theme.shadow.light};
44
+ `;
45
+ /**
46
+ * The OptionsMenu component adds a sectioned list menu to the Table component.
47
+ * It inherits the ability to reset column widths and filters from react-table's useTable hook
48
+ *
49
+ * @param props - the component props
50
+ */
51
+ const OptionsMenu = ({ allColumns, allowColumnHiding, numVisibleColumns, resetResizing, setAllFilters, style, }) => {
52
+ const [optionsElement, setOptionsElement] = useState(null);
53
+ const [popperElement, setPopperElement] = useState(null);
54
+ const [showOptions, setShowOptions] = useState(false);
55
+ const { styles, attributes, update } = usePopper(optionsElement, popperElement, {
56
+ placement: 'left-end',
57
+ });
58
+ const toggleOptions = () => {
59
+ setShowOptions(!showOptions);
60
+ };
61
+ const onOptionSelect = (option) => {
62
+ option.onClick();
63
+ };
64
+ const clickOutsideOptionsHandler = () => {
65
+ if (showOptions)
66
+ toggleOptions();
67
+ };
68
+ useOnClickOutside(popperElement, clickOutsideOptionsHandler);
69
+ useEffect(() => {
70
+ if (showOptions)
71
+ update();
72
+ }, [showOptions, update]);
73
+ const resetFunctions = useMemo(() => {
74
+ const functions = {
75
+ items: [
76
+ {
77
+ label: 'Reset Column Widths',
78
+ onClick: resetResizing,
79
+ value: 'resetResizing',
80
+ },
81
+ {
82
+ label: 'Reset Filters',
83
+ onClick: () => setAllFilters([]),
84
+ value: 'resetFilters',
85
+ },
86
+ ],
87
+ label: 'Reset',
88
+ };
89
+ if (allowColumnHiding) {
90
+ functions.items.push({
91
+ label: 'Show All Columns',
92
+ onClick: () => {
93
+ allColumns.forEach((column) => {
94
+ if (!column.isVisible)
95
+ column.toggleHidden();
96
+ });
97
+ },
98
+ value: 'showAllColumns',
99
+ });
100
+ }
101
+ return functions;
102
+ }, [resetResizing, setAllFilters, allColumns, allowColumnHiding]);
103
+ const columnToggles = useMemo(() => {
104
+ return {
105
+ items: allColumns
106
+ .filter((column) => typeof column.Header === 'string')
107
+ .map((column) => ({
108
+ label: `${column.isVisible ? 'Hide' : 'Show'} ${String(column.Header)}`,
109
+ onClick: () =>
110
+ /* Don't allow last visible column to be hidden */
111
+ !(column.isVisible && numVisibleColumns === 1) ? column.toggleHidden() : null,
112
+ value: `${column.isVisible ? 'hide' : 'show'}${String(column.Header)}`,
113
+ })),
114
+ label: 'Columns',
115
+ };
116
+ }, [allColumns, allowColumnHiding]);
117
+ return (_jsxs(HeaderOptions, { ref: setOptionsElement, children: [_jsx(HeaderOptionsIcon, { icon: faEllipsisV, onClick: toggleOptions }), ReactDOM.createPortal(_jsx(OptionsDropdownList, Object.assign({}, attributes.popper, { isOpen: showOptions, ref: setPopperElement, style: Object.assign(Object.assign(Object.assign({}, styles.popper), { maxHeight: 800, minWidth: 150, zIndex: 9999 }), style), children: _jsx(SectionedList, { items: allowColumnHiding ? [resetFunctions, columnToggles] : [resetFunctions], onSelect: onOptionSelect }) })), document.body)] }));
118
+ };
119
+ export default OptionsMenu;
120
+ //# sourceMappingURL=options-menu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options-menu.js","sourceRoot":"","sources":["../../src/table/options-menu.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAqB,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OA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CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,EAC7E,QAAQ,EAAE,cAAc,GAC1B,IACgB,EACtB,QAAQ,CAAC,IAAI,CAChB,IACW,CACnB,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,95 @@
1
+ import * as React from 'react';
2
+ import { Filters, SortingRule } from 'react-table';
3
+ import { ItemsRenderedPayload } from '../utils/use-infinite-loader';
4
+ import { Action, ActionCol, Actions } from './cells/action-cell';
5
+ import DatetimeCell from './cells/datetime-cell';
6
+ import EditInputCell from './cells/edit-input-cell';
7
+ import EditSelectCell from './cells/edit-select-cell';
8
+ import { TableColumn } from './types';
9
+ /** Predefined cells */
10
+ declare const cells: {
11
+ readonly DATETIME: typeof DatetimeCell;
12
+ readonly EDIT_INPUT: typeof EditInputCell;
13
+ readonly EDIT_SELECT: typeof EditSelectCell;
14
+ };
15
+ /**
16
+ * Handle exposed if attaching a `ref` to the Table
17
+ */
18
+ export interface TableHandle {
19
+ resetFilters(): void;
20
+ }
21
+ /**
22
+ * Extra properties available on the Table function itself
23
+ */
24
+ interface TableProperties {
25
+ ActionColumn?: (actions: Array<ActionCol>, accessor?: string, sticky?: string, disableSelectAll?: boolean) => TableColumn;
26
+ Actions?: typeof Actions;
27
+ cells?: typeof cells;
28
+ }
29
+ export interface Props<T extends {
30
+ [k: string]: any;
31
+ }> {
32
+ /** Optional flag to enable or disable column hiding functionality */
33
+ allowHiding?: boolean;
34
+ /** An optional argument to specify the background color of the table either in hex or rgba format */
35
+ backgroundColor?: string;
36
+ /** Standard react className property */
37
+ className?: string;
38
+ /** An array of column definitions, see react-table docs for all options */
39
+ columns: Array<TableColumn>;
40
+ /** An array of data objects, each object should contain the keys defined as accessors in the column defs */
41
+ data?: Array<T>;
42
+ /** An optional function to retrieve an item from a virtualized dataset, use in conjunction with onItemsRendered */
43
+ getItem?: (index: number) => T;
44
+ /** An optional initial sort for the table */
45
+ initialSort?: Array<SortingRule<string>>;
46
+ /** The total number of items in the table, required when using the infinite loader */
47
+ itemCount?: number;
48
+ /** The maximum number of rows to display, useful when table is not in a flexed container */
49
+ maxRows?: number;
50
+ /** An optional handler for listening to any action buttons */
51
+ onAction?: (actionId: string, input: any) => void | Promise<void>;
52
+ /**
53
+ * An optional onChange handler for listening to any changes from edit cells, the handler is called with the new
54
+ * value, the rowIdx and the column id passed in as accessor. The Table component will not try and update the data
55
+ * it has, it's up to the consuming component to apply the update and pass data in again.
56
+ */
57
+ onChange?: (value: any, rowIdx: number, colId: string) => void | Promise<void>;
58
+ /** An optional handler for listening to a click on a row, will pass the callback the row that was clicked */
59
+ onClickRow?: (row: T) => void | Promise<void>;
60
+ /**
61
+ * An optional onFilter handler, can be used to draw filtering logic up into the parent component, rather than being
62
+ * done in the table itself
63
+ */
64
+ onFilter?: (filters: Filters<any>) => Promise<void>;
65
+ /** An optional handler for triggering the infinite loader to fetch more data, use alongside getItem */
66
+ onItemsRendered?: (payload: ItemsRenderedPayload) => Promise<void>;
67
+ /**
68
+ * An optional onSort handler, can be used to draw sorting logic up into the parent component, rather than being
69
+ * done in the table itself
70
+ */
71
+ onSort?: (sort: Array<SortingRule<string>>) => void | Promise<void>;
72
+ /** Optional flag to control whether or not to show additional table options */
73
+ showTableOptions?: boolean;
74
+ /** Pass through of the style prop to the root component */
75
+ style?: React.CSSProperties;
76
+ /** Pass through of the style prop to the table options Dropdown */
77
+ tableOptionsStyle?: React.CSSProperties;
78
+ }
79
+ type TableType = React.ForwardRefExoticComponent<Props<{
80
+ [k: string]: any;
81
+ }> & React.RefAttributes<TableHandle>> & TableProperties;
82
+ /**
83
+ * The Table component builds on top of the thirdparty react-table library and aims to provide a simple outward facing
84
+ * api. A table can be completely defined by passing in an array of columns and an array of data. The columns
85
+ * definitions are the same as that of ReactTable and the data can be any JSON like data. For more info on column
86
+ * definitions check the react table docs and examples:
87
+ *
88
+ * https://react-table.tanstack.com/docs/quick-start
89
+ *
90
+ * @param props - the component props
91
+ */
92
+ declare const Table: TableType;
93
+ export { Action as TableAction };
94
+ export default Table;
95
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/table/table.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAEH,OAAO,EAEP,WAAW,EAMd,MAAM,aAAa,CAAC;AAYrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,MAAM,EAAc,SAAS,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,YAAY,MAAM,uBAAuB,CAAC;AACjD,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,cAAc,MAAM,0BAA0B,CAAC;AAItD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAuTtC,uBAAuB;AACvB,QAAA,MAAM,KAAK;;;;CAID,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,YAAY,IAAI,IAAI,CAAC;CACxB;AAED;;GAEG;AACH,UAAU,eAAe;IACrB,YAAY,CAAC,EAAE,CACX,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,EACzB,QAAQ,CAAC,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,OAAO,KACzB,WAAW,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACxB;AAED,MAAM,WAAW,KAAK,CAAC,CAAC,SAAS;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE;IACjD,qEAAqE;IACrE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,qGAAqG;IACrG,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2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