Comments (12)
@Janpot What do you think about moving the useStorageStateBrowser
hook to @mui/utils
?
I think we have many utility hooks we use internally that our users could use.
We can create a separate package and docs for these hooks - e.g. @mui/hooks
.
This could also be an initiative under the MUI X product line - @mui/x-hooks
with more advanced utility hooks like useStorageStateBrowser
, useResizeObserver
, useTimeout
, useFirstRender
, useOnMount
, etc.
cc @joserodolfofreitas @oliviertassinari @mui/x
from mui-x.
For inspiration: In Toolpad we wrote a hook that handles initializing state from localstorage on the first render correctly (i.e. doesn't need an effect to run). It also syncs this state across tabs.
from mui-x.
Yes, I'll clean it up a bit and move to @mui/utils
👍
from mui-x.
To be noted that @mui/utils is a "private" npm package. Only MUI System and Base UI are supposed to import from it. This package exists so that MUI System doesn't have a dependency on Base UI but still able to use some of its logic to create components.
Just to note that this example is promoting @mui/utils
as a public package. (This is why we have it as a dependency in Toolpad, I never knew it wasn't meant to be public)
Other places where @mui/utils
seems to be endorsed in the docs as a public package:
visuallyHidden
https://mui.com/material-ui/icons/#semantic-iconsvisuallyHidden
https://mui.com/material-ui/migration/v5-component-changes/#remove-sronly-variantunstable_useForkRef
https://mui.com/base-ui/react-autocomplete/#using-a-portal (promoting anunstable_
export on an internal package 🙂 )
IMO, the @mui/utils
package is already de facto public. It would make more sense to mark everything in the package as unstable_
to signal to consumers that it's not following semver guarantees. It's more effective than documenting it in the docs or README, at least you notice it when vscode autoimports something from the @mui/utils
package.
from mui-x.
I don't think making it public is a good idea. The code in there is internal code that we need to share across our packages/repos, not code we want the public to consume. I think we should either clearly mark it as a private package or create a new one with a name like @mui/internals
. Then there is no issue with removing the unstable_
prefix and making breaking changes to the code, because it's an internal-only package. There is also nothing that prevents us from uncoupling the version number from the core's versionning scheme if we introduce breaking changes.
What would prevent us from following semver?
Nothing prevents us, it just adds overhead. It needs to be properly maintained, backwards compatibility needs to be guaranteed more tightly, and it needs to be documented.
I don't think semver implies we need to do all that. If it's an internal package we can have a meaningful (semver) version number while also not documenting it. Following semver doesn't imply we make the package public. We could also just leave it at version 0.x, which semver defines as basically "do anything you want" (point 4 of semver).
from mui-x.
Other places where @mui/utils seems to be endorsed in the docs as a public package:
@Janpot Yes, it's not great, this work was never prioritized.
The shaping page that centralizes the discussions on this topic: https://www.notion.so/mui-org/mui-utils-purpose-9a9fc9da3a004864b6c4e1f4d1f24f95.
from mui-x.
I ported the hook to @mui/utils
. For now with the purpose to only use it internally. If anyone has objections to this, please comment on the PR.
To build save/store grid state on top of this, it will need to be wrapped with parsing/serialization/validation logic. The hook doesn't mean to be opinionated about parsing, error handling and migrating stored values.
from mui-x.
To be noted that @mui/utils is a "private" npm package. Only MUI System and Base UI are supposed to import from it.
This package exists so that MUI System doesn't have a dependency on Base UI (would be weird, and isolate download npm stats) but still able to use some of its logic to create components.
from mui-x.
We did not close the discussion about MUI X using it
from mui-x.
To be noted that @mui/utils is a "private" npm package. Only MUI System and Base UI are supposed to import from it. This package exists so that MUI System doesn't have a dependency on Base UI but still able to use some of its logic to create components.
Just to note that this example is promoting
@mui/utils
as a public package. (This is why we have it as a dependency in Toolpad, I never knew it wasn't meant to be public)Other places where
@mui/utils
seems to be endorsed in the docs as a public package:
visuallyHidden
https://mui.com/material-ui/icons/#semantic-iconsvisuallyHidden
https://mui.com/material-ui/migration/v5-component-changes/#remove-sronly-variantunstable_useForkRef
https://mui.com/base-ui/react-autocomplete/#using-a-portal (promoting anunstable_
export on an internal package 🙂 )IMO, the
@mui/utils
package is already de facto public. It would make more sense to mark everything in the package asunstable_
to signal to consumers that it's not following semver guarantees. It's more effective than documenting it in the docs or README, at least you notice it when vscode autoimports something from the@mui/utils
package.
What would prevent us from following semver? Couldn't we make this public and follow best practices as well?
from mui-x.
What would prevent us from following semver?
Nothing prevents us, it just adds overhead. It needs to be properly maintained, backwards compatibility needs to be guaranteed more tightly, and it needs to be documented.
edit: To be clear, I interpreted the question as "what prevents us from treating @mui/utils
as an officially supported MUI product?".
from mui-x.
I think we should either clearly mark it as a private package or create a new one with a name like @mui/internals.
@romgrk this makes sense to me. Essentially have 2 packages,@mui/internals
which is mostly what is currently in the utils, and @mui/utils
which is public and contains things like useStorageStateBrowser
from Toolpad. I can see us adding more relevant utils for our users there, we are probably going to encounter some cases when we ship the data grid server-side integration (transformers, adaptors, etc.)
from mui-x.
Related Issues (20)
- [Clipboard Paste] clipboardPaste can bypass isCellEditable result. HOT 2
- [data grid] How to do confirmation before pasting? HOT 6
- [data grid] The `preProcessEditCellProps` params don't include the column field name HOT 3
- [DataGridPro] Make lazy loading API stable HOT 1
- [TreeView] Expose `expandNodeAncestors` method
- [data grid] Unable to print data containing image HOT 3
- [data grid] overflow issue when border is set to virtualScroller. HOT 9
- [data grid] Difference in cell tab&select behavior between v5 and v6 HOT 3
- [charts] Add RSC variant support
- [pickers] MultiSectionDigitalClock - iOS Style HOT 2
- [data grid] When changing `rows` and `columns` simultaneously, new `column` `valueGetter` will be invoked on previous rows. HOT 3
- [data grid] Columns selector is not recalculating re-enabled column sizes with flex property HOT 1
- [pickers] Unable to set timezone in DatePicker HOT 9
- [data grid] SingleSelect Horizontal alignment in Datagrid HOT 3
- [charts]Unique Key property LineChart error HOT 1
- [data grid] Add option to `GridTooldbar` to remove export option or to `GridToolbarExport` to pass custom export function HOT 2
- [docs] Demo QuickFilteringGrid crashes HOT 3
- [DateRangeCalendar] Calendar layout breaks when changing the `timezone` prop from UTC to something else HOT 2
- [pickers] Could not resolve "dayjs" imported by "@mui/x-date-pickers" HOT 3
- [pickers] Can't start project using MUI and Remix + Vite. SyntaxError: Named export 'AdapterLuxon' not found. HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mui-x.