@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,541 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _typeof from "@babel/runtime/helpers/typeof";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
+
6
+ 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; }
7
+
8
+ 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) { _defineProperty(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; }
9
+
10
+ /**
11
+ * Copyright IBM Corp. 2022, 2022
12
+ *
13
+ * This source code is licensed under the Apache-2.0 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ */
16
+ import React, { useState, useRef, useEffect, useContext, useCallback } from 'react';
17
+ import PropTypes from 'prop-types';
18
+ import { TextInput, NumberInput, Dropdown, DatePicker, DatePickerInput } from '@carbon/react';
19
+ import { Edit, CaretSort, ChevronDown, Calendar } from '@carbon/react/icons';
20
+ import { InlineEditButton } from '../InlineEditButton';
21
+ import { pkg } from '../../../../../../settings';
22
+ import cx from 'classnames';
23
+ import { InlineEditContext } from '../InlineEditContext';
24
+ import { usePreviousValue } from '../../../../../../global/js/hooks';
25
+ import { prepareProps } from '../../../../../../global/js/utils/props-helper';
26
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
27
+ export var InlineEditCell = function InlineEditCell(_ref) {
28
+ var _config$validator, _cx3, _value$text;
29
+
30
+ var cell = _ref.cell,
31
+ config = _ref.config,
32
+ instance = _ref.instance,
33
+ _ref$placeholder = _ref.placeholder,
34
+ placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
35
+ tabIndex = _ref.tabIndex,
36
+ value = _ref.value,
37
+ nonEditCell = _ref.nonEditCell,
38
+ totalInlineEditColumns = _ref.totalInlineEditColumns,
39
+ type = _ref.type;
40
+ var columnId = cell.column.id;
41
+ var columnIndex = instance.columns.findIndex(function (col) {
42
+ return col.id === columnId;
43
+ });
44
+ var cellId = "column-".concat(columnIndex, "-row-").concat(cell.row.index);
45
+ var totalColumns = instance.columns.length;
46
+
47
+ var _useContext = useContext(InlineEditContext),
48
+ state = _useContext.state,
49
+ dispatch = _useContext.dispatch;
50
+
51
+ var _useState = useState(false),
52
+ _useState2 = _slicedToArray(_useState, 2),
53
+ inEditMode = _useState2[0],
54
+ setInEditMode = _useState2[1];
55
+
56
+ var _useState3 = useState(value),
57
+ _useState4 = _slicedToArray(_useState3, 2),
58
+ cellValue = _useState4[0],
59
+ setCellValue = _useState4[1];
60
+
61
+ var _useState5 = useState(),
62
+ _useState6 = _slicedToArray(_useState5, 2),
63
+ initialValue = _useState6[0],
64
+ setInitialValue = _useState6[1];
65
+
66
+ var _useState7 = useState(),
67
+ _useState8 = _slicedToArray(_useState7, 2),
68
+ cellLabel = _useState8[0],
69
+ setCellLabel = _useState8[1];
70
+
71
+ var activeCellId = state.activeCellId,
72
+ editId = state.editId;
73
+ var previousState = usePreviousValue({
74
+ editId: editId,
75
+ activeCellId: activeCellId
76
+ });
77
+
78
+ var _ref2 = config || {},
79
+ inputProps = _ref2.inputProps;
80
+
81
+ var textInputRef = useRef();
82
+ var numberInputRef = useRef();
83
+ var dropdownRef = useRef();
84
+ var datePickerRef = useRef();
85
+ var outerButtonElement = useRef();
86
+ useEffect(function () {
87
+ setInitialValue(value);
88
+ var columnId = cell.column.id;
89
+ var columnLabel = instance.columns.find(function (item) {
90
+ return item.id === columnId;
91
+ });
92
+ setCellLabel(typeof columnLabel.Header === 'string' ? columnLabel.Header : 'Inline edit cell label'); // eslint-disable-next-line react-hooks/exhaustive-deps
93
+ }, []); // Reverts cellValue back to initialValue when exiting edit mode via clicking outside
94
+ // of the cell (either on a regular cell or clicking into another inline edit cell) and the
95
+ // edit input is in an invalid state
96
+
97
+ useEffect(function () {
98
+ if ((previousState === null || previousState === void 0 ? void 0 : previousState.editId) === cellId && !editId || (previousState === null || previousState === void 0 ? void 0 : previousState.editId) === cellId && cellId !== editId) {
99
+ var _ref3 = config || {},
100
+ validator = _ref3.validator;
101
+
102
+ var isInvalid = validator === null || validator === void 0 ? void 0 : validator(cellValue);
103
+
104
+ if (isInvalid) {
105
+ setCellValue(initialValue);
106
+ saveCellData(initialValue);
107
+ return;
108
+ }
109
+ }
110
+ }, [previousState === null || previousState === void 0 ? void 0 : previousState.editId, editId, cellId, cellValue, config, initialValue, saveCellData]); // If you are in edit mode and click outside of the cell,
111
+ // this changes the cell back to the InlineEditButton
112
+
113
+ useEffect(function () {
114
+ if (activeCellId !== cellId || !editId) {
115
+ setInEditMode(false);
116
+ }
117
+
118
+ if (activeCellId === cellId && editId === cellId && !nonEditCell) {
119
+ setInEditMode(true);
120
+ saveCellData(cellValue);
121
+ }
122
+ }, [activeCellId, cellId, nonEditCell, editId, cellValue, saveCellData]);
123
+
124
+ var openDropdown = function openDropdown(type) {
125
+ // *****
126
+ // Only added this querySelector because v11 Datepicker isn't forwarding the ref which breaks how we were handling this in v10
127
+ // *****
128
+ var datePickerInputElement = document.querySelector("#".concat(blockClass, "__inline-edit--date-picker--").concat(cell.row.index));
129
+ var dropdownTrigger = type === 'selection' ? dropdownRef === null || dropdownRef === void 0 ? void 0 : dropdownRef.current : datePickerInputElement;
130
+ dropdownTrigger.click();
131
+
132
+ if (type === 'date') {
133
+ dropdownTrigger === null || dropdownTrigger === void 0 ? void 0 : dropdownTrigger.focus();
134
+ }
135
+ }; // Re-initializes initialValue if clicking outside of a cell that was previously
136
+ // in edit mode, otherwise `initialValue` becomes stale
137
+
138
+
139
+ useEffect(function () {
140
+ if ((previousState === null || previousState === void 0 ? void 0 : previousState.editId) === cellId && (previousState === null || previousState === void 0 ? void 0 : previousState.activeCellId) === cellId && activeCellId !== cellId) {
141
+ setInitialValue(cellValue);
142
+ }
143
+ }, [previousState, cellId, cellValue, activeCellId]);
144
+
145
+ var handleInlineCellClick = function handleInlineCellClick() {
146
+ if (!inEditMode) {
147
+ dispatch({
148
+ type: 'ENTER_EDIT_MODE',
149
+ payload: {
150
+ activeCellId: cellId,
151
+ editId: cellId
152
+ }
153
+ });
154
+ setInEditMode(true);
155
+ setTimeout(function () {
156
+ if (type === 'selection' || type === 'date') {
157
+ openDropdown(type);
158
+ }
159
+ }, 1);
160
+ }
161
+ };
162
+
163
+ var rowSize = instance.rowSize,
164
+ onDataUpdate = instance.onDataUpdate; // Auto focus text input when entering edit mode
165
+
166
+ useEffect(function () {
167
+ if (inEditMode) {
168
+ if (type === 'text') {
169
+ textInputRef.current.focus();
170
+ }
171
+
172
+ if (type === 'number') {
173
+ numberInputRef.current.focus();
174
+ }
175
+ }
176
+ }, [inEditMode, type]); // Initialize cellValue from value prop
177
+
178
+ useEffect(function () {
179
+ setCellValue(value);
180
+ }, [value]); // Saves the new cell data, onDataUpdate is a required function to be
181
+ // passed to useDatagrid when using useInlineEdit
182
+
183
+ var saveCellData = useCallback(function (newValue) {
184
+ var columnId = cell.column.id;
185
+ var rowIndex = cell.row.index;
186
+ onDataUpdate(function (prev) {
187
+ return prev.map(function (row, index) {
188
+ if (index === rowIndex) {
189
+ return _objectSpread(_objectSpread({}, prev[rowIndex]), {}, _defineProperty({}, columnId, newValue));
190
+ }
191
+
192
+ return row;
193
+ });
194
+ });
195
+ }, [cell, onDataUpdate]);
196
+
197
+ var sendFocusBackToGrid = function sendFocusBackToGrid() {
198
+ // Allows the onKeyDown listener to go back to the entire grid area
199
+ var inlineEditArea = document.querySelector("#".concat(instance.tableId, " .").concat(blockClass, "__table-with-inline-edit"));
200
+ inlineEditArea.focus();
201
+ };
202
+
203
+ var getNewCellId = function getNewCellId(key) {
204
+ var totalRows = instance.rows.length;
205
+ var newCellId = key === 'Enter' ? "column-".concat(columnIndex, "-row-").concat(cell.row.index < totalRows - 1 ? cell.row.index + 1 : cell.row.index) : "column-".concat(columnIndex < instance.columns.length - 1 ? columnIndex + 1 : columnIndex, "-row-").concat(cell.row.index);
206
+ return newCellId;
207
+ };
208
+
209
+ var handleKeyDown = function handleKeyDown(event) {
210
+ var key = event.key;
211
+
212
+ switch (key) {
213
+ // Save cell contents to data
214
+ case 'Tab':
215
+ case 'Enter':
216
+ {
217
+ if (inEditMode) {
218
+ // Dropdown saves are handled in the Dropdown's/DatePicker's onChange prop
219
+ if (type === 'selection' || type === 'date') {
220
+ return;
221
+ }
222
+
223
+ var _ref4 = config || {},
224
+ validator = _ref4.validator;
225
+
226
+ var isInvalid = validator === null || validator === void 0 ? void 0 : validator(cellValue); // If an invalid state is detected, Tab/Enter should not do anything
227
+ // until the input has a valid state once again
228
+
229
+ if (isInvalid) {
230
+ return;
231
+ }
232
+
233
+ var newCellId = getNewCellId(key);
234
+ saveCellData(cellValue);
235
+ setInitialValue(cellValue);
236
+ dispatch({
237
+ type: 'EXIT_EDIT_MODE',
238
+ payload: newCellId
239
+ });
240
+ setInEditMode(false);
241
+ sendFocusBackToGrid();
242
+ }
243
+
244
+ break;
245
+ }
246
+
247
+ case 'Escape':
248
+ {
249
+ if (inEditMode) {
250
+ dispatch({
251
+ type: 'EXIT_EDIT_MODE',
252
+ payload: cellId
253
+ });
254
+ setCellValue(initialValue);
255
+ saveCellData(initialValue);
256
+ setInEditMode(false);
257
+ sendFocusBackToGrid();
258
+ }
259
+
260
+ break;
261
+ }
262
+
263
+ default:
264
+ return;
265
+ }
266
+ };
267
+
268
+ var addActiveState = function addActiveState() {
269
+ dispatch({
270
+ type: 'UPDATE_ACTIVE_CELL_ID',
271
+ payload: cellId
272
+ });
273
+ };
274
+
275
+ var renderDropdownItem = function renderDropdownItem(item) {
276
+ var includesIcon = !!(item !== null && item !== void 0 && item.icon);
277
+ return includesIcon ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(item.icon), /*#__PURE__*/React.createElement("span", {
278
+ className: cx("".concat(blockClass, "__inline-edit--select-item"))
279
+ }, item === null || item === void 0 ? void 0 : item.text)) : item === null || item === void 0 ? void 0 : item.text;
280
+ };
281
+
282
+ var handleTransformedItem = function handleTransformedItem(items) {
283
+ return items !== null && items !== void 0 && items.length && _typeof(items[0]) === 'object' ? function (item) {
284
+ return renderDropdownItem(item);
285
+ } : null;
286
+ };
287
+
288
+ var renderSelectCell = function renderSelectCell() {
289
+ var _ref5 = config || {},
290
+ inputProps = _ref5.inputProps;
291
+
292
+ return /*#__PURE__*/React.createElement(Dropdown, _extends({
293
+ id: cellId,
294
+ label: cellLabel || 'Dropdown menu options',
295
+ ariaLabel: cellLabel || 'Dropdown menu options'
296
+ }, inputProps, {
297
+ hideLabel: true,
298
+ style: {
299
+ width: cell.column.totalWidth
300
+ },
301
+ className: cx("".concat(blockClass, "__inline-edit--select"), _defineProperty({}, "".concat(blockClass, "__inline-edit--select-").concat(rowSize), rowSize)),
302
+ items: (inputProps === null || inputProps === void 0 ? void 0 : inputProps.items) || [],
303
+ initialSelectedItem: cell.value,
304
+ itemToElement: handleTransformedItem(inputProps === null || inputProps === void 0 ? void 0 : inputProps.items),
305
+ renderSelectedItem: handleTransformedItem(inputProps === null || inputProps === void 0 ? void 0 : inputProps.items),
306
+ onChange: function onChange(item) {
307
+ var _inputProps$onChange;
308
+
309
+ var newCellId = getNewCellId('Enter');
310
+ saveCellData(item.selectedItem);
311
+ setCellValue(item.selectedItem);
312
+ dispatch({
313
+ type: 'EXIT_EDIT_MODE',
314
+ payload: newCellId
315
+ });
316
+ setInEditMode(false);
317
+ sendFocusBackToGrid();
318
+ inputProps === null || inputProps === void 0 ? void 0 : (_inputProps$onChange = inputProps.onChange) === null || _inputProps$onChange === void 0 ? void 0 : _inputProps$onChange.call(inputProps, item.selectedItem);
319
+ },
320
+ downshiftProps: {
321
+ onStateChange: function onStateChange(downshiftState) {
322
+ var _ref6 = downshiftState || {},
323
+ isOpen = _ref6.isOpen; // !isOpen does not work in this case because a state change occurs on hover of the
324
+ // menu items and isOpen is changed to undefined which causes dispatch to be called unexpectedly
325
+
326
+
327
+ if (isOpen === false) {
328
+ dispatch({
329
+ type: 'EXIT_EDIT_MODE',
330
+ payload: cellId
331
+ });
332
+ setInEditMode(false);
333
+ sendFocusBackToGrid();
334
+ }
335
+ }
336
+ },
337
+ ref: dropdownRef
338
+ }));
339
+ };
340
+
341
+ var setRenderIcon = function setRenderIcon() {
342
+ if (type === 'text') {
343
+ return function (props) {
344
+ return /*#__PURE__*/React.createElement(Edit, _extends({
345
+ size: 16
346
+ }, props));
347
+ };
348
+ }
349
+
350
+ if (type === 'number') {
351
+ return function (props) {
352
+ return /*#__PURE__*/React.createElement(CaretSort, _extends({
353
+ size: 16
354
+ }, props));
355
+ };
356
+ }
357
+
358
+ if (type === 'selection') {
359
+ return function (props) {
360
+ return /*#__PURE__*/React.createElement(ChevronDown, _extends({
361
+ size: 16
362
+ }, props));
363
+ };
364
+ }
365
+
366
+ if (type === 'date') {
367
+ return function (props) {
368
+ return /*#__PURE__*/React.createElement(Calendar, _extends({
369
+ size: 16
370
+ }, props));
371
+ };
372
+ }
373
+ };
374
+
375
+ var renderDateCell = function renderDateCell() {
376
+ var _config$inputProps, _outerButtonElement$c;
377
+
378
+ var datePickerPreparedProps = prepareProps(config.inputProps, ['datePickerInputProps']);
379
+ var datePickerInputProps = config === null || config === void 0 ? void 0 : (_config$inputProps = config.inputProps) === null || _config$inputProps === void 0 ? void 0 : _config$inputProps.datePickerInputProps;
380
+ return /*#__PURE__*/React.createElement(DatePicker, _extends({}, datePickerPreparedProps, {
381
+ appendTo: outerButtonElement === null || outerButtonElement === void 0 ? void 0 : (_outerButtonElement$c = outerButtonElement.current) === null || _outerButtonElement$c === void 0 ? void 0 : _outerButtonElement$c.parentElement,
382
+ ref: datePickerRef,
383
+ style: {
384
+ width: cell.column.totalWidth
385
+ },
386
+ datePickerType: "single",
387
+ className: cx("".concat(blockClass, "__inline-edit--date"), _defineProperty({}, "".concat(blockClass, "__inline-edit--date-").concat(rowSize), rowSize)),
388
+ onChange: function onChange(newDate) {
389
+ var _datePickerPreparedPr;
390
+
391
+ var newDateObj = newDate[0];
392
+ datePickerPreparedProps === null || datePickerPreparedProps === void 0 ? void 0 : (_datePickerPreparedPr = datePickerPreparedProps.onChange) === null || _datePickerPreparedPr === void 0 ? void 0 : _datePickerPreparedPr.call(datePickerPreparedProps, newDateObj, cell);
393
+ var newCellId = getNewCellId('Enter');
394
+ saveCellData(newDateObj);
395
+ setCellValue(newDateObj); // To handle the interaction of the masked input when the DatePicker and updating
396
+
397
+ setTimeout(function () {
398
+ setInEditMode(false);
399
+ sendFocusBackToGrid();
400
+ dispatch({
401
+ type: 'EXIT_EDIT_MODE',
402
+ payload: newCellId
403
+ });
404
+ }, 1);
405
+ },
406
+ value: cell.value
407
+ }), /*#__PURE__*/React.createElement(DatePickerInput, _extends({}, datePickerInputProps, {
408
+ style: {
409
+ position: 'static'
410
+ },
411
+ placeholder: (datePickerInputProps === null || datePickerInputProps === void 0 ? void 0 : datePickerInputProps.placeholder) || 'mm/dd/yyyy',
412
+ labelText: (datePickerInputProps === null || datePickerInputProps === void 0 ? void 0 : datePickerInputProps.labelText) || cellLabel || 'Set date',
413
+ id: "".concat(blockClass, "__inline-edit--date-picker--").concat(cell.row.index),
414
+ hideLabel: true
415
+ })));
416
+ }; // Ensures that months and days are all 2 digits, prefixes 0 if `num` is a single digit
417
+
418
+
419
+ var padTo2Digits = function padTo2Digits(num) {
420
+ return num.toString().padStart(2, '0');
421
+ };
422
+
423
+ var buildDate = function buildDate(value) {
424
+ var _config$inputProps2;
425
+
426
+ var dateFormat = config === null || config === void 0 ? void 0 : (_config$inputProps2 = config.inputProps) === null || _config$inputProps2 === void 0 ? void 0 : _config$inputProps2.dateFormat;
427
+
428
+ if (value instanceof Date) {
429
+ var maskedFullYear = value.getFullYear();
430
+ var maskedMonth = padTo2Digits(value.getMonth() + 1);
431
+ var maskedDay = padTo2Digits(value.getDate());
432
+
433
+ if (dateFormat === 'm/d/Y' || value === 'm/d/y') {
434
+ return [maskedMonth, maskedDay, maskedFullYear].join('/');
435
+ }
436
+
437
+ if (dateFormat === 'd/m/Y' || dateFormat === 'd/m/y' || dateFormat === undefined) {
438
+ return [maskedDay, maskedMonth, maskedFullYear].join('/');
439
+ }
440
+ } else {
441
+ return value;
442
+ }
443
+
444
+ return null;
445
+ };
446
+
447
+ var renderNumberInput = function renderNumberInput() {
448
+ var _ref7 = config || {},
449
+ validator = _ref7.validator;
450
+
451
+ return /*#__PURE__*/React.createElement(NumberInput, _extends({
452
+ placeholder: placeholder,
453
+ label: cellLabel
454
+ }, inputProps, {
455
+ id: cellId,
456
+ hideLabel: true,
457
+ defaultValue: cellValue,
458
+ invalid: validator === null || validator === void 0 ? void 0 : validator(cellValue),
459
+ invalidText: (inputProps === null || inputProps === void 0 ? void 0 : inputProps.invalidText) || 'Provide missing invalidText',
460
+ onChange: function onChange(event, _ref8) {
461
+ var value = _ref8.value;
462
+ setCellValue(value);
463
+
464
+ if (inputProps.onChange) {
465
+ inputProps.onChange(value);
466
+ }
467
+ },
468
+ ref: numberInputRef
469
+ }));
470
+ };
471
+
472
+ var renderTextInput = function renderTextInput() {
473
+ var _ref9 = config || {},
474
+ validator = _ref9.validator;
475
+
476
+ var isInvalid = validator === null || validator === void 0 ? void 0 : validator(cellValue);
477
+ return /*#__PURE__*/React.createElement(TextInput, _extends({
478
+ labelText: cellLabel,
479
+ placeholder: placeholder
480
+ }, inputProps, {
481
+ id: cellId,
482
+ hideLabel: true,
483
+ defaultValue: cellValue,
484
+ invalid: isInvalid,
485
+ invalidText: (inputProps === null || inputProps === void 0 ? void 0 : inputProps.invalidText) || 'Provide missing invalidText',
486
+ onChange: function onChange(event) {
487
+ setCellValue(event.target.value);
488
+
489
+ if (inputProps.onChange) {
490
+ inputProps.onChange(event.target.value);
491
+ }
492
+ },
493
+ ref: textInputRef
494
+ }));
495
+ };
496
+
497
+ return (
498
+ /*#__PURE__*/
499
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
500
+ React.createElement("div", {
501
+ ref: outerButtonElement,
502
+ "data-cell-id": cellId,
503
+ "data-column-index": columnIndex,
504
+ "data-row-index": cell.row.index,
505
+ "data-disabled": nonEditCell,
506
+ "data-inline-type": type,
507
+ onClick: !nonEditCell ? handleInlineCellClick : addActiveState,
508
+ onKeyDown: !nonEditCell ? handleKeyDown : null,
509
+ className: cx("".concat(blockClass, "__inline-edit--outer-cell-button"), (_cx3 = {}, _defineProperty(_cx3, "".concat(blockClass, "__inline-edit--outer-cell-button--").concat(rowSize), rowSize), _defineProperty(_cx3, "".concat(blockClass, "__inline-edit--outer-cell-button--lg"), !rowSize), _defineProperty(_cx3, "".concat(blockClass, "__inline-edit--outer-cell-button--invalid"), config === null || config === void 0 ? void 0 : (_config$validator = config.validator) === null || _config$validator === void 0 ? void 0 : _config$validator.call(config, cellValue)), _cx3))
510
+ }, !inEditMode && /*#__PURE__*/React.createElement(InlineEditButton, {
511
+ isActiveCell: cellId === activeCellId,
512
+ renderIcon: setRenderIcon(),
513
+ label: type === 'selection' ? (_value$text = value === null || value === void 0 ? void 0 : value.text) !== null && _value$text !== void 0 ? _value$text : value : type === 'date' ? buildDate(value) : value,
514
+ labelIcon: (value === null || value === void 0 ? void 0 : value.icon) || null,
515
+ placeholder: placeholder,
516
+ tabIndex: tabIndex,
517
+ nonEditCell: nonEditCell,
518
+ columnConfig: cell.column,
519
+ totalInlineEditColumns: totalInlineEditColumns,
520
+ totalColumns: totalColumns,
521
+ type: type
522
+ }), !nonEditCell && inEditMode && cellId === activeCellId && /*#__PURE__*/React.createElement(React.Fragment, null, type === 'text' && renderTextInput(), type === 'number' && renderNumberInput(), type === 'selection' && renderSelectCell(), type === 'date' && renderDateCell()))
523
+ );
524
+ };
525
+ InlineEditCell.propTypes = {
526
+ cell: PropTypes.object,
527
+ config: PropTypes.object,
528
+ instance: PropTypes.shape({
529
+ columns: PropTypes.arrayOf(PropTypes.object),
530
+ onDataUpdate: PropTypes.func,
531
+ rows: PropTypes.arrayOf(PropTypes.object),
532
+ rowSize: PropTypes.string,
533
+ tableId: PropTypes.string
534
+ }),
535
+ nonEditCell: PropTypes.bool,
536
+ placeholder: PropTypes.string,
537
+ tabIndex: PropTypes.number,
538
+ totalInlineEditColumns: PropTypes.number,
539
+ type: PropTypes.oneOf(['text', 'number', 'selection', 'date']),
540
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.object])
541
+ };
@@ -0,0 +1 @@
1
+ export { InlineEditCell } from './InlineEditCell';
@@ -0,0 +1,112 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+
4
+ 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; }
5
+
6
+ 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) { _defineProperty(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; }
7
+
8
+ /**
9
+ * Copyright IBM Corp. 2022, 2022
10
+ *
11
+ * This source code is licensed under the Apache-2.0 license found in the
12
+ * LICENSE file in the root directory of this source tree.
13
+ */
14
+ import React, { createContext, useReducer } from 'react';
15
+ import PropTypes from 'prop-types';
16
+ import { returnUpdatedActiveCell } from './returnUpdatedActiveCell';
17
+ import { getCellIdAsObject } from './getCellIdAsObject';
18
+ export var InlineEditContext = /*#__PURE__*/createContext();
19
+
20
+ var inlineEditReducer = function inlineEditReducer(state, action) {
21
+ switch (action.type) {
22
+ case 'ADD_GRID_ACTIVE_FOCUS':
23
+ {
24
+ return _objectSpread(_objectSpread({}, state), {}, {
25
+ gridActive: true,
26
+ activeCellId: action.payload,
27
+ // set default active cell when grid receives focus
28
+ previousActiveCellId: null
29
+ });
30
+ }
31
+
32
+ case 'REMOVE_GRID_ACTIVE_FOCUS':
33
+ {
34
+ return _objectSpread(_objectSpread({}, state), {}, {
35
+ gridActive: false,
36
+ editId: null,
37
+ activeCellId: null,
38
+ previousActiveCellId: action.payload
39
+ });
40
+ }
41
+
42
+ case 'ENTER_EDIT_MODE':
43
+ {
44
+ return _objectSpread(_objectSpread({}, state), {}, {
45
+ activeCellId: action.payload.activeCellId,
46
+ editId: action.payload.editId
47
+ });
48
+ }
49
+
50
+ case 'EXIT_EDIT_MODE':
51
+ {
52
+ return _objectSpread(_objectSpread({}, state), {}, {
53
+ activeCellId: action.payload,
54
+ editId: null
55
+ });
56
+ }
57
+
58
+ case 'UPDATE_ACTIVE_CELL_ID':
59
+ {
60
+ var _action$payload = action.payload,
61
+ direction = _action$payload.direction,
62
+ oldId = _action$payload.oldId,
63
+ instance = _action$payload.instance;
64
+
65
+ if (!action.payload.direction) {
66
+ return _objectSpread(_objectSpread({}, state), {}, {
67
+ activeCellId: action.payload,
68
+ editId: null
69
+ });
70
+ }
71
+
72
+ if (direction && typeof direction === 'string') {
73
+ var activeCellCoords = getCellIdAsObject(oldId);
74
+ var totalVisibleColumns = instance.visibleColumns.filter(function (item) {
75
+ return item.id !== 'spacer';
76
+ });
77
+ return returnUpdatedActiveCell({
78
+ activeCellCoords: activeCellCoords,
79
+ direction: direction,
80
+ totalVisibleColumns: totalVisibleColumns,
81
+ state: state,
82
+ instance: instance
83
+ });
84
+ }
85
+
86
+ break;
87
+ }
88
+
89
+ default:
90
+ return state;
91
+ }
92
+ };
93
+
94
+ export var InlineEditProvider = function InlineEditProvider(_ref) {
95
+ var children = _ref.children;
96
+ var initialState = {};
97
+
98
+ var _useReducer = useReducer(inlineEditReducer, initialState),
99
+ _useReducer2 = _slicedToArray(_useReducer, 2),
100
+ state = _useReducer2[0],
101
+ dispatch = _useReducer2[1];
102
+
103
+ return /*#__PURE__*/React.createElement(InlineEditContext.Provider, {
104
+ value: {
105
+ state: state,
106
+ dispatch: dispatch
107
+ }
108
+ }, children);
109
+ };
110
+ InlineEditProvider.propTypes = {
111
+ children: PropTypes.element
112
+ };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ // Turns activeCellId into an object to be able to
8
+ // update cell coordinates more easily
9
+ export var getCellIdAsObject = function getCellIdAsObject(oldId) {
10
+ var oldIdArr = oldId.split('-');
11
+ var updatedOldValuesArray = oldIdArr.map(function (item) {
12
+ if (isNaN(item)) {
13
+ return item;
14
+ }
15
+
16
+ return Number(item);
17
+ });
18
+ var indexArray = updatedOldValuesArray.filter(Number.isFinite);
19
+ var keyArray = updatedOldValuesArray.filter(function (item) {
20
+ return typeof item === 'string';
21
+ });
22
+ var activeCellCoords = {};
23
+ keyArray.forEach(function (element, index) {
24
+ activeCellCoords[element] = indexArray[index];
25
+ });
26
+ return activeCellCoords;
27
+ };
@@ -0,0 +1 @@
1
+ export { InlineEditProvider, InlineEditContext } from './InlineEditContext';