Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(DataGrid): implement types for DataGrid component #5257

Merged
merged 123 commits into from
Jun 6, 2024

Conversation

makafsal
Copy link
Contributor

@makafsal makafsal commented May 17, 2024

Closes #5175

What did you change?

  1. packages/ibm-products/src/components/Datagrid/Datagrid/Datagrid.tsx
  2. packages/ibm-products/src/components/Datagrid/Datagrid/DatagridContent.tsx
  3. packages/ibm-products/src/components/FilterSummary/FilterSummary.tsx
  4. packages/ibm-products/src/components/Datagrid/Datagrid/DatagridBody.tsx
  5. packages/ibm-products/src/components/Datagrid/Datagrid/DatagridHead.tsx
  6. packages/ibm-products/src/components/Datagrid/Datagrid/DatagridEmptyBody.tsx
  7. packages/ibm-products/src/components/Datagrid/Datagrid/DatagridVirtualBody.tsx
  8. packages/ibm-products/src/components/Datagrid/Datagrid/DatagridRefBody.tsx
  9. packages/ibm-products/src/components/Datagrid/Datagrid/DatagridSimpleBody.tsx
  10. packages/ibm-products/src/components/Datagrid/Datagrid/DatagridExpandedRow.tsx
  11. packages/ibm-products/src/components/Datagrid/Datagrid/DatagridHeaderRow.tsx
  12. packages/ibm-products/src/components/Datagrid/Datagrid/addons/Slug/DatagridSlug.tsx
  13. packages/ibm-products/src/components/Datagrid/Datagrid/DatagridRow.tsx
  14. packages/ibm-products/src/components/Datagrid/Datagrid/DatagridSelectAll.tsx
  15. packages/ibm-products/src/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.tsx
  16. packages/ibm-products/src/components/Datagrid/Datagrid/DatagridToolbar.tsx
  17. packages/ibm-products/src/components/Datagrid/Datagrid/DraggableElement.tsx

How did you test and verify your work?

Storybook
yarn test
Manual test

Copy link

netlify bot commented May 17, 2024

Deploy Preview for carbon-for-ibm-products ready!

Name Link
🔨 Latest commit cebcaf7
🔍 Latest deploy log https://app.netlify.com/sites/carbon-for-ibm-products/deploys/666146acb4c5860008583a9e
😎 Deploy Preview https://deploy-preview-5257--carbon-for-ibm-products.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@makafsal makafsal marked this pull request as ready for review May 20, 2024 10:54
@makafsal makafsal requested a review from a team as a code owner May 20, 2024 10:54
@makafsal makafsal requested review from emyarod and sangeethababu9223 and removed request for a team May 20, 2024 10:54
emyarod
emyarod previously approved these changes May 21, 2024
Copy link
Member

@emyarod emyarod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

makafsal and others added 18 commits June 5, 2024 11:24
chore: remove unwanted line

refactor: change react-table types version

refactor: change react-table types version

chore: remove unwanted line

refactor: change react-table types version

refactor: change react-table types version

chore: dummy commit to rerun jobs

chore: remove unwanted line

refactor: change react-table types version

refactor: change react-table types version

chore: remove unwanted line

refactor: change react-table types version

refactor: change react-table types version
…ign-system#5391)

* fix(Coachmark): ssr issues with htmlelement

* chore: remove unnecessary export
Co-authored-by: ibm-mend-app[bot] <142626574+ibm-mend-app[bot]@users.noreply.github.com>
Co-authored-by: Jeff Chew <[email protected]>
…rbon/feature-flags` (carbon-design-system#5204)

* feat(FeatureFlags): add feature flag support using carbon package

* chore: import feature flags and update lock

* chore: remove console log

* feat: use new feature flag system and add mdx docs

* chore: add annotation component to example story

* fix: remove utility hook from portal target hook

* chore: rename feature-flags file

* chore: remove console log

* chore: add feature flag component to editable cell stories

* fix: import feature flags file

* fix: import feature flags in jest setup

* fix: update tests

* chore: remove old generated feature flags

* chore: import feature flags

* fix: add feature flags file as side effect

* chore: add test file

* chore(feature-flags): rename to match carbon naming patterns

chore: dummy commit to rerun jobs

chore: remove unwanted line

refactor: change react-table types version

refactor: change react-table types version

chore: remove unwanted line

refactor: change react-table types version

refactor: change react-table types version

chore: dummy commit to rerun jobs

chore: remove unwanted line

refactor: change react-table types version

refactor: change react-table types version

chore: remove unwanted line

refactor: change react-table types version

refactor: change react-table types version

chore: dummy commit to rerun jobs

chore: remove unwanted line

refactor: change react-table types version

refactor: change react-table types version

chore: remove unwanted line

refactor: change react-table types version

refactor: change react-table types version

chore: dummy commit to rerun jobs

chore: remove unwanted line

refactor: change react-table types version

refactor: change react-table types version

chore: remove unwanted line

refactor: change react-table types version

refactor: change react-table types version
@makafsal makafsal enabled auto-merge June 6, 2024 11:01
@makafsal makafsal added this pull request to the merge queue Jun 6, 2024
Merged via the queue into carbon-design-system:main with commit de9c862 Jun 6, 2024
17 checks passed
@makafsal makafsal deleted the type-datagrid-50175 branch June 6, 2024 11:18
wkeese added a commit to wkeese/carbon-ibm-products that referenced this pull request Sep 25, 2024
This fixes some (but not all) of the Typescript issues with Datagrid.

Specifically:

1. Export DataGridState type.  Maybe other types should be exported too.
   Note that in other places the G is not capitalized, but it is for
   the type.

2. onAllRowSelect() is (and should be) optional.

3. Presumably you aren't required to have a button on your empty state
   screens, so "emptyStateAction" should be optional.

4. "allRowsLabel" should be optional because you only need it if your
   table has a "Select all" checkbox.  And also because it's optional
   in PropTypes.

5. Properties like "page" are only necessary if your table has pagination,
   so make UsePaginationInstanceProps props optional.

6. UseFiltersInstanceProps defines a bunch of weird and required properties like
   "preFilteredRows", "preFilteredFlatRows", "preFilteredRowsById".  AFAICT none
   of those are valid for DataGridState except for setFilter() and
   setAllFilters(), and even those should be optional.

7. The original DataGridState class extended both UseRowSelectInstanceProps and
   Pick<UseRowSelectInstanceProps<T>, 'toggleAllRowsSelected'>.  Obviously that
   doesn't make sense because of the redundancy.  But I'm not sure what does
   make sense.  AFAIK users don't directly defined functions like
   toggleRowSelected() or toggleAllRowsSelected()... but there is code that
   calls them.

This PR doesn't address the main issues with the types, where useDatagrid()
returns a TableInstance but Datagrid.datagridState is a DataGridState.

Further, I think maybe DataGridState needs to be split into two types.
Consider that:

1. The object passed to Datagrid.datagridState does not contain "row".
2. DataGridRow's props DO include "row".
3. Both Datagrid.datagridState and DataGridRow's props are defined as
   DataGridState.

Refs carbon-design-system#5257, carbon-design-system#6115.
github-merge-queue bot pushed a commit that referenced this pull request Oct 16, 2024
This fixes some (but not all) of the Typescript issues with Datagrid.

Specifically:

1. Export DataGridState type.  Maybe other types should be exported too.
   Note that in other places the G is not capitalized, but it is for
   the type.

2. onAllRowSelect() is (and should be) optional.

3. Presumably you aren't required to have a button on your empty state
   screens, so "emptyStateAction" should be optional.

4. "allRowsLabel" should be optional because you only need it if your
   table has a "Select all" checkbox.  And also because it's optional
   in PropTypes.

5. Properties like "page" are only necessary if your table has pagination,
   so make UsePaginationInstanceProps props optional.

6. UseFiltersInstanceProps defines a bunch of weird and required properties like
   "preFilteredRows", "preFilteredFlatRows", "preFilteredRowsById".  AFAICT none
   of those are valid for DataGridState except for setFilter() and
   setAllFilters(), and even those should be optional.

7. The original DataGridState class extended both UseRowSelectInstanceProps and
   Pick<UseRowSelectInstanceProps<T>, 'toggleAllRowsSelected'>.  Obviously that
   doesn't make sense because of the redundancy.  But I'm not sure what does
   make sense.  AFAIK users don't directly defined functions like
   toggleRowSelected() or toggleAllRowsSelected()... but there is code that
   calls them.

This PR doesn't address the main issues with the types, where useDatagrid()
returns a TableInstance but Datagrid.datagridState is a DataGridState.

Further, I think maybe DataGridState needs to be split into two types.
Consider that:

1. The object passed to Datagrid.datagridState does not contain "row".
2. DataGridRow's props DO include "row".
3. Both Datagrid.datagridState and DataGridRow's props are defined as
   DataGridState.

Refs #5257, #6115.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Typescript types to Datagrid
8 participants