@carbon/ibm-products 2.0.0-rc.2 → 2.0.0-rc.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (380) hide show
  1. package/README.md +2 -2
  2. package/css/index-full-carbon.css +1368 -401
  3. package/css/index-full-carbon.css.map +1 -1
  4. package/css/index-full-carbon.min.css +6 -8
  5. package/css/index-full-carbon.min.css.map +1 -1
  6. package/css/index-without-carbon-released-only.css +1413 -385
  7. package/css/index-without-carbon-released-only.css.map +1 -1
  8. package/css/index-without-carbon-released-only.min.css +4 -8
  9. package/css/index-without-carbon-released-only.min.css.map +1 -1
  10. package/css/index-without-carbon.css +1292 -456
  11. package/css/index-without-carbon.css.map +1 -1
  12. package/css/index-without-carbon.min.css +6 -8
  13. package/css/index-without-carbon.min.css.map +1 -1
  14. package/css/index.css +1165 -334
  15. package/css/index.css.map +1 -1
  16. package/css/index.min.css +6 -8
  17. package/css/index.min.css.map +1 -1
  18. package/es/components/APIKeyModal/APIKeyModal.js +1 -1
  19. package/es/components/ActionBar/ActionBarOverflowItems.js +1 -0
  20. package/es/components/ActionSet/ActionSet.js +7 -3
  21. package/es/components/AddSelect/AddSelect.js +6 -6
  22. package/es/components/AddSelect/AddSelectBody.js +73 -32
  23. package/es/components/AddSelect/AddSelectBreadcrumbs.js +12 -4
  24. package/es/components/AddSelect/AddSelectColumn.js +8 -8
  25. package/es/components/AddSelect/AddSelectFilter.js +10 -7
  26. package/es/components/AddSelect/AddSelectList.js +64 -29
  27. package/es/components/AddSelect/AddSelectMetaPanel.js +7 -1
  28. package/es/components/AddSelect/AddSelectSidebar.js +5 -2
  29. package/es/components/AddSelect/AddSelectSort.js +2 -2
  30. package/es/components/AddSelect/add-select-utils.js +9 -2
  31. package/es/components/AddSelect/hooks/useItemSort.js +6 -0
  32. package/es/components/AddSelect/hooks/useParentSelect.js +6 -0
  33. package/es/components/AddSelect/hooks/usePath.js +23 -2
  34. package/es/components/AddSelect/index.js +1 -1
  35. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +4 -6
  36. package/es/components/ButtonMenu/ButtonMenu.js +4 -3
  37. package/es/components/Card/Card.js +16 -6
  38. package/es/components/Card/CardFooter.js +3 -1
  39. package/es/components/Card/CardHeader.js +20 -1
  40. package/es/components/ComboButton/ComboButton.js +1 -1
  41. package/es/components/CreateFullPage/CreateFullPage.js +13 -3
  42. package/es/components/CreateTearsheet/CreateTearsheet.js +17 -3
  43. package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +3 -1
  44. package/es/components/CreateTearsheetNarrow/CreateTearsheetNarrow.js +2 -2
  45. package/es/components/DataSpreadsheet/DataSpreadsheet.js +65 -15
  46. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
  47. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
  48. package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +6 -5
  49. package/es/components/DataSpreadsheet/utils/handleCellDeletion.js +42 -0
  50. package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
  51. package/es/components/Datagrid/Datagrid/Datagrid.js +16 -40
  52. package/es/components/Datagrid/Datagrid/DatagridContent.js +194 -0
  53. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +18 -8
  54. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  55. package/es/components/Datagrid/Datagrid/DatagridHead.js +1 -2
  56. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +1 -4
  57. package/es/components/Datagrid/Datagrid/DatagridRow.js +44 -7
  58. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +11 -5
  59. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +13 -4
  60. package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +1 -2
  61. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +14 -10
  62. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +32 -11
  63. package/es/components/Datagrid/Datagrid/DraggableElement.js +12 -4
  64. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +11 -54
  65. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +15 -14
  66. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +63 -31
  67. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +193 -0
  68. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +56 -0
  69. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +1 -1
  70. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +484 -0
  71. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +514 -0
  72. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +91 -0
  73. package/es/components/Datagrid/Datagrid/addons/Filtering/constants.js +28 -0
  74. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/index.js +9 -0
  75. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +25 -0
  76. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.js +38 -0
  77. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useSubscribeToEventEmitter.js +25 -0
  78. package/es/components/Datagrid/Datagrid/addons/Filtering/index.js +9 -0
  79. package/es/components/Datagrid/Datagrid/addons/Filtering/motion/variants.js +55 -0
  80. package/es/components/Datagrid/Datagrid/addons/Filtering/utils.js +72 -0
  81. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +60 -0
  82. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +1 -0
  83. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +541 -0
  84. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +1 -0
  85. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +112 -0
  86. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +27 -0
  87. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +1 -0
  88. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +39 -0
  89. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +19 -0
  90. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +262 -0
  91. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +87 -0
  92. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +17 -14
  93. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +13 -36
  94. package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/index.js +0 -1
  95. package/es/components/Datagrid/index.js +4 -1
  96. package/es/components/Datagrid/useActionsColumn.js +28 -12
  97. package/es/components/Datagrid/useColumnOrder.js +8 -0
  98. package/es/components/Datagrid/useCustomizeColumns.js +13 -8
  99. package/es/components/Datagrid/useDisableSelectRows.js +6 -2
  100. package/es/components/Datagrid/useExpandedRow.js +0 -1
  101. package/es/components/Datagrid/useFiltering.js +99 -0
  102. package/es/components/Datagrid/useInfiniteScroll.js +5 -2
  103. package/es/components/Datagrid/useInlineEdit.js +71 -0
  104. package/es/components/Datagrid/useNestedRowExpander.js +47 -0
  105. package/es/components/Datagrid/useNestedRows.js +16 -4
  106. package/es/components/Datagrid/useParentDimensions.js +3 -1
  107. package/es/components/Datagrid/useRowExpander.js +12 -4
  108. package/es/components/Datagrid/useRowSize.js +17 -6
  109. package/es/components/Datagrid/useSelectAllToggle.js +17 -4
  110. package/es/components/Datagrid/useSelectRows.js +13 -4
  111. package/es/components/Datagrid/useSortableColumns.js +15 -9
  112. package/es/components/Datagrid/useStickyColumn.js +11 -0
  113. package/es/components/Datagrid/utils/DatagridActions.js +249 -0
  114. package/es/components/Datagrid/utils/DatagridPagination.js +33 -0
  115. package/es/components/Datagrid/utils/Wrapper.js +21 -0
  116. package/es/components/Datagrid/utils/getArgTypes.js +94 -0
  117. package/es/components/Datagrid/utils/getInlineEditColumns.js +159 -0
  118. package/es/components/Datagrid/utils/makeData.js +54 -1
  119. package/es/components/EditUpdateCards/EditUpdateCards.js +144 -0
  120. package/es/components/EditUpdateCards/index.js +7 -0
  121. package/es/components/ExportModal/ExportModal.js +1 -1
  122. package/es/components/FilterSummary/FilterSummary.js +54 -0
  123. package/es/components/FilterSummary/index.js +7 -0
  124. package/es/components/ImportModal/ImportModal.js +3 -3
  125. package/es/components/InlineEdit/InlineEdit.js +28 -426
  126. package/es/components/InlineEditV1/InlineEditV1.js +447 -0
  127. package/es/components/InlineEditV1/index.js +7 -0
  128. package/es/components/InlineEditV2/InlineEditV2.js +289 -0
  129. package/es/components/InlineEditV2/index.js +7 -0
  130. package/es/components/ModifiedTabs/ModifiedTabLabelNew.js +1 -1
  131. package/es/components/ModifiedTabs/ModifiedTabLabelWithClose.js +1 -1
  132. package/es/components/MultiAddSelect/MultiAddSelect.js +14 -7
  133. package/es/components/MultiAddSelect/index.js +6 -0
  134. package/es/components/NotificationsPanel/NotificationsPanel.js +1 -1
  135. package/es/components/OptionsTile/OptionsTile.js +32 -16
  136. package/es/components/PageHeader/PageHeader.js +4 -4
  137. package/es/components/PageHeader/PageHeaderTitle.js +1 -1
  138. package/es/components/ProductiveCard/ProductiveCard.js +5 -0
  139. package/es/components/RemoveModal/RemoveModal.js +20 -3
  140. package/es/components/Saving/Saving.js +1 -1
  141. package/es/components/SidePanel/SidePanel.js +45 -52
  142. package/es/components/SidePanel/motion/variants.js +45 -0
  143. package/es/components/SingleAddSelect/SingleAddSelect.js +6 -0
  144. package/es/components/SingleAddSelect/index.js +6 -0
  145. package/es/components/StatusIcon/StatusIcon.js +1 -1
  146. package/es/components/Tearsheet/Tearsheet.js +5 -0
  147. package/es/components/Tearsheet/TearsheetNarrow.js +5 -0
  148. package/es/components/Tearsheet/TearsheetShell.js +1 -1
  149. package/es/components/UserProfileImage/UserProfileImage.js +1 -1
  150. package/es/components/WebTerminal/WebTerminal.js +1 -1
  151. package/es/components/WebTerminal/preview-components/Navigation.js +1 -1
  152. package/es/components/index.js +4 -3
  153. package/es/global/js/hooks/index.js +2 -1
  154. package/es/global/js/hooks/useClickOutside.js +1 -1
  155. package/es/global/js/hooks/useControllableState.js +83 -0
  156. package/es/global/js/hooks/useCreateComponentFocus.js +38 -10
  157. package/es/global/js/hooks/useResetCreateComponent.js +6 -2
  158. package/es/global/js/package-settings.js +9 -6
  159. package/es/global/js/utils/getBezierValues.js +20 -0
  160. package/es/global/js/utils/getNumberOfHiddenSteps.js +19 -0
  161. package/es/global/js/utils/motionConstants.js +45 -0
  162. package/es/global/js/utils/rangeWithCallback.js +13 -0
  163. package/es/global/js/utils/story-helper.js +5 -1
  164. package/es/global/js/utils/uuidv4.spec.js +4 -0
  165. package/lib/components/APIKeyModal/APIKeyModal.js +4 -4
  166. package/lib/components/ActionBar/ActionBarOverflowItems.js +1 -0
  167. package/lib/components/ActionSet/ActionSet.js +7 -3
  168. package/lib/components/AddSelect/AddSelect.js +5 -6
  169. package/lib/components/AddSelect/AddSelectBody.js +68 -31
  170. package/lib/components/AddSelect/AddSelectBreadcrumbs.js +15 -4
  171. package/lib/components/AddSelect/AddSelectColumn.js +7 -7
  172. package/lib/components/AddSelect/AddSelectFilter.js +9 -6
  173. package/lib/components/AddSelect/AddSelectList.js +65 -30
  174. package/lib/components/AddSelect/AddSelectMetaPanel.js +8 -2
  175. package/lib/components/AddSelect/AddSelectSidebar.js +4 -1
  176. package/lib/components/AddSelect/AddSelectSort.js +5 -5
  177. package/lib/components/AddSelect/add-select-utils.js +9 -2
  178. package/lib/components/AddSelect/hooks/useItemSort.js +6 -0
  179. package/lib/components/AddSelect/hooks/useParentSelect.js +6 -0
  180. package/lib/components/AddSelect/hooks/usePath.js +16 -1
  181. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +6 -6
  182. package/lib/components/ButtonMenu/ButtonMenu.js +4 -3
  183. package/lib/components/Card/Card.js +16 -6
  184. package/lib/components/Card/CardFooter.js +3 -1
  185. package/lib/components/Card/CardHeader.js +21 -1
  186. package/lib/components/ComboButton/ComboButton.js +3 -3
  187. package/lib/components/CreateFullPage/CreateFullPage.js +13 -3
  188. package/lib/components/CreateTearsheet/CreateTearsheet.js +18 -3
  189. package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +3 -1
  190. package/lib/components/CreateTearsheetNarrow/CreateTearsheetNarrow.js +2 -2
  191. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +65 -14
  192. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
  193. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
  194. package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +6 -5
  195. package/lib/components/DataSpreadsheet/utils/handleCellDeletion.js +53 -0
  196. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
  197. package/lib/components/Datagrid/Datagrid/Datagrid.js +19 -47
  198. package/lib/components/Datagrid/Datagrid/DatagridContent.js +230 -0
  199. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +19 -9
  200. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  201. package/lib/components/Datagrid/Datagrid/DatagridHead.js +1 -3
  202. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +2 -5
  203. package/lib/components/Datagrid/Datagrid/DatagridRow.js +46 -8
  204. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +14 -6
  205. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +16 -5
  206. package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +1 -2
  207. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +14 -10
  208. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +33 -10
  209. package/lib/components/Datagrid/Datagrid/DraggableElement.js +12 -4
  210. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +11 -49
  211. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +11 -8
  212. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +76 -46
  213. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/{CustomizeColumnsModal.js → CustomizeColumnsTearsheet.js} +85 -48
  214. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/{ModalWrapper.js → TearsheetWrapper.js} +32 -36
  215. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +3 -3
  216. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +505 -0
  217. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +538 -0
  218. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +112 -0
  219. package/lib/components/Datagrid/Datagrid/addons/Filtering/constants.js +47 -0
  220. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/index.js +31 -0
  221. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +37 -0
  222. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.js +50 -0
  223. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useSubscribeToEventEmitter.js +35 -0
  224. package/lib/components/Datagrid/Datagrid/addons/Filtering/index.js +37 -0
  225. package/lib/components/Datagrid/Datagrid/addons/Filtering/motion/variants.js +67 -0
  226. package/lib/components/Datagrid/Datagrid/addons/Filtering/utils.js +82 -0
  227. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +76 -0
  228. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +13 -0
  229. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +566 -0
  230. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +13 -0
  231. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +129 -0
  232. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +36 -0
  233. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +19 -0
  234. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +45 -0
  235. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +28 -0
  236. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +271 -0
  237. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +100 -0
  238. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +17 -13
  239. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +13 -35
  240. package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/index.js +0 -8
  241. package/lib/components/Datagrid/index.js +25 -1
  242. package/lib/components/Datagrid/useActionsColumn.js +28 -13
  243. package/lib/components/Datagrid/useColumnOrder.js +17 -0
  244. package/lib/components/Datagrid/useCustomizeColumns.js +12 -7
  245. package/lib/components/Datagrid/useDisableSelectRows.js +6 -2
  246. package/lib/components/Datagrid/useExpandedRow.js +0 -1
  247. package/lib/components/Datagrid/useFiltering.js +105 -0
  248. package/lib/components/Datagrid/useInfiniteScroll.js +5 -2
  249. package/lib/components/Datagrid/useInlineEdit.js +85 -0
  250. package/lib/components/Datagrid/useNestedRowExpander.js +63 -0
  251. package/lib/components/Datagrid/useNestedRows.js +17 -4
  252. package/lib/components/Datagrid/useParentDimensions.js +3 -1
  253. package/lib/components/Datagrid/useRowExpander.js +17 -5
  254. package/lib/components/Datagrid/useRowSize.js +18 -13
  255. package/lib/components/Datagrid/useSelectAllToggle.js +18 -4
  256. package/lib/components/Datagrid/useSelectRows.js +13 -4
  257. package/lib/components/Datagrid/useSortableColumns.js +16 -7
  258. package/lib/components/Datagrid/useStickyColumn.js +11 -0
  259. package/lib/components/Datagrid/utils/DatagridActions.js +275 -0
  260. package/lib/components/Datagrid/utils/DatagridPagination.js +46 -0
  261. package/lib/components/Datagrid/utils/Wrapper.js +33 -0
  262. package/lib/components/Datagrid/utils/getArgTypes.js +102 -0
  263. package/lib/components/Datagrid/utils/getInlineEditColumns.js +174 -0
  264. package/lib/components/Datagrid/utils/makeData.js +56 -2
  265. package/lib/components/EditUpdateCards/EditUpdateCards.js +152 -0
  266. package/lib/components/EditUpdateCards/index.js +13 -0
  267. package/lib/components/ExportModal/ExportModal.js +3 -3
  268. package/lib/components/FilterSummary/FilterSummary.js +72 -0
  269. package/lib/components/FilterSummary/index.js +15 -0
  270. package/lib/components/ImportModal/ImportModal.js +4 -4
  271. package/lib/components/InlineEdit/InlineEdit.js +27 -426
  272. package/lib/components/InlineEditV1/InlineEditV1.js +464 -0
  273. package/lib/components/InlineEditV1/index.js +13 -0
  274. package/lib/components/InlineEditV2/InlineEditV2.js +309 -0
  275. package/lib/components/InlineEditV2/index.js +13 -0
  276. package/lib/components/ModifiedTabs/ModifiedTabLabelNew.js +2 -2
  277. package/lib/components/ModifiedTabs/ModifiedTabLabelWithClose.js +3 -3
  278. package/lib/components/MultiAddSelect/MultiAddSelect.js +14 -7
  279. package/lib/components/NotificationsPanel/NotificationsPanel.js +8 -8
  280. package/lib/components/OptionsTile/OptionsTile.js +36 -19
  281. package/lib/components/PageHeader/PageHeader.js +5 -5
  282. package/lib/components/PageHeader/PageHeaderTitle.js +1 -1
  283. package/lib/components/ProductiveCard/ProductiveCard.js +5 -0
  284. package/lib/components/RemoveModal/RemoveModal.js +20 -3
  285. package/lib/components/Saving/Saving.js +5 -5
  286. package/lib/components/SidePanel/SidePanel.js +48 -53
  287. package/lib/components/SidePanel/motion/variants.js +55 -0
  288. package/lib/components/SingleAddSelect/SingleAddSelect.js +6 -0
  289. package/lib/components/StatusIcon/StatusIcon.js +45 -45
  290. package/lib/components/Tearsheet/Tearsheet.js +5 -0
  291. package/lib/components/Tearsheet/TearsheetNarrow.js +5 -0
  292. package/lib/components/Tearsheet/TearsheetShell.js +1 -1
  293. package/lib/components/UserProfileImage/UserProfileImage.js +7 -7
  294. package/lib/components/WebTerminal/WebTerminal.js +3 -3
  295. package/lib/components/WebTerminal/preview-components/Navigation.js +4 -4
  296. package/lib/components/index.js +33 -1
  297. package/lib/global/js/hooks/index.js +9 -1
  298. package/lib/global/js/hooks/useClickOutside.js +1 -1
  299. package/lib/global/js/hooks/useControllableState.js +94 -0
  300. package/lib/global/js/hooks/useCreateComponentFocus.js +42 -11
  301. package/lib/global/js/hooks/useResetCreateComponent.js +7 -2
  302. package/lib/global/js/package-settings.js +9 -6
  303. package/lib/global/js/utils/getBezierValues.js +29 -0
  304. package/lib/global/js/utils/getNumberOfHiddenSteps.js +28 -0
  305. package/lib/global/js/utils/motionConstants.js +55 -0
  306. package/lib/global/js/utils/rangeWithCallback.js +22 -0
  307. package/lib/global/js/utils/story-helper.js +5 -1
  308. package/lib/global/js/utils/uuidv4.spec.js +4 -0
  309. package/package.json +18 -16
  310. package/scss/components/ActionSet/_action-set.scss +9 -4
  311. package/scss/components/AddSelect/_add-select.scss +132 -34
  312. package/scss/components/AddSelect/_index.scss +1 -1
  313. package/scss/components/AddSelect/_storybook-styles.scss +1 -1
  314. package/scss/components/Card/_card.scss +1 -0
  315. package/scss/components/Cascade/_cascade.scss +1 -1
  316. package/scss/components/CreateTearsheet/_create-tearsheet.scss +2 -0
  317. package/scss/components/Datagrid/_datagrid.scss +7 -1
  318. package/scss/components/Datagrid/_storybook-styles.scss +29 -5
  319. package/scss/components/Datagrid/styles/_datagrid.scss +131 -37
  320. package/scss/components/Datagrid/styles/_draggableElement.scss +50 -18
  321. package/scss/components/Datagrid/styles/_index.scss +10 -8
  322. package/scss/components/Datagrid/styles/_useActionsColumn.scss +14 -0
  323. package/scss/components/Datagrid/styles/_useExpandedRow.scss +56 -10
  324. package/scss/components/Datagrid/styles/_useInlineEdit.scss +419 -0
  325. package/scss/components/Datagrid/styles/_useNestedRows.scss +33 -1
  326. package/scss/components/Datagrid/styles/_useSortableColumns.scss +35 -16
  327. package/scss/components/Datagrid/styles/_useStickyColumn.scss +31 -2
  328. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsTearsheet.scss +69 -0
  329. package/scss/components/Datagrid/styles/addons/_FilterFlyout.scss +87 -0
  330. package/scss/components/Datagrid/styles/addons/_FilterPanel.scss +129 -0
  331. package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +12 -4
  332. package/scss/components/EditUpdateCards/_carbon-imports.scss +9 -0
  333. package/scss/components/EditUpdateCards/_edit-update-cards.scss +85 -0
  334. package/scss/components/EditUpdateCards/_index-with-carbon.scss +9 -0
  335. package/scss/components/EditUpdateCards/_index.scss +8 -0
  336. package/scss/components/EditUpdateCards/_storybook-styles.scss +55 -0
  337. package/scss/components/FilterSummary/_filter-summary.scss +21 -0
  338. package/scss/components/FilterSummary/_index.scss +10 -0
  339. package/scss/components/FilterSummary/_storybook-styles.scss +14 -0
  340. package/scss/components/{InlineEdit → InlineEditV1}/_index-with-carbon.scss +1 -1
  341. package/scss/components/{InlineEdit → InlineEditV1}/_index.scss +1 -1
  342. package/scss/components/{InlineEdit/_inline-edit.scss → InlineEditV1/_inline-edit-v1.scss} +4 -2
  343. package/scss/components/InlineEditV2/_carbon-imports.scss +9 -0
  344. package/scss/components/InlineEditV2/_index-with-carbon.scss +9 -0
  345. package/scss/components/InlineEditV2/_index.scss +10 -0
  346. package/scss/components/InlineEditV2/_inline-edit-v2.scss +83 -0
  347. package/scss/components/InlineEditV2/_storybook-styles.scss +9 -0
  348. package/scss/components/MultiAddSelect/_multi-add-select.scss +8 -1
  349. package/scss/components/MultiAddSelect/_storybook-styles.scss +1 -1
  350. package/scss/components/NotificationsPanel/_notifications-panel.scss +3 -6
  351. package/scss/components/RemoveModal/_remove-modal.scss +0 -4
  352. package/scss/components/SidePanel/_side-panel.scss +3 -82
  353. package/scss/components/SidePanel/_storybook-styles.scss +6 -1
  354. package/scss/components/SingleAddSelect/_carbon-imports.scss +1 -1
  355. package/scss/components/SingleAddSelect/_index-with-carbon.scss +1 -1
  356. package/scss/components/SingleAddSelect/_index.scss +7 -0
  357. package/scss/components/SingleAddSelect/_single-add-select.scss +8 -1
  358. package/scss/components/SingleAddSelect/_storybook-styles.scss +1 -1
  359. package/scss/components/Tearsheet/_tearsheet.scss +4 -2
  360. package/scss/components/_index-released-only-with-carbon.scss +3 -1
  361. package/scss/components/_index-released-only.scss +4 -1
  362. package/scss/components/_index-with-carbon.scss +3 -1
  363. package/scss/components/_index.scss +4 -1
  364. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +0 -157
  365. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +0 -62
  366. package/es/components/Datagrid/Datagrid.stories-helpers/LeftPanelStory.js +0 -6
  367. package/lib/components/Datagrid/Datagrid.stories-helpers/LeftPanelStory.js +0 -13
  368. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsModal.scss +0 -52
  369. /package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/CustomizeColumnStory.js +0 -0
  370. /package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/RowSizeDropdownStory.js +0 -0
  371. /package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/SelectAllWithToggleStory.js +0 -0
  372. /package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/StickyActionsColumnStory.js +0 -0
  373. /package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/common.js +0 -0
  374. /package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/CustomizeColumnStory.js +0 -0
  375. /package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/RowSizeDropdownStory.js +0 -0
  376. /package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/SelectAllWithToggleStory.js +0 -0
  377. /package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/StickyActionsColumnStory.js +0 -0
  378. /package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/common.js +0 -0
  379. /package/scss/components/{InlineEdit → InlineEditV1}/_carbon-imports.scss +0 -0
  380. /package/scss/components/{InlineEdit → InlineEditV1}/_storybook-styles.scss +0 -0
@@ -0,0 +1,538 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.default = void 0;
11
+
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+
16
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
17
+
18
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
19
+
20
+ var _react = _interopRequireWildcard(require("react"));
21
+
22
+ var _propTypes = _interopRequireDefault(require("prop-types"));
23
+
24
+ var _react2 = require("@carbon/react");
25
+
26
+ var _layout = require("@carbon/layout");
27
+
28
+ var _settings = require("../../../../../settings");
29
+
30
+ var _constants = require("./constants");
31
+
32
+ var _classnames = _interopRequireDefault(require("classnames"));
33
+
34
+ var _framerMotion = require("framer-motion");
35
+
36
+ var _variants = require("./motion/variants");
37
+
38
+ var _icons = require("@carbon/react/icons");
39
+
40
+ var _ActionSet = require("../../../../ActionSet");
41
+
42
+ var _2 = require(".");
43
+
44
+ var _hooks = require("./hooks");
45
+
46
+ var _utils = require("./utils");
47
+
48
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
49
+
50
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
51
+
52
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
53
+
54
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
55
+
56
+ var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
57
+ var componentClass = "".concat(blockClass, "-filter-panel");
58
+ var MotionActionSet = (0, _framerMotion.motion)(_ActionSet.ActionSet);
59
+
60
+ var FilterPanel = function FilterPanel(_ref) {
61
+ var _cx;
62
+
63
+ var _ref$title = _ref.title,
64
+ title = _ref$title === void 0 ? 'Filter' : _ref$title,
65
+ _ref$closeIconDescrip = _ref.closeIconDescription,
66
+ closeIconDescription = _ref$closeIconDescrip === void 0 ? 'Close filter panel' : _ref$closeIconDescrip,
67
+ _ref$updateMethod = _ref.updateMethod,
68
+ updateMethod = _ref$updateMethod === void 0 ? _constants.BATCH : _ref$updateMethod,
69
+ filterSections = _ref.filterSections,
70
+ setAllFilters = _ref.setAllFilters,
71
+ _ref$onApply = _ref.onApply,
72
+ onApply = _ref$onApply === void 0 ? function () {} : _ref$onApply,
73
+ _ref$onCancel = _ref.onCancel,
74
+ onCancel = _ref$onCancel === void 0 ? function () {} : _ref$onCancel,
75
+ _ref$onPanelOpen = _ref.onPanelOpen,
76
+ onPanelOpen = _ref$onPanelOpen === void 0 ? function () {} : _ref$onPanelOpen,
77
+ _ref$onPanelClose = _ref.onPanelClose,
78
+ onPanelClose = _ref$onPanelClose === void 0 ? function () {} : _ref$onPanelClose,
79
+ _ref$showFilterSearch = _ref.showFilterSearch,
80
+ showFilterSearch = _ref$showFilterSearch === void 0 ? false : _ref$showFilterSearch,
81
+ _ref$filterPanelMinHe = _ref.filterPanelMinHeight,
82
+ filterPanelMinHeight = _ref$filterPanelMinHe === void 0 ? 600 : _ref$filterPanelMinHe,
83
+ _ref$primaryActionLab = _ref.primaryActionLabel,
84
+ primaryActionLabel = _ref$primaryActionLab === void 0 ? 'Apply' : _ref$primaryActionLab,
85
+ _ref$secondaryActionL = _ref.secondaryActionLabel,
86
+ secondaryActionLabel = _ref$secondaryActionL === void 0 ? 'Cancel' : _ref$secondaryActionL,
87
+ _ref$searchLabelText = _ref.searchLabelText,
88
+ searchLabelText = _ref$searchLabelText === void 0 ? 'Filter search' : _ref$searchLabelText,
89
+ _ref$searchPlaceholde = _ref.searchPlaceholder,
90
+ searchPlaceholder = _ref$searchPlaceholde === void 0 ? 'Find filters' : _ref$searchPlaceholde;
91
+
92
+ /** State */
93
+ var _useInitialStateFromF = (0, _hooks.useInitialStateFromFilters)(filterSections, _constants.PANEL),
94
+ _useInitialStateFromF2 = (0, _slicedToArray2.default)(_useInitialStateFromF, 2),
95
+ filtersState = _useInitialStateFromF2[0],
96
+ setFiltersState = _useInitialStateFromF2[1];
97
+
98
+ var _useState = (0, _react.useState)([]),
99
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
100
+ filtersObjectArray = _useState2[0],
101
+ setFiltersObjectArray = _useState2[1];
102
+
103
+ var _useState3 = (0, _react.useState)(false),
104
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
105
+ showDividerLine = _useState4[0],
106
+ setShowDividerLine = _useState4[1];
107
+ /** Refs */
108
+
109
+
110
+ var filterPanelRef = (0, _react.useRef)();
111
+ var filterHeadingRef = (0, _react.useRef)();
112
+ var filterSearchRef = (0, _react.useRef)();
113
+ var actionSetRef = (0, _react.useRef)(); // When using batch actions we have to store the filters to then apply them later
114
+
115
+ var prevFiltersRef = (0, _react.useRef)(JSON.stringify(filtersState));
116
+ var prevFiltersObjectArrayRef = (0, _react.useRef)(JSON.stringify(filtersObjectArray));
117
+ /** State from hooks */
118
+
119
+ var _useShouldDisableButt = (0, _hooks.useShouldDisableButtons)({
120
+ initialValue: true,
121
+ filtersState: filtersState,
122
+ prevFiltersRef: prevFiltersRef
123
+ }),
124
+ _useShouldDisableButt2 = (0, _slicedToArray2.default)(_useShouldDisableButt, 2),
125
+ shouldDisableButtons = _useShouldDisableButt2[0],
126
+ setShouldDisableButtons = _useShouldDisableButt2[1];
127
+ /** Memos */
128
+
129
+
130
+ var showActionSet = (0, _react.useMemo)(function () {
131
+ return updateMethod === _constants.BATCH;
132
+ }, [updateMethod]);
133
+ /** Context */
134
+
135
+ var _useContext = (0, _react.useContext)(_2.FilterContext),
136
+ leftPanelOpen = _useContext.leftPanelOpen,
137
+ setLeftPanelOpen = _useContext.setLeftPanelOpen;
138
+ /** Methods */
139
+
140
+
141
+ var closePanel = function closePanel() {
142
+ return setLeftPanelOpen(false);
143
+ }; // If the user decides to cancel or click outside the flyout, it reverts back to the filters that were
144
+ // there when they opened the flyout
145
+
146
+
147
+ var revertToPreviousFilters = function revertToPreviousFilters() {
148
+ setFiltersState(JSON.parse(prevFiltersRef.current));
149
+ setFiltersObjectArray(JSON.parse(prevFiltersObjectArrayRef.current));
150
+ };
151
+
152
+ var cancel = function cancel() {
153
+ // Reverting to previous filters only applies when using batch actions
154
+ if (updateMethod === _constants.BATCH) {
155
+ revertToPreviousFilters();
156
+ onCancel();
157
+ }
158
+ };
159
+
160
+ var reset = function reset() {
161
+ // Get the initial values for the filters
162
+ var initialFiltersState = (0, _utils.getInitialStateFromFilters)(filterSections, _constants.PANEL);
163
+ var initialFiltersObjectArray = []; // Set the state to the initial values
164
+
165
+ setFiltersState(initialFiltersState);
166
+ setFiltersObjectArray(initialFiltersObjectArray);
167
+ setAllFilters([]); // Update their respective refs so everything is in sync
168
+
169
+ prevFiltersRef.current = JSON.stringify(initialFiltersState);
170
+ prevFiltersObjectArrayRef.current = JSON.stringify(initialFiltersObjectArray);
171
+ };
172
+
173
+ var apply = function apply() {
174
+ setAllFilters(filtersObjectArray); // From the user
175
+
176
+ onApply(); // When the user clicks apply, the action set buttons should be disabled again
177
+
178
+ setShouldDisableButtons(true); // updates the ref so next time the flyout opens we have records of the previous filters
179
+
180
+ prevFiltersRef.current = JSON.stringify(filtersState);
181
+ prevFiltersObjectArrayRef.current = JSON.stringify(filtersObjectArray);
182
+ };
183
+
184
+ var applyFilters = function applyFilters(_ref2) {
185
+ var column = _ref2.column,
186
+ value = _ref2.value,
187
+ type = _ref2.type;
188
+
189
+ // If no end date is selected return because we need the end date to do computations
190
+ if (type === _constants.DATE && value.length > 0 && !value[1]) {
191
+ return;
192
+ }
193
+
194
+ var filtersObjectArrayCopy = (0, _toConsumableArray2.default)(filtersObjectArray); // // check if the filter already exists in the array
195
+
196
+ var filter = filtersObjectArrayCopy.find(function (item) {
197
+ return item.id === column;
198
+ }); // // if filter exists in array then update the filter's new value
199
+
200
+ if (filter) {
201
+ filter.value = value;
202
+ } else {
203
+ filtersObjectArrayCopy.push({
204
+ id: column,
205
+ value: value,
206
+ type: type
207
+ });
208
+ } // ATTENTION: this is where you would reset or remove individual filters from the filters array
209
+
210
+
211
+ if (type === _constants.CHECKBOX) {
212
+ /**
213
+ When all checkboxes of a group are all unselected the value still exists in the filtersObjectArray
214
+ This checks if all the checkboxes are selected = false and removes it from the array
215
+ */
216
+ var index = filtersObjectArrayCopy.findIndex(function (filter) {
217
+ return filter.id === column;
218
+ }); // If all the selected state is false remove from array
219
+
220
+ var shouldRemoveFromArray = filtersObjectArrayCopy[index].value.every(function (val) {
221
+ return val.selected === false;
222
+ });
223
+
224
+ if (shouldRemoveFromArray) {
225
+ filtersObjectArrayCopy.splice(index, 1);
226
+ }
227
+ } else if (type === _constants.DATE) {
228
+ if (value.length === 0) {
229
+ /**
230
+ Checks to see if the date value is an empty array, if it is that means the user wants
231
+ to reset the date filter
232
+ */
233
+ var _index = filtersObjectArrayCopy.findIndex(function (filter) {
234
+ return filter.id === column;
235
+ }); // Remove it from the filters array since there is nothing to filter
236
+
237
+
238
+ filtersObjectArrayCopy.splice(_index, 1);
239
+ }
240
+ } else if (type === _constants.DROPDOWN || type === _constants.RADIO) {
241
+ if (value === 'Any') {
242
+ /**
243
+ Checks to see if the selected value is 'Any', that means the user wants
244
+ to reset specific filter
245
+ */
246
+ var _index2 = filtersObjectArrayCopy.findIndex(function (filter) {
247
+ return filter.id === column;
248
+ }); // Remove it from the filters array
249
+
250
+
251
+ filtersObjectArrayCopy.splice(_index2, 1);
252
+ }
253
+ }
254
+
255
+ setFiltersObjectArray(filtersObjectArrayCopy); // // Automatically apply the filters if the updateMethod is instant
256
+
257
+ if (updateMethod === _constants.INSTANT) {
258
+ setAllFilters(filtersObjectArrayCopy);
259
+ }
260
+ };
261
+ /** Render the individual filter component */
262
+
263
+
264
+ var renderFilter = function renderFilter(_ref3) {
265
+ var _filtersState$column, _filtersState$column2, _filtersState$column3, _filtersState$column4;
266
+
267
+ var type = _ref3.type,
268
+ column = _ref3.column,
269
+ components = _ref3.props;
270
+
271
+ switch (type) {
272
+ case _constants.DATE:
273
+ return /*#__PURE__*/_react.default.createElement(_react2.Layer, null, /*#__PURE__*/_react.default.createElement(_react2.DatePicker, (0, _extends2.default)({}, components.DatePicker, {
274
+ onChange: function onChange(value) {
275
+ var _components$DatePicke, _components$DatePicke2;
276
+
277
+ setFiltersState(_objectSpread(_objectSpread({}, filtersState), {}, (0, _defineProperty2.default)({}, column, {
278
+ value: value,
279
+ type: type
280
+ })));
281
+ applyFilters({
282
+ column: column,
283
+ value: value,
284
+ type: type
285
+ });
286
+ (_components$DatePicke = (_components$DatePicke2 = components.DatePicker).onChange) === null || _components$DatePicke === void 0 ? void 0 : _components$DatePicke.call(_components$DatePicke2, value);
287
+ },
288
+ value: filtersState[column].value,
289
+ datePickerType: "range"
290
+ }), /*#__PURE__*/_react.default.createElement(_react2.DatePickerInput, (0, _extends2.default)({
291
+ placeholder: "mm/dd/yyyy",
292
+ labelText: "Start date"
293
+ }, components.DatePickerInput.start)), /*#__PURE__*/_react.default.createElement(_react2.DatePickerInput, (0, _extends2.default)({
294
+ placeholder: "mm/dd/yyyy",
295
+ labelText: "End date"
296
+ }, components.DatePickerInput.end))));
297
+
298
+ case _constants.NUMBER:
299
+ return /*#__PURE__*/_react.default.createElement(_react2.Layer, null, /*#__PURE__*/_react.default.createElement(_react2.NumberInput, (0, _extends2.default)({
300
+ step: 1,
301
+ allowEmpty: true,
302
+ hideSteppers: true
303
+ }, components.NumberInput, {
304
+ onChange: function onChange(event) {
305
+ var _components$NumberInp, _components$NumberInp2;
306
+
307
+ setFiltersState(_objectSpread(_objectSpread({}, filtersState), {}, (0, _defineProperty2.default)({}, column, {
308
+ value: event.target.value,
309
+ type: type
310
+ })));
311
+ applyFilters({
312
+ column: column,
313
+ value: event.target.value,
314
+ type: type
315
+ });
316
+ (_components$NumberInp = (_components$NumberInp2 = components.NumberInput).onChange) === null || _components$NumberInp === void 0 ? void 0 : _components$NumberInp.call(_components$NumberInp2, event);
317
+ },
318
+ value: filtersState[column].value
319
+ })));
320
+
321
+ case _constants.CHECKBOX:
322
+ return /*#__PURE__*/_react.default.createElement(_react2.FormGroup, components.FormGroup, filtersState[column].value.map(function (option) {
323
+ return /*#__PURE__*/_react.default.createElement(_react2.Checkbox, (0, _extends2.default)({
324
+ key: option.labelText
325
+ }, option, {
326
+ onChange: function onChange(_, _ref4) {
327
+ var _option$onChange;
328
+
329
+ var isSelected = _ref4.checked;
330
+ var checkboxCopy = filtersState[column].value;
331
+ var foundCheckbox = checkboxCopy.find(function (checkbox) {
332
+ return checkbox.value === option.value;
333
+ });
334
+ foundCheckbox.selected = isSelected;
335
+ setFiltersState(_objectSpread(_objectSpread({}, filtersState), {}, (0, _defineProperty2.default)({}, column, {
336
+ value: checkboxCopy,
337
+ type: type
338
+ })));
339
+ applyFilters({
340
+ column: column,
341
+ value: (0, _toConsumableArray2.default)(filtersState[column].value),
342
+ type: type
343
+ });
344
+ (_option$onChange = option.onChange) === null || _option$onChange === void 0 ? void 0 : _option$onChange.call(option, isSelected);
345
+ },
346
+ checked: option.selected
347
+ }));
348
+ }));
349
+
350
+ case _constants.RADIO:
351
+ return /*#__PURE__*/_react.default.createElement(_react2.FormGroup, components.FormGroup, /*#__PURE__*/_react.default.createElement(_react2.RadioButtonGroup, (0, _extends2.default)({}, components.RadioButtonGroup, {
352
+ valueSelected: ((_filtersState$column = filtersState[column]) === null || _filtersState$column === void 0 ? void 0 : _filtersState$column.value) === '' ? 'Any' : (_filtersState$column2 = filtersState[column]) === null || _filtersState$column2 === void 0 ? void 0 : _filtersState$column2.value,
353
+ onChange: function onChange(selected) {
354
+ var _components$RadioButt, _components$RadioButt2;
355
+
356
+ setFiltersState(_objectSpread(_objectSpread({}, filtersState), {}, (0, _defineProperty2.default)({}, column, {
357
+ value: selected,
358
+ type: type
359
+ })));
360
+ applyFilters({
361
+ column: column,
362
+ value: selected,
363
+ type: type
364
+ });
365
+ (_components$RadioButt = (_components$RadioButt2 = components.RadioButtonGroup).onChange) === null || _components$RadioButt === void 0 ? void 0 : _components$RadioButt.call(_components$RadioButt2, selected);
366
+ }
367
+ }), /*#__PURE__*/_react.default.createElement(_react2.RadioButton, {
368
+ id: "any",
369
+ labelText: "Any",
370
+ value: "Any"
371
+ }), components.RadioButton.map(function (radio) {
372
+ var _ref5, _radio$id;
373
+
374
+ return /*#__PURE__*/_react.default.createElement(_react2.RadioButton, (0, _extends2.default)({
375
+ key: (_ref5 = (_radio$id = radio.id) !== null && _radio$id !== void 0 ? _radio$id : radio.labelText) !== null && _ref5 !== void 0 ? _ref5 : radio.value
376
+ }, radio));
377
+ })));
378
+
379
+ case _constants.DROPDOWN:
380
+ return /*#__PURE__*/_react.default.createElement(_react2.Layer, null, /*#__PURE__*/_react.default.createElement(_react2.Dropdown, (0, _extends2.default)({}, components.Dropdown, {
381
+ selectedItem: ((_filtersState$column3 = filtersState[column]) === null || _filtersState$column3 === void 0 ? void 0 : _filtersState$column3.value) === '' ? 'Any' : (_filtersState$column4 = filtersState[column]) === null || _filtersState$column4 === void 0 ? void 0 : _filtersState$column4.value,
382
+ items: ['Any'].concat((0, _toConsumableArray2.default)(components.Dropdown.items)),
383
+ onChange: function onChange(_ref6) {
384
+ var _components$Dropdown$, _components$Dropdown;
385
+
386
+ var selectedItem = _ref6.selectedItem;
387
+ setFiltersState(_objectSpread(_objectSpread({}, filtersState), {}, (0, _defineProperty2.default)({}, column, {
388
+ value: selectedItem,
389
+ type: type
390
+ })));
391
+ applyFilters({
392
+ column: column,
393
+ value: selectedItem,
394
+ type: type
395
+ });
396
+ (_components$Dropdown$ = (_components$Dropdown = components.Dropdown).onChange) === null || _components$Dropdown$ === void 0 ? void 0 : _components$Dropdown$.call(_components$Dropdown, selectedItem);
397
+ }
398
+ })));
399
+ }
400
+ };
401
+
402
+ var renderActionSet = function renderActionSet() {
403
+ return showActionSet && /*#__PURE__*/_react.default.createElement(MotionActionSet, {
404
+ actions: [{
405
+ key: 1,
406
+ kind: 'primary',
407
+ label: primaryActionLabel,
408
+ onClick: apply,
409
+ disabled: shouldDisableButtons
410
+ }, {
411
+ key: 2,
412
+ kind: 'secondary',
413
+ label: secondaryActionLabel,
414
+ onClick: cancel,
415
+ disabled: shouldDisableButtons
416
+ }],
417
+ className: "".concat(componentClass, "__action-set"),
418
+ ref: actionSetRef,
419
+ variants: _variants.actionSetVariants
420
+ });
421
+ };
422
+
423
+ var onInnerContainerScroll = function onInnerContainerScroll(event) {
424
+ if (event.target.scrollTop > 0) {
425
+ setShowDividerLine(true);
426
+ } else {
427
+ setShowDividerLine(false);
428
+ }
429
+ };
430
+ /** Effects */
431
+
432
+
433
+ (0, _react.useEffect)(function liftOpenStateToParent() {
434
+ if (leftPanelOpen) {
435
+ onPanelOpen(leftPanelOpen);
436
+ } else {
437
+ onPanelClose(leftPanelOpen);
438
+ }
439
+ }, [leftPanelOpen, onPanelClose, onPanelOpen]);
440
+ (0, _react.useEffect)(function setPanelMinimumHeight() {
441
+ var _filterPanelRef$curre;
442
+
443
+ (_filterPanelRef$curre = filterPanelRef.current) === null || _filterPanelRef$curre === void 0 ? void 0 : _filterPanelRef$curre.style.setProperty('--filter-panel-min-height', (0, _layout.rem)(filterPanelMinHeight));
444
+ }, [filterPanelMinHeight]);
445
+ (0, _hooks.useSubscribeToEventEmitter)(_constants.CLEAR_FILTERS, reset);
446
+
447
+ var getScrollableContainerHeight = function getScrollableContainerHeight() {
448
+ var _filterHeadingRef$cur, _filterSearchRef$curr, _actionSetRef$current;
449
+
450
+ var filterHeadingHeight = (_filterHeadingRef$cur = filterHeadingRef.current) === null || _filterHeadingRef$cur === void 0 ? void 0 : _filterHeadingRef$cur.getBoundingClientRect().height;
451
+ var filterSearchHeight = (_filterSearchRef$curr = filterSearchRef.current) === null || _filterSearchRef$curr === void 0 ? void 0 : _filterSearchRef$curr.getBoundingClientRect().height;
452
+ var actionSetHeight = (_actionSetRef$current = actionSetRef.current) === null || _actionSetRef$current === void 0 ? void 0 : _actionSetRef$current.getBoundingClientRect().height;
453
+ var height = "calc(100vh - ".concat(filterHeadingHeight, "px - ").concat(showFilterSearch ? filterSearchHeight : 0, "px - ").concat(updateMethod === _constants.BATCH ? actionSetHeight : 0, "px)");
454
+ return height;
455
+ };
456
+
457
+ return /*#__PURE__*/_react.default.createElement(_framerMotion.motion.div, {
458
+ ref: filterPanelRef,
459
+ className: (0, _classnames.default)(componentClass, "".concat(componentClass, "__container"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(componentClass, "--open"), leftPanelOpen), (0, _defineProperty2.default)(_cx, "".concat(componentClass, "--batch"), showActionSet), (0, _defineProperty2.default)(_cx, "".concat(componentClass, "--instant"), !showActionSet), _cx)),
460
+ initial: false,
461
+ animate: leftPanelOpen ? 'visible' : 'hidden',
462
+ variants: _variants.panelVariants
463
+ }, /*#__PURE__*/_react.default.createElement(_framerMotion.motion.div, {
464
+ variants: _variants.innerContainerVariants
465
+ }, /*#__PURE__*/_react.default.createElement("header", {
466
+ ref: filterHeadingRef,
467
+ className: (0, _classnames.default)("".concat(componentClass, "__heading"), (0, _defineProperty2.default)({}, "".concat(componentClass, "__heading--with-divider"), showDividerLine))
468
+ }, /*#__PURE__*/_react.default.createElement("div", {
469
+ className: "".concat(componentClass, "__title")
470
+ }, title), /*#__PURE__*/_react.default.createElement(_react2.Button, {
471
+ hasIconOnly: true,
472
+ renderIcon: function renderIcon(props) {
473
+ return /*#__PURE__*/_react.default.createElement(_icons.Close, (0, _extends2.default)({
474
+ size: 16
475
+ }, props));
476
+ },
477
+ iconDescription: closeIconDescription,
478
+ kind: "ghost",
479
+ tooltipPosition: "bottom",
480
+ tooltipAlignment: "end",
481
+ onClick: closePanel
482
+ }), showFilterSearch && /*#__PURE__*/_react.default.createElement("div", {
483
+ ref: filterSearchRef,
484
+ className: "".concat(componentClass, "__search")
485
+ }, /*#__PURE__*/_react.default.createElement(_react2.Layer, null, /*#__PURE__*/_react.default.createElement(_react2.Search, {
486
+ labelText: searchLabelText,
487
+ placeholder: searchPlaceholder,
488
+ size: "sm"
489
+ })))), /*#__PURE__*/_react.default.createElement("div", {
490
+ className: "".concat(componentClass, "__inner-container"),
491
+ style: {
492
+ height: getScrollableContainerHeight()
493
+ },
494
+ onScroll: onInnerContainerScroll
495
+ }, filterSections.map(function (_ref7) {
496
+ var _ref7$categoryTitle = _ref7.categoryTitle,
497
+ categoryTitle = _ref7$categoryTitle === void 0 ? null : _ref7$categoryTitle,
498
+ _ref7$filters = _ref7.filters,
499
+ filters = _ref7$filters === void 0 ? [] : _ref7$filters,
500
+ hasAccordion = _ref7.hasAccordion;
501
+ return /*#__PURE__*/_react.default.createElement("div", {
502
+ className: "".concat(componentClass, "__category")
503
+ }, categoryTitle && /*#__PURE__*/_react.default.createElement("div", {
504
+ className: "".concat(componentClass, "__category-title")
505
+ }, categoryTitle), hasAccordion ? /*#__PURE__*/_react.default.createElement(_react2.Accordion, null, filters.map(function (_ref8) {
506
+ var filterLabel = _ref8.filterLabel,
507
+ filter = _ref8.filter;
508
+ return /*#__PURE__*/_react.default.createElement(_react2.AccordionItem, {
509
+ title: filterLabel,
510
+ key: filterLabel
511
+ }, renderFilter(filter));
512
+ })) : filters.map(function (_ref9) {
513
+ var filter = _ref9.filter;
514
+ return renderFilter(filter);
515
+ }));
516
+ })), renderActionSet()));
517
+ };
518
+
519
+ FilterPanel.propTypes = {
520
+ closeIconDescription: _propTypes.default.string,
521
+ filterPanelMinHeight: _propTypes.default.number,
522
+ filterSections: _propTypes.default.array,
523
+ onApply: _propTypes.default.func,
524
+ onCancel: _propTypes.default.func,
525
+ onPanelClose: _propTypes.default.func,
526
+ onPanelOpen: _propTypes.default.func,
527
+ open: _propTypes.default.bool,
528
+ primaryActionLabel: _propTypes.default.string,
529
+ searchLabelText: _propTypes.default.string,
530
+ searchPlaceholder: _propTypes.default.string,
531
+ secondaryActionLabel: _propTypes.default.string,
532
+ setAllFilters: _propTypes.default.func.isRequired,
533
+ showFilterSearch: _propTypes.default.bool,
534
+ title: _propTypes.default.string,
535
+ updateMethod: _propTypes.default.oneOf([_constants.BATCH, _constants.INSTANT])
536
+ };
537
+ var _default = FilterPanel;
538
+ exports.default = _default;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.FilterProvider = exports.FilterContext = void 0;
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
14
+ var _react = _interopRequireWildcard(require("react"));
15
+
16
+ var _propTypes = _interopRequireDefault(require("prop-types"));
17
+
18
+ var _constants = require("./constants");
19
+
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
24
+ /**
25
+ * Copyright IBM Corp. 2022, 2022
26
+ *
27
+ * This source code is licensed under the Apache-2.0 license found in the
28
+ * LICENSE file in the root directory of this source tree.
29
+ */
30
+ var FilterContext = /*#__PURE__*/(0, _react.createContext)();
31
+ exports.FilterContext = FilterContext;
32
+ var EventEmitter = {
33
+ events: {},
34
+ dispatch: function dispatch(event, data) {
35
+ if (!this.events[event]) {
36
+ return;
37
+ }
38
+
39
+ this.events[event].forEach(function (callback) {
40
+ return callback(data);
41
+ });
42
+ },
43
+ subscribe: function subscribe(event, callback) {
44
+ if (!this.events[event]) {
45
+ this.events[event] = [];
46
+ } else {
47
+ this.events[event].push(callback);
48
+ }
49
+ }
50
+ };
51
+
52
+ var prepareFiltersForTags = function prepareFiltersForTags(filters) {
53
+ var tags = [];
54
+ filters.forEach(function (_ref) {
55
+ var id = _ref.id,
56
+ type = _ref.type,
57
+ value = _ref.value;
58
+
59
+ if (type === _constants.DROPDOWN || type === _constants.RADIO || type === _constants.NUMBER) {
60
+ tags.push({
61
+ key: id,
62
+ value: value
63
+ });
64
+ } else if (type === _constants.DATE) {
65
+ var _value = (0, _slicedToArray2.default)(value, 2),
66
+ startDate = _value[0],
67
+ endDate = _value[1];
68
+
69
+ tags.push({
70
+ key: id,
71
+ value: "".concat(startDate.toLocaleDateString(), " - ").concat(endDate.toLocaleDateString())
72
+ });
73
+ } else if (type === _constants.CHECKBOX) {
74
+ value.forEach(function (checkbox) {
75
+ if (checkbox.selected) {
76
+ tags.push({
77
+ key: id,
78
+ value: checkbox.value
79
+ });
80
+ }
81
+ });
82
+ }
83
+ });
84
+ return tags;
85
+ };
86
+
87
+ var FilterProvider = function FilterProvider(_ref2) {
88
+ var children = _ref2.children,
89
+ filters = _ref2.filters;
90
+ var filterTags = prepareFiltersForTags(filters);
91
+
92
+ var _useState = (0, _react.useState)(false),
93
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
94
+ leftPanelOpen = _useState2[0],
95
+ setLeftPanelOpen = _useState2[1];
96
+
97
+ var value = {
98
+ filterTags: filterTags,
99
+ EventEmitter: EventEmitter,
100
+ leftPanelOpen: leftPanelOpen,
101
+ setLeftPanelOpen: setLeftPanelOpen
102
+ };
103
+ return /*#__PURE__*/_react.default.createElement(FilterContext.Provider, {
104
+ value: value
105
+ }, children);
106
+ };
107
+
108
+ exports.FilterProvider = FilterProvider;
109
+ FilterProvider.propTypes = {
110
+ children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.node), _propTypes.default.node]).isRequired,
111
+ filters: _propTypes.default.arrayOf(_propTypes.default.object).isRequired
112
+ };