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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (383) hide show
  1. package/README.md +19 -2
  2. package/css/index-full-carbon.css +1376 -403
  3. package/css/index-full-carbon.css.map +1 -1
  4. package/css/index-full-carbon.min.css +8 -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 +1295 -453
  11. package/css/index-without-carbon.css.map +1 -1
  12. package/css/index-without-carbon.min.css +8 -8
  13. package/css/index-without-carbon.min.css.map +1 -1
  14. package/css/index.css +1170 -333
  15. package/css/index.css.map +1 -1
  16. package/css/index.min.css +8 -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 +256 -0
  71. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +270 -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 +10 -0
  75. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +310 -0
  76. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +25 -0
  77. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.js +38 -0
  78. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useSubscribeToEventEmitter.js +25 -0
  79. package/es/components/Datagrid/Datagrid/addons/Filtering/index.js +9 -0
  80. package/es/components/Datagrid/Datagrid/addons/Filtering/motion/variants.js +55 -0
  81. package/es/components/Datagrid/Datagrid/addons/Filtering/utils.js +72 -0
  82. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +60 -0
  83. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +1 -0
  84. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +541 -0
  85. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +1 -0
  86. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +112 -0
  87. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +27 -0
  88. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +1 -0
  89. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +39 -0
  90. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +19 -0
  91. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +262 -0
  92. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +87 -0
  93. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +17 -14
  94. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +13 -36
  95. package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/index.js +0 -1
  96. package/es/components/Datagrid/index.js +4 -1
  97. package/es/components/Datagrid/useActionsColumn.js +28 -12
  98. package/es/components/Datagrid/useColumnOrder.js +8 -0
  99. package/es/components/Datagrid/useCustomizeColumns.js +13 -8
  100. package/es/components/Datagrid/useDisableSelectRows.js +6 -2
  101. package/es/components/Datagrid/useExpandedRow.js +0 -1
  102. package/es/components/Datagrid/useFiltering.js +99 -0
  103. package/es/components/Datagrid/useInfiniteScroll.js +5 -2
  104. package/es/components/Datagrid/useInlineEdit.js +71 -0
  105. package/es/components/Datagrid/useNestedRowExpander.js +47 -0
  106. package/es/components/Datagrid/useNestedRows.js +16 -4
  107. package/es/components/Datagrid/useParentDimensions.js +3 -1
  108. package/es/components/Datagrid/useRowExpander.js +12 -4
  109. package/es/components/Datagrid/useRowSize.js +17 -6
  110. package/es/components/Datagrid/useSelectAllToggle.js +17 -4
  111. package/es/components/Datagrid/useSelectRows.js +13 -4
  112. package/es/components/Datagrid/useSortableColumns.js +15 -9
  113. package/es/components/Datagrid/useStickyColumn.js +11 -0
  114. package/es/components/Datagrid/utils/DatagridActions.js +249 -0
  115. package/es/components/Datagrid/utils/DatagridPagination.js +33 -0
  116. package/es/components/Datagrid/utils/Wrapper.js +21 -0
  117. package/es/components/Datagrid/utils/getArgTypes.js +94 -0
  118. package/es/components/Datagrid/utils/getInlineEditColumns.js +159 -0
  119. package/es/components/Datagrid/utils/makeData.js +54 -1
  120. package/es/components/EditUpdateCards/EditUpdateCards.js +144 -0
  121. package/es/components/EditUpdateCards/index.js +7 -0
  122. package/es/components/ExportModal/ExportModal.js +1 -1
  123. package/es/components/FilterSummary/FilterSummary.js +54 -0
  124. package/es/components/FilterSummary/index.js +7 -0
  125. package/es/components/ImportModal/ImportModal.js +3 -3
  126. package/es/components/InlineEdit/InlineEdit.js +28 -426
  127. package/es/components/InlineEditV1/InlineEditV1.js +447 -0
  128. package/es/components/InlineEditV1/index.js +7 -0
  129. package/es/components/InlineEditV2/InlineEditV2.js +289 -0
  130. package/es/components/InlineEditV2/index.js +7 -0
  131. package/es/components/ModifiedTabs/ModifiedTabLabelNew.js +1 -1
  132. package/es/components/ModifiedTabs/ModifiedTabLabelWithClose.js +1 -1
  133. package/es/components/MultiAddSelect/MultiAddSelect.js +14 -7
  134. package/es/components/MultiAddSelect/index.js +6 -0
  135. package/es/components/NotificationsPanel/NotificationsPanel.js +1 -1
  136. package/es/components/OptionsTile/OptionsTile.js +32 -16
  137. package/es/components/PageHeader/PageHeader.js +4 -4
  138. package/es/components/PageHeader/PageHeaderTitle.js +1 -1
  139. package/es/components/ProductiveCard/ProductiveCard.js +5 -0
  140. package/es/components/RemoveModal/RemoveModal.js +20 -3
  141. package/es/components/Saving/Saving.js +1 -1
  142. package/es/components/SidePanel/SidePanel.js +45 -52
  143. package/es/components/SidePanel/motion/variants.js +45 -0
  144. package/es/components/SingleAddSelect/SingleAddSelect.js +6 -0
  145. package/es/components/SingleAddSelect/index.js +6 -0
  146. package/es/components/StatusIcon/StatusIcon.js +1 -1
  147. package/es/components/Tearsheet/Tearsheet.js +5 -0
  148. package/es/components/Tearsheet/TearsheetNarrow.js +5 -0
  149. package/es/components/Tearsheet/TearsheetShell.js +1 -1
  150. package/es/components/UserProfileImage/UserProfileImage.js +1 -1
  151. package/es/components/WebTerminal/WebTerminal.js +1 -1
  152. package/es/components/WebTerminal/preview-components/Navigation.js +1 -1
  153. package/es/components/index.js +4 -3
  154. package/es/global/js/hooks/index.js +2 -1
  155. package/es/global/js/hooks/useClickOutside.js +1 -1
  156. package/es/global/js/hooks/useControllableState.js +83 -0
  157. package/es/global/js/hooks/useCreateComponentFocus.js +38 -10
  158. package/es/global/js/hooks/useResetCreateComponent.js +6 -2
  159. package/es/global/js/package-settings.js +9 -6
  160. package/es/global/js/utils/getBezierValues.js +20 -0
  161. package/es/global/js/utils/getNumberOfHiddenSteps.js +19 -0
  162. package/es/global/js/utils/motionConstants.js +45 -0
  163. package/es/global/js/utils/rangeWithCallback.js +13 -0
  164. package/es/global/js/utils/story-helper.js +5 -1
  165. package/es/global/js/utils/uuidv4.spec.js +4 -0
  166. package/lib/components/APIKeyModal/APIKeyModal.js +4 -4
  167. package/lib/components/ActionBar/ActionBarOverflowItems.js +1 -0
  168. package/lib/components/ActionSet/ActionSet.js +7 -3
  169. package/lib/components/AddSelect/AddSelect.js +5 -6
  170. package/lib/components/AddSelect/AddSelectBody.js +68 -31
  171. package/lib/components/AddSelect/AddSelectBreadcrumbs.js +15 -4
  172. package/lib/components/AddSelect/AddSelectColumn.js +7 -7
  173. package/lib/components/AddSelect/AddSelectFilter.js +9 -6
  174. package/lib/components/AddSelect/AddSelectList.js +65 -30
  175. package/lib/components/AddSelect/AddSelectMetaPanel.js +8 -2
  176. package/lib/components/AddSelect/AddSelectSidebar.js +4 -1
  177. package/lib/components/AddSelect/AddSelectSort.js +5 -5
  178. package/lib/components/AddSelect/add-select-utils.js +9 -2
  179. package/lib/components/AddSelect/hooks/useItemSort.js +6 -0
  180. package/lib/components/AddSelect/hooks/useParentSelect.js +6 -0
  181. package/lib/components/AddSelect/hooks/usePath.js +16 -1
  182. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +6 -6
  183. package/lib/components/ButtonMenu/ButtonMenu.js +4 -3
  184. package/lib/components/Card/Card.js +16 -6
  185. package/lib/components/Card/CardFooter.js +3 -1
  186. package/lib/components/Card/CardHeader.js +21 -1
  187. package/lib/components/ComboButton/ComboButton.js +3 -3
  188. package/lib/components/CreateFullPage/CreateFullPage.js +13 -3
  189. package/lib/components/CreateTearsheet/CreateTearsheet.js +18 -3
  190. package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +3 -1
  191. package/lib/components/CreateTearsheetNarrow/CreateTearsheetNarrow.js +2 -2
  192. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +65 -14
  193. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
  194. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
  195. package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +6 -5
  196. package/lib/components/DataSpreadsheet/utils/handleCellDeletion.js +53 -0
  197. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
  198. package/lib/components/Datagrid/Datagrid/Datagrid.js +19 -47
  199. package/lib/components/Datagrid/Datagrid/DatagridContent.js +230 -0
  200. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +19 -9
  201. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  202. package/lib/components/Datagrid/Datagrid/DatagridHead.js +1 -3
  203. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +2 -5
  204. package/lib/components/Datagrid/Datagrid/DatagridRow.js +46 -8
  205. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +14 -6
  206. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +16 -5
  207. package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +1 -2
  208. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +14 -10
  209. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +33 -10
  210. package/lib/components/Datagrid/Datagrid/DraggableElement.js +12 -4
  211. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +11 -49
  212. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +11 -8
  213. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +76 -46
  214. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/{CustomizeColumnsModal.js → CustomizeColumnsTearsheet.js} +85 -48
  215. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/{ModalWrapper.js → TearsheetWrapper.js} +32 -36
  216. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +3 -3
  217. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +284 -0
  218. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +301 -0
  219. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +112 -0
  220. package/lib/components/Datagrid/Datagrid/addons/Filtering/constants.js +47 -0
  221. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/index.js +39 -0
  222. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +325 -0
  223. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +37 -0
  224. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.js +50 -0
  225. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useSubscribeToEventEmitter.js +35 -0
  226. package/lib/components/Datagrid/Datagrid/addons/Filtering/index.js +37 -0
  227. package/lib/components/Datagrid/Datagrid/addons/Filtering/motion/variants.js +67 -0
  228. package/lib/components/Datagrid/Datagrid/addons/Filtering/utils.js +82 -0
  229. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +76 -0
  230. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +13 -0
  231. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +566 -0
  232. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +13 -0
  233. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +129 -0
  234. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +36 -0
  235. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +19 -0
  236. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +45 -0
  237. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +28 -0
  238. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +271 -0
  239. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +100 -0
  240. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +17 -13
  241. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +13 -35
  242. package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/index.js +0 -8
  243. package/lib/components/Datagrid/index.js +25 -1
  244. package/lib/components/Datagrid/useActionsColumn.js +28 -13
  245. package/lib/components/Datagrid/useColumnOrder.js +17 -0
  246. package/lib/components/Datagrid/useCustomizeColumns.js +12 -7
  247. package/lib/components/Datagrid/useDisableSelectRows.js +6 -2
  248. package/lib/components/Datagrid/useExpandedRow.js +0 -1
  249. package/lib/components/Datagrid/useFiltering.js +105 -0
  250. package/lib/components/Datagrid/useInfiniteScroll.js +5 -2
  251. package/lib/components/Datagrid/useInlineEdit.js +85 -0
  252. package/lib/components/Datagrid/useNestedRowExpander.js +63 -0
  253. package/lib/components/Datagrid/useNestedRows.js +17 -4
  254. package/lib/components/Datagrid/useParentDimensions.js +3 -1
  255. package/lib/components/Datagrid/useRowExpander.js +17 -5
  256. package/lib/components/Datagrid/useRowSize.js +18 -13
  257. package/lib/components/Datagrid/useSelectAllToggle.js +18 -4
  258. package/lib/components/Datagrid/useSelectRows.js +13 -4
  259. package/lib/components/Datagrid/useSortableColumns.js +16 -7
  260. package/lib/components/Datagrid/useStickyColumn.js +11 -0
  261. package/lib/components/Datagrid/utils/DatagridActions.js +275 -0
  262. package/lib/components/Datagrid/utils/DatagridPagination.js +46 -0
  263. package/lib/components/Datagrid/utils/Wrapper.js +33 -0
  264. package/lib/components/Datagrid/utils/getArgTypes.js +102 -0
  265. package/lib/components/Datagrid/utils/getInlineEditColumns.js +174 -0
  266. package/lib/components/Datagrid/utils/makeData.js +56 -2
  267. package/lib/components/EditUpdateCards/EditUpdateCards.js +152 -0
  268. package/lib/components/EditUpdateCards/index.js +13 -0
  269. package/lib/components/ExportModal/ExportModal.js +3 -3
  270. package/lib/components/FilterSummary/FilterSummary.js +72 -0
  271. package/lib/components/FilterSummary/index.js +15 -0
  272. package/lib/components/ImportModal/ImportModal.js +4 -4
  273. package/lib/components/InlineEdit/InlineEdit.js +27 -426
  274. package/lib/components/InlineEditV1/InlineEditV1.js +464 -0
  275. package/lib/components/InlineEditV1/index.js +13 -0
  276. package/lib/components/InlineEditV2/InlineEditV2.js +309 -0
  277. package/lib/components/InlineEditV2/index.js +13 -0
  278. package/lib/components/ModifiedTabs/ModifiedTabLabelNew.js +2 -2
  279. package/lib/components/ModifiedTabs/ModifiedTabLabelWithClose.js +3 -3
  280. package/lib/components/MultiAddSelect/MultiAddSelect.js +14 -7
  281. package/lib/components/NotificationsPanel/NotificationsPanel.js +8 -8
  282. package/lib/components/OptionsTile/OptionsTile.js +36 -19
  283. package/lib/components/PageHeader/PageHeader.js +5 -5
  284. package/lib/components/PageHeader/PageHeaderTitle.js +1 -1
  285. package/lib/components/ProductiveCard/ProductiveCard.js +5 -0
  286. package/lib/components/RemoveModal/RemoveModal.js +20 -3
  287. package/lib/components/Saving/Saving.js +5 -5
  288. package/lib/components/SidePanel/SidePanel.js +48 -53
  289. package/lib/components/SidePanel/motion/variants.js +55 -0
  290. package/lib/components/SingleAddSelect/SingleAddSelect.js +6 -0
  291. package/lib/components/StatusIcon/StatusIcon.js +45 -45
  292. package/lib/components/Tearsheet/Tearsheet.js +5 -0
  293. package/lib/components/Tearsheet/TearsheetNarrow.js +5 -0
  294. package/lib/components/Tearsheet/TearsheetShell.js +1 -1
  295. package/lib/components/UserProfileImage/UserProfileImage.js +7 -7
  296. package/lib/components/WebTerminal/WebTerminal.js +3 -3
  297. package/lib/components/WebTerminal/preview-components/Navigation.js +4 -4
  298. package/lib/components/index.js +33 -1
  299. package/lib/global/js/hooks/index.js +9 -1
  300. package/lib/global/js/hooks/useClickOutside.js +1 -1
  301. package/lib/global/js/hooks/useControllableState.js +94 -0
  302. package/lib/global/js/hooks/useCreateComponentFocus.js +42 -11
  303. package/lib/global/js/hooks/useResetCreateComponent.js +7 -2
  304. package/lib/global/js/package-settings.js +9 -6
  305. package/lib/global/js/utils/getBezierValues.js +29 -0
  306. package/lib/global/js/utils/getNumberOfHiddenSteps.js +28 -0
  307. package/lib/global/js/utils/motionConstants.js +55 -0
  308. package/lib/global/js/utils/rangeWithCallback.js +22 -0
  309. package/lib/global/js/utils/story-helper.js +5 -1
  310. package/lib/global/js/utils/uuidv4.spec.js +4 -0
  311. package/package.json +18 -16
  312. package/scss/components/ActionSet/_action-set.scss +9 -4
  313. package/scss/components/AddSelect/_add-select.scss +132 -34
  314. package/scss/components/AddSelect/_index.scss +1 -1
  315. package/scss/components/AddSelect/_storybook-styles.scss +1 -1
  316. package/scss/components/Card/_card.scss +1 -0
  317. package/scss/components/Cascade/_cascade.scss +1 -1
  318. package/scss/components/CreateTearsheet/_create-tearsheet.scss +2 -0
  319. package/scss/components/Datagrid/_datagrid.scss +7 -1
  320. package/scss/components/Datagrid/_storybook-styles.scss +29 -5
  321. package/scss/components/Datagrid/styles/_datagrid.scss +133 -41
  322. package/scss/components/Datagrid/styles/_draggableElement.scss +50 -18
  323. package/scss/components/Datagrid/styles/_index.scss +10 -8
  324. package/scss/components/Datagrid/styles/_useActionsColumn.scss +14 -0
  325. package/scss/components/Datagrid/styles/_useExpandedRow.scss +56 -10
  326. package/scss/components/Datagrid/styles/_useInlineEdit.scss +419 -0
  327. package/scss/components/Datagrid/styles/_useNestedRows.scss +33 -1
  328. package/scss/components/Datagrid/styles/_useSortableColumns.scss +35 -16
  329. package/scss/components/Datagrid/styles/_useStickyColumn.scss +31 -2
  330. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsTearsheet.scss +69 -0
  331. package/scss/components/Datagrid/styles/addons/_FilterFlyout.scss +87 -0
  332. package/scss/components/Datagrid/styles/addons/_FilterPanel.scss +129 -0
  333. package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +12 -4
  334. package/scss/components/EditUpdateCards/_carbon-imports.scss +9 -0
  335. package/scss/components/EditUpdateCards/_edit-update-cards.scss +85 -0
  336. package/scss/components/EditUpdateCards/_index-with-carbon.scss +9 -0
  337. package/scss/components/EditUpdateCards/_index.scss +8 -0
  338. package/scss/components/EditUpdateCards/_storybook-styles.scss +55 -0
  339. package/scss/components/FilterSummary/_filter-summary.scss +21 -0
  340. package/scss/components/FilterSummary/_index.scss +10 -0
  341. package/scss/components/FilterSummary/_storybook-styles.scss +14 -0
  342. package/scss/components/{InlineEdit → InlineEditV1}/_index-with-carbon.scss +1 -1
  343. package/scss/components/{InlineEdit → InlineEditV1}/_index.scss +1 -1
  344. package/scss/components/{InlineEdit/_inline-edit.scss → InlineEditV1/_inline-edit-v1.scss} +4 -2
  345. package/scss/components/InlineEditV2/_carbon-imports.scss +9 -0
  346. package/scss/components/InlineEditV2/_index-with-carbon.scss +9 -0
  347. package/scss/components/InlineEditV2/_index.scss +10 -0
  348. package/scss/components/InlineEditV2/_inline-edit-v2.scss +83 -0
  349. package/scss/components/InlineEditV2/_storybook-styles.scss +9 -0
  350. package/scss/components/MultiAddSelect/_multi-add-select.scss +8 -1
  351. package/scss/components/MultiAddSelect/_storybook-styles.scss +1 -1
  352. package/scss/components/NotificationsPanel/_notifications-panel.scss +3 -6
  353. package/scss/components/OptionsTile/_options-tile.scss +10 -3
  354. package/scss/components/RemoveModal/_remove-modal.scss +0 -4
  355. package/scss/components/SidePanel/_side-panel.scss +3 -82
  356. package/scss/components/SidePanel/_storybook-styles.scss +6 -1
  357. package/scss/components/SingleAddSelect/_carbon-imports.scss +1 -1
  358. package/scss/components/SingleAddSelect/_index-with-carbon.scss +1 -1
  359. package/scss/components/SingleAddSelect/_index.scss +7 -0
  360. package/scss/components/SingleAddSelect/_single-add-select.scss +8 -1
  361. package/scss/components/SingleAddSelect/_storybook-styles.scss +1 -1
  362. package/scss/components/Tearsheet/_tearsheet.scss +4 -2
  363. package/scss/components/_index-released-only-with-carbon.scss +3 -1
  364. package/scss/components/_index-released-only.scss +4 -1
  365. package/scss/components/_index-with-carbon.scss +3 -1
  366. package/scss/components/_index.scss +4 -1
  367. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +0 -157
  368. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +0 -62
  369. package/es/components/Datagrid/Datagrid.stories-helpers/LeftPanelStory.js +0 -6
  370. package/lib/components/Datagrid/Datagrid.stories-helpers/LeftPanelStory.js +0 -13
  371. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsModal.scss +0 -52
  372. /package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/CustomizeColumnStory.js +0 -0
  373. /package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/RowSizeDropdownStory.js +0 -0
  374. /package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/SelectAllWithToggleStory.js +0 -0
  375. /package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/StickyActionsColumnStory.js +0 -0
  376. /package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/common.js +0 -0
  377. /package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/CustomizeColumnStory.js +0 -0
  378. /package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/RowSizeDropdownStory.js +0 -0
  379. /package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/SelectAllWithToggleStory.js +0 -0
  380. /package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/StickyActionsColumnStory.js +0 -0
  381. /package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/common.js +0 -0
  382. /package/scss/components/{InlineEdit → InlineEditV1}/_carbon-imports.scss +0 -0
  383. /package/scss/components/{InlineEdit → InlineEditV1}/_storybook-styles.scss +0 -0
@@ -0,0 +1,284 @@
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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
+
16
+ var _icons = require("@carbon/react/icons");
17
+
18
+ var _react = require("@carbon/react");
19
+
20
+ var _classnames = _interopRequireDefault(require("classnames"));
21
+
22
+ var _propTypes = _interopRequireDefault(require("prop-types"));
23
+
24
+ var _react2 = _interopRequireWildcard(require("react"));
25
+
26
+ var _hooks = require("../../../../../global/js/hooks");
27
+
28
+ var _settings = require("../../../../../settings");
29
+
30
+ var _ActionSet = require("../../../../ActionSet");
31
+
32
+ var _constants = require("./constants");
33
+
34
+ var _hooks2 = require("./hooks");
35
+
36
+ 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); }
37
+
38
+ 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; }
39
+
40
+ // @flow
41
+
42
+ /**
43
+ * Copyright IBM Corp. 2022, 2023
44
+ *
45
+ * This source code is licensed under the Apache-2.0 license found in the
46
+ * LICENSE file in the root directory of this source tree.
47
+ */
48
+ var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
49
+ var componentClass = "".concat(blockClass, "-filter-flyout");
50
+
51
+ var FilterFlyout = function FilterFlyout(_ref) {
52
+ var _cx2;
53
+
54
+ var _ref$updateMethod = _ref.updateMethod,
55
+ updateMethod = _ref$updateMethod === void 0 ? _constants.BATCH : _ref$updateMethod,
56
+ _ref$flyoutIconDescri = _ref.flyoutIconDescription,
57
+ flyoutIconDescription = _ref$flyoutIconDescri === void 0 ? 'Open filters' : _ref$flyoutIconDescri,
58
+ _ref$filters = _ref.filters,
59
+ filters = _ref$filters === void 0 ? [] : _ref$filters,
60
+ _ref$title = _ref.title,
61
+ title = _ref$title === void 0 ? 'Filter' : _ref$title,
62
+ _ref$primaryActionLab = _ref.primaryActionLabel,
63
+ primaryActionLabel = _ref$primaryActionLab === void 0 ? 'Apply' : _ref$primaryActionLab,
64
+ _ref$onFlyoutOpen = _ref.onFlyoutOpen,
65
+ onFlyoutOpen = _ref$onFlyoutOpen === void 0 ? function () {} : _ref$onFlyoutOpen,
66
+ _ref$onFlyoutClose = _ref.onFlyoutClose,
67
+ onFlyoutClose = _ref$onFlyoutClose === void 0 ? function () {} : _ref$onFlyoutClose,
68
+ _ref$onApply = _ref.onApply,
69
+ onApply = _ref$onApply === void 0 ? function () {} : _ref$onApply,
70
+ _ref$onCancel = _ref.onCancel,
71
+ onCancel = _ref$onCancel === void 0 ? function () {} : _ref$onCancel,
72
+ _ref$secondaryActionL = _ref.secondaryActionLabel,
73
+ secondaryActionLabel = _ref$secondaryActionL === void 0 ? 'Cancel' : _ref$secondaryActionL,
74
+ setAllFilters = _ref.setAllFilters,
75
+ _ref$data = _ref.data,
76
+ data = _ref$data === void 0 ? [] : _ref$data;
77
+
78
+ /** State */
79
+ var _useState = (0, _react2.useState)(false),
80
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
81
+ open = _useState2[0],
82
+ setOpen = _useState2[1];
83
+
84
+ var _useFilters = (0, _hooks2.useFilters)({
85
+ updateMethod: updateMethod,
86
+ filters: filters,
87
+ setAllFilters: setAllFilters,
88
+ variation: _constants.FLYOUT
89
+ }),
90
+ filtersState = _useFilters.filtersState,
91
+ prevFiltersObjectArrayRef = _useFilters.prevFiltersObjectArrayRef,
92
+ prevFiltersRef = _useFilters.prevFiltersRef,
93
+ revertToPreviousFilters = _useFilters.revertToPreviousFilters,
94
+ reset = _useFilters.reset,
95
+ renderFilter = _useFilters.renderFilter,
96
+ filtersObjectArray = _useFilters.filtersObjectArray;
97
+ /** Refs */
98
+
99
+
100
+ var filterFlyoutRef = (0, _react2.useRef)(null);
101
+ /** State from hooks */
102
+
103
+ var _useShouldDisableButt = (0, _hooks2.useShouldDisableButtons)({
104
+ initialValue: true,
105
+ filtersState: filtersState,
106
+ prevFiltersRef: prevFiltersRef
107
+ }),
108
+ _useShouldDisableButt2 = (0, _slicedToArray2.default)(_useShouldDisableButt, 2),
109
+ shouldDisableButtons = _useShouldDisableButt2[0],
110
+ setShouldDisableButtons = _useShouldDisableButt2[1];
111
+ /** Memos */
112
+
113
+
114
+ var showActionSet = updateMethod === _constants.BATCH;
115
+ var carbonPrefix = (0, _react.usePrefix)();
116
+ /** Methods */
117
+
118
+ var openFlyout = function openFlyout() {
119
+ setOpen(true);
120
+ onFlyoutOpen();
121
+ };
122
+
123
+ var closeFlyout = function closeFlyout() {
124
+ setOpen(false);
125
+ onFlyoutClose();
126
+ };
127
+
128
+ var apply = function apply() {
129
+ setAllFilters(filtersObjectArray);
130
+ closeFlyout(); // From the user
131
+
132
+ onApply(); // When the user clicks apply, the action set buttons should be disabled again
133
+
134
+ setShouldDisableButtons(true); // updates the ref so next time the flyout opens we have records of the previous filters
135
+
136
+ prevFiltersRef.current = JSON.stringify(filtersState);
137
+ prevFiltersObjectArrayRef.current = JSON.stringify(filtersObjectArray);
138
+ };
139
+
140
+ var cancel = function cancel() {
141
+ // Reverting to previous filters only applies when using batch actions
142
+ if (updateMethod === _constants.BATCH) {
143
+ revertToPreviousFilters();
144
+ onCancel();
145
+ }
146
+
147
+ closeFlyout();
148
+ };
149
+ /** Effects */
150
+
151
+
152
+ (0, _hooks.useClickOutside)(filterFlyoutRef, function (target) {
153
+ var hasClickedOnDatePicker = target.closest('.flatpickr-calendar');
154
+ var hasClickedOnDropdown = target.className === "".concat(carbonPrefix, "--list-box__menu-item__option");
155
+
156
+ if (!open || hasClickedOnDatePicker || hasClickedOnDropdown) {
157
+ return;
158
+ }
159
+
160
+ cancel();
161
+ });
162
+ (0, _hooks2.useSubscribeToEventEmitter)(_constants.CLEAR_FILTERS, reset);
163
+ /** Renders all filters */
164
+
165
+ var renderFilters = function renderFilters() {
166
+ return filters.map(renderFilter);
167
+ };
168
+
169
+ var renderActionSet = function renderActionSet() {
170
+ return showActionSet && /*#__PURE__*/_react2.default.createElement(_ActionSet.ActionSet, {
171
+ actions: [{
172
+ key: 1,
173
+ kind: 'primary',
174
+ label: primaryActionLabel,
175
+ onClick: apply,
176
+ isExpressive: false,
177
+ disabled: shouldDisableButtons
178
+ }, {
179
+ key: 3,
180
+ kind: 'secondary',
181
+ label: secondaryActionLabel,
182
+ onClick: cancel,
183
+ isExpressive: false,
184
+ disabled: shouldDisableButtons
185
+ }],
186
+ size: "md",
187
+ buttonSize: "md"
188
+ });
189
+ };
190
+
191
+ return /*#__PURE__*/_react2.default.createElement("div", {
192
+ className: "".concat(componentClass, "__container")
193
+ }, /*#__PURE__*/_react2.default.createElement(_react.Button, {
194
+ kind: "ghost",
195
+ hasIconOnly: true,
196
+ tooltipPosition: "bottom",
197
+ renderIcon: function renderIcon() {
198
+ return /*#__PURE__*/_react2.default.createElement(_icons.Filter, {
199
+ size: 16
200
+ });
201
+ },
202
+ iconDescription: flyoutIconDescription,
203
+ onClick: open ? closeFlyout : openFlyout,
204
+ className: (0, _classnames.default)("".concat(componentClass, "__trigger"), (0, _defineProperty2.default)({}, "".concat(componentClass, "__trigger--open"), open)),
205
+ disabled: data.length === 0
206
+ }), /*#__PURE__*/_react2.default.createElement("div", {
207
+ ref: filterFlyoutRef,
208
+ className: (0, _classnames.default)(componentClass, (_cx2 = {}, (0, _defineProperty2.default)(_cx2, "".concat(componentClass, "--open"), open), (0, _defineProperty2.default)(_cx2, "".concat(componentClass, "--batch"), showActionSet), (0, _defineProperty2.default)(_cx2, "".concat(componentClass, "--instant"), !showActionSet), _cx2))
209
+ }, /*#__PURE__*/_react2.default.createElement("div", {
210
+ className: "".concat(componentClass, "__inner-container")
211
+ }, /*#__PURE__*/_react2.default.createElement("span", {
212
+ className: "".concat(componentClass, "__title")
213
+ }, title), /*#__PURE__*/_react2.default.createElement("div", {
214
+ className: "".concat(componentClass, "__filters")
215
+ }, renderFilters())), renderActionSet()));
216
+ };
217
+
218
+ FilterFlyout.propTypes = {
219
+ /**
220
+ * All data rows in the table
221
+ */
222
+ data: _propTypes.default.array.isRequired,
223
+
224
+ /**
225
+ * Array of filters to render
226
+ */
227
+ filters: _propTypes.default.arrayOf(_propTypes.default.shape({
228
+ type: _propTypes.default.string.isRequired,
229
+ column: _propTypes.default.string.isRequired,
230
+ props: _propTypes.default.object.isRequired
231
+ })).isRequired,
232
+
233
+ /**
234
+ * Icon description for the filter flyout button
235
+ */
236
+ flyoutIconDescription: _propTypes.default.string,
237
+
238
+ /**
239
+ * Callback when the apply button is clicked
240
+ */
241
+ onApply: _propTypes.default.func,
242
+
243
+ /**
244
+ * Callback when the cancel button is clicked
245
+ */
246
+ onCancel: _propTypes.default.func,
247
+
248
+ /**
249
+ * Callback when the flyout closes
250
+ */
251
+ onFlyoutClose: _propTypes.default.func,
252
+
253
+ /**
254
+ * Callback when the flyout opens
255
+ */
256
+ onFlyoutOpen: _propTypes.default.func,
257
+
258
+ /**
259
+ * Label text of the primary action in the flyout
260
+ */
261
+ primaryActionLabel: _propTypes.default.string,
262
+
263
+ /**
264
+ * Label text of the secondary action in the flyout
265
+ */
266
+ secondaryActionLabel: _propTypes.default.string,
267
+
268
+ /**
269
+ * Function that sets all the filters, this comes from the datagridState
270
+ */
271
+ setAllFilters: _propTypes.default.func.isRequired,
272
+
273
+ /**
274
+ * Title of the filter flyout
275
+ */
276
+ title: _propTypes.default.string,
277
+
278
+ /**
279
+ * The update method used to apply the filters
280
+ */
281
+ updateMethod: _propTypes.default.oneOf([_constants.BATCH, _constants.INSTANT]).isRequired
282
+ };
283
+ var _default = FilterFlyout;
284
+ exports.default = _default;
@@ -0,0 +1,301 @@
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 _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
+
18
+ var _react = _interopRequireWildcard(require("react"));
19
+
20
+ var _propTypes = _interopRequireDefault(require("prop-types"));
21
+
22
+ var _react2 = require("@carbon/react");
23
+
24
+ var _layout = require("@carbon/layout");
25
+
26
+ var _settings = require("../../../../../settings");
27
+
28
+ var _constants = require("./constants");
29
+
30
+ var _classnames = _interopRequireDefault(require("classnames"));
31
+
32
+ var _framerMotion = require("framer-motion");
33
+
34
+ var _variants = require("./motion/variants");
35
+
36
+ var _icons = require("@carbon/react/icons");
37
+
38
+ var _ActionSet = require("../../../../ActionSet");
39
+
40
+ var _ = require(".");
41
+
42
+ var _hooks = require("./hooks");
43
+
44
+ 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); }
45
+
46
+ 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; }
47
+
48
+ /**
49
+ * Copyright IBM Corp. 2022, 2023
50
+ *
51
+ * This source code is licensed under the Apache-2.0 license found in the
52
+ * LICENSE file in the root directory of this source tree.
53
+ */
54
+
55
+ /* eslint-disable react/jsx-key */
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 _useState = (0, _react.useState)(false),
94
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
95
+ showDividerLine = _useState2[0],
96
+ setShowDividerLine = _useState2[1];
97
+
98
+ var _useFilters = (0, _hooks.useFilters)({
99
+ updateMethod: updateMethod,
100
+ filters: filterSections,
101
+ setAllFilters: setAllFilters,
102
+ variation: _constants.PANEL
103
+ }),
104
+ filtersState = _useFilters.filtersState,
105
+ prevFiltersObjectArrayRef = _useFilters.prevFiltersObjectArrayRef,
106
+ prevFiltersRef = _useFilters.prevFiltersRef,
107
+ revertToPreviousFilters = _useFilters.revertToPreviousFilters,
108
+ reset = _useFilters.reset,
109
+ renderFilter = _useFilters.renderFilter,
110
+ filtersObjectArray = _useFilters.filtersObjectArray;
111
+ /** Refs */
112
+
113
+
114
+ var filterPanelRef = (0, _react.useRef)();
115
+ var filterHeadingRef = (0, _react.useRef)();
116
+ var filterSearchRef = (0, _react.useRef)();
117
+ var actionSetRef = (0, _react.useRef)();
118
+ /** State from hooks */
119
+
120
+ var _useShouldDisableButt = (0, _hooks.useShouldDisableButtons)({
121
+ initialValue: true,
122
+ filtersState: filtersState,
123
+ prevFiltersRef: prevFiltersRef
124
+ }),
125
+ _useShouldDisableButt2 = (0, _slicedToArray2.default)(_useShouldDisableButt, 2),
126
+ shouldDisableButtons = _useShouldDisableButt2[0],
127
+ setShouldDisableButtons = _useShouldDisableButt2[1];
128
+ /** Memos */
129
+
130
+
131
+ var showActionSet = (0, _react.useMemo)(function () {
132
+ return updateMethod === _constants.BATCH;
133
+ }, [updateMethod]);
134
+ /** Context */
135
+
136
+ var _useContext = (0, _react.useContext)(_.FilterContext),
137
+ panelOpen = _useContext.panelOpen,
138
+ setPanelOpen = _useContext.setPanelOpen;
139
+ /** Methods */
140
+
141
+
142
+ var closePanel = function closePanel() {
143
+ return setPanelOpen(false);
144
+ };
145
+
146
+ var cancel = function cancel() {
147
+ // Reverting to previous filters only applies when using batch actions
148
+ if (updateMethod === _constants.BATCH) {
149
+ revertToPreviousFilters();
150
+ onCancel();
151
+ }
152
+ };
153
+
154
+ var apply = function apply() {
155
+ setAllFilters(filtersObjectArray); // From the user
156
+
157
+ onApply(); // When the user clicks apply, the action set buttons should be disabled again
158
+
159
+ setShouldDisableButtons(true); // updates the ref so next time the flyout opens we have records of the previous filters
160
+
161
+ prevFiltersRef.current = JSON.stringify(filtersState);
162
+ prevFiltersObjectArrayRef.current = JSON.stringify(filtersObjectArray);
163
+ };
164
+
165
+ var renderActionSet = function renderActionSet() {
166
+ return showActionSet && /*#__PURE__*/_react.default.createElement(MotionActionSet, {
167
+ actions: [{
168
+ key: 1,
169
+ kind: 'primary',
170
+ label: primaryActionLabel,
171
+ onClick: apply,
172
+ disabled: shouldDisableButtons
173
+ }, {
174
+ key: 2,
175
+ kind: 'secondary',
176
+ label: secondaryActionLabel,
177
+ onClick: cancel,
178
+ disabled: shouldDisableButtons
179
+ }],
180
+ className: "".concat(componentClass, "__action-set"),
181
+ ref: actionSetRef,
182
+ variants: _variants.actionSetVariants
183
+ });
184
+ };
185
+
186
+ var onInnerContainerScroll = function onInnerContainerScroll(event) {
187
+ if (event.target.scrollTop > 0) {
188
+ setShowDividerLine(true);
189
+ } else {
190
+ setShowDividerLine(false);
191
+ }
192
+ };
193
+ /** Effects */
194
+
195
+
196
+ (0, _react.useEffect)(function liftOpenStateToParent() {
197
+ if (panelOpen) {
198
+ onPanelOpen(panelOpen);
199
+ } else {
200
+ onPanelClose(panelOpen);
201
+ }
202
+ }, [panelOpen, onPanelClose, onPanelOpen]);
203
+ (0, _react.useEffect)(function setPanelMinimumHeight() {
204
+ var _filterPanelRef$curre;
205
+
206
+ (_filterPanelRef$curre = filterPanelRef.current) === null || _filterPanelRef$curre === void 0 ? void 0 : _filterPanelRef$curre.style.setProperty('--filter-panel-min-height', (0, _layout.rem)(filterPanelMinHeight));
207
+ }, [filterPanelMinHeight]);
208
+ (0, _hooks.useSubscribeToEventEmitter)(_constants.CLEAR_FILTERS, reset);
209
+
210
+ var getScrollableContainerHeight = function getScrollableContainerHeight() {
211
+ var _filterHeadingRef$cur, _filterSearchRef$curr, _actionSetRef$current;
212
+
213
+ var filterHeadingHeight = (_filterHeadingRef$cur = filterHeadingRef.current) === null || _filterHeadingRef$cur === void 0 ? void 0 : _filterHeadingRef$cur.getBoundingClientRect().height;
214
+ var filterSearchHeight = (_filterSearchRef$curr = filterSearchRef.current) === null || _filterSearchRef$curr === void 0 ? void 0 : _filterSearchRef$curr.getBoundingClientRect().height;
215
+ var actionSetHeight = (_actionSetRef$current = actionSetRef.current) === null || _actionSetRef$current === void 0 ? void 0 : _actionSetRef$current.getBoundingClientRect().height;
216
+ var height = "calc(100vh - ".concat(filterHeadingHeight, "px - ").concat(showFilterSearch ? filterSearchHeight : 0, "px - ").concat(updateMethod === _constants.BATCH ? actionSetHeight : 0, "px)");
217
+ return height;
218
+ };
219
+
220
+ return /*#__PURE__*/_react.default.createElement(_framerMotion.motion.div, {
221
+ ref: filterPanelRef,
222
+ className: (0, _classnames.default)(componentClass, "".concat(componentClass, "__container"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(componentClass, "--open"), panelOpen), (0, _defineProperty2.default)(_cx, "".concat(componentClass, "--batch"), showActionSet), (0, _defineProperty2.default)(_cx, "".concat(componentClass, "--instant"), !showActionSet), _cx)),
223
+ initial: false,
224
+ animate: panelOpen ? 'visible' : 'hidden',
225
+ variants: _variants.panelVariants
226
+ }, /*#__PURE__*/_react.default.createElement(_framerMotion.motion.div, {
227
+ variants: _variants.innerContainerVariants
228
+ }, /*#__PURE__*/_react.default.createElement("header", {
229
+ ref: filterHeadingRef,
230
+ className: (0, _classnames.default)("".concat(componentClass, "__heading"), (0, _defineProperty2.default)({}, "".concat(componentClass, "__heading--with-divider"), showDividerLine))
231
+ }, /*#__PURE__*/_react.default.createElement("div", {
232
+ className: "".concat(componentClass, "__title")
233
+ }, title), /*#__PURE__*/_react.default.createElement(_react2.Button, {
234
+ hasIconOnly: true,
235
+ renderIcon: function renderIcon(props) {
236
+ return /*#__PURE__*/_react.default.createElement(_icons.Close, (0, _extends2.default)({
237
+ size: 16
238
+ }, props));
239
+ },
240
+ iconDescription: closeIconDescription,
241
+ kind: "ghost",
242
+ tooltipPosition: "bottom",
243
+ tooltipAlignment: "end",
244
+ onClick: closePanel
245
+ }), showFilterSearch && /*#__PURE__*/_react.default.createElement("div", {
246
+ ref: filterSearchRef,
247
+ className: "".concat(componentClass, "__search")
248
+ }, /*#__PURE__*/_react.default.createElement(_react2.Layer, null, /*#__PURE__*/_react.default.createElement(_react2.Search, {
249
+ labelText: searchLabelText,
250
+ placeholder: searchPlaceholder,
251
+ size: "sm"
252
+ })))), /*#__PURE__*/_react.default.createElement("div", {
253
+ className: "".concat(componentClass, "__inner-container"),
254
+ style: {
255
+ height: getScrollableContainerHeight()
256
+ },
257
+ onScroll: onInnerContainerScroll
258
+ }, filterSections.map(function (_ref2) {
259
+ var _ref2$categoryTitle = _ref2.categoryTitle,
260
+ categoryTitle = _ref2$categoryTitle === void 0 ? null : _ref2$categoryTitle,
261
+ _ref2$filters = _ref2.filters,
262
+ filters = _ref2$filters === void 0 ? [] : _ref2$filters,
263
+ hasAccordion = _ref2.hasAccordion;
264
+ return /*#__PURE__*/_react.default.createElement("div", {
265
+ className: "".concat(componentClass, "__category")
266
+ }, categoryTitle && /*#__PURE__*/_react.default.createElement("div", {
267
+ className: "".concat(componentClass, "__category-title")
268
+ }, categoryTitle), hasAccordion ? /*#__PURE__*/_react.default.createElement(_react2.Accordion, null, filters.map(function (_ref3) {
269
+ var filterLabel = _ref3.filterLabel,
270
+ filter = _ref3.filter;
271
+ return /*#__PURE__*/_react.default.createElement(_react2.AccordionItem, {
272
+ title: filterLabel,
273
+ key: filterLabel
274
+ }, renderFilter(filter));
275
+ })) : filters.map(function (_ref4) {
276
+ var filter = _ref4.filter;
277
+ return renderFilter(filter);
278
+ }));
279
+ })), renderActionSet()));
280
+ };
281
+
282
+ FilterPanel.propTypes = {
283
+ closeIconDescription: _propTypes.default.string,
284
+ filterPanelMinHeight: _propTypes.default.number,
285
+ filterSections: _propTypes.default.array,
286
+ onApply: _propTypes.default.func,
287
+ onCancel: _propTypes.default.func,
288
+ onPanelClose: _propTypes.default.func,
289
+ onPanelOpen: _propTypes.default.func,
290
+ open: _propTypes.default.bool,
291
+ primaryActionLabel: _propTypes.default.string,
292
+ searchLabelText: _propTypes.default.string,
293
+ searchPlaceholder: _propTypes.default.string,
294
+ secondaryActionLabel: _propTypes.default.string,
295
+ setAllFilters: _propTypes.default.func.isRequired,
296
+ showFilterSearch: _propTypes.default.bool,
297
+ title: _propTypes.default.string,
298
+ updateMethod: _propTypes.default.oneOf([_constants.BATCH, _constants.INSTANT])
299
+ };
300
+ var _default = FilterPanel;
301
+ exports.default = _default;