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

Material UI 5 Adapter #1054

Closed
guyathomas opened this issue Oct 20, 2021 · 22 comments · Fixed by #1091
Closed

Material UI 5 Adapter #1054

guyathomas opened this issue Oct 20, 2021 · 22 comments · Fixed by #1091
Assignees
Labels
Type: Feature New features and feature requests
Milestone

Comments

@guyathomas
Copy link

Material UI 5 is finally out of Alpha and it would be great to leverage it.

https://mui.com/getting-started/usage/

@guyathomas guyathomas changed the title Material UI 5 Material UI 5 Adapter Oct 20, 2021
@Monteth Monteth self-assigned this Oct 21, 2021
@Monteth Monteth added the Type: Feature New features and feature requests label Oct 21, 2021
@Monteth Monteth added this to Needs triage in Open Source (migrated) via automation Oct 21, 2021
@Monteth
Copy link
Member

Monteth commented Oct 21, 2021

Hi @guyathomas,
Thank you for submitting your proposal. According to the npm download data, the Material UI theme is one of the most popular themes in uniforms, so we definitely want to introduce its newest version in the future.
For now, we are looking for volunteers, so if you are using Material UI 5, or just want to help us please feel free to start the implementation, we can offer our support.

@Monteth Monteth moved this from Needs triage to To do in Open Source (migrated) Oct 21, 2021
@Monteth Monteth moved this from To do to In progress in Open Source (migrated) Nov 10, 2021
@radekmie
Copy link
Contributor

(We've had a team discussion about this issue, and here are the notes.)

  • We'd like to have an MUI (a.k.a. Material UI 5) theme.
  • @Monteth will post the initial draft of the time as soon as possible.
  • @wadamek65 will probably overtake the integration.

@Floriferous
Copy link
Contributor

meme

(I know I should just write a PR myself, but that's how I feel right now ;) )

@boertel
Copy link

boertel commented Jan 28, 2022

We did it here: https://github.com/comediadesign/uniforms-mui-5 mostly fixing imports and props but also remove the tests since we didn't bother migrating all of them 😬 I've been using it for 2 months, and we didn't have any issues with it (yet...)

@radekmie
Copy link
Contributor

That's great @boertel! We have a meeting today and we'll check out your package. Would you be interested in maintaining it yourself, or maybe transfer it here?

@boertel
Copy link

boertel commented Jan 28, 2022

I'm a contractor working on a project so I don't see myself maintaining it but I'm happy to transfer it!

@radekmie radekmie added this to the v3.x milestone Feb 3, 2022
@radekmie
Copy link
Contributor

radekmie commented Feb 4, 2022

We'll try the codemod first and if it'll take too much time, we'll ask you for help.

Separately, we'll contact you about the package name on npm later.

@wadamek65 wadamek65 self-assigned this Feb 11, 2022
@wadamek65
Copy link
Contributor

@Floriferous @guyathomas @boertel Just FYI: We have started working on implementing MUI v5 theme in uniforms. So far the codemod has worked really well and a large portion of work is already done. We will be posting updates on our progress as we go.

@wadamek65 wadamek65 linked a pull request Feb 25, 2022 that will close this issue
5 tasks
@vcardins
Copy link
Contributor

vcardins commented Apr 4, 2022

Any update on this progress?

@wadamek65
Copy link
Contributor

@vcardins You can track the exact progress on the draft PR submitted here: #1091. The core of the theme is done but we're still working on polishing the theme before releasing it. I hope we will be done with everything in the upcoming few weeks but only time will tell.

@minhna
Copy link

minhna commented May 17, 2022

@wadamek65 How is it going?

@wadamek65
Copy link
Contributor

@wadamek65 The PR is finished and awaiting reviews and testing. Feel free to review it yourself if you'd like to participate and help us out!

@minhna
Copy link

minhna commented May 19, 2022

@wadamek65 Thank you for your update.
I tried to clone the repository then installed the uniforms-mui package from the directory but then when I tried to start the app, it said

Error: Cannot find module '/home/minhna/WORKS/Mike/settler/se2-admin/node_modules/uniforms-mui/cjs/index.js'. Please verify that the package.json has a valid "main" entry

I check the node_modules/uniforms-mui directory, cjs and esm dir are missing. Do I need to run some build commands before?

@minhna
Copy link

minhna commented May 19, 2022

@wadamek65 I've got it. I need to run npm install in the root directory first then it will run the tsc --build --incremental tsconfig.build.json command.

@minhna
Copy link

minhna commented May 19, 2022

then I had this error:

Uncaught Invariant Violation: useForm must be used within a form.
    at invariant (/node_modules/invariant/browser.js:46:15)
    at useForm (/node_modules/uniforms/esm/useForm.js:14:5)
    at useField (/node_modules/uniforms/esm/useField.js:30:21)
    at Field (/node_modules/uniforms/esm/connectField.js:43:39)

I works well with the uniforms-material package

@wadamek65
Copy link
Contributor

@minhna Sounds like it might be an issue with a duplicate version of the package installed. Please try cleaning all node_modules and reinstalling them.

@minhna
Copy link

minhna commented May 19, 2022

@wadamek65 I tried but it didn't solve the problem.
The error only occurred with the fields I defined with connnectField function.
for example:

import React from 'react'
import PropTypes from 'prop-types'
import { connectField } from 'uniforms'
import { FormControl, InputLabel, Input, InputAdornment } from '@mui/material'
import numeral from 'numeral'

function CostField({ onChange, value, name, label }) {
  const [newValue, setNewValue] = React.useState(value)

  const handleChange = (_value) => {
    setNewValue(_value)
    onChange(numeral(_value).value())
  }

  return (
    <FormControl fullWidth style={{ marginTop: '1em' }}>
      <InputLabel htmlFor={`cost-adorment-${name}`}>{label}</InputLabel>
      <Input
        id={`cost-adorment-${name}`}
        value={newValue ? numeral(newValue).format('0,0') : ''}
        onChange={(e) => handleChange(e.target.value)}
        startAdornment={<InputAdornment position="start">$</InputAdornment>}
      />
    </FormControl>
  )
}

CostField.propTypes = {
  onChange: PropTypes.func.isRequired,
  value: PropTypes.number,
  name: PropTypes.string.isRequired,
  label: PropTypes.string.isRequired,
}

export default connectField(CostField)

and defind the schema

import { SimpleSchema2Bridge } from 'uniforms-bridge-simple-schema-2'
import CostField from 'ABOVE_FILE_LOCATION'
...
const listingSchema = new SimpleSchema2Bridge(
    new SimpleSchema({
      transactionType: {
        type: String,
        allowedValues: Object.keys(CONSTANTS.TRANSACTION_TYPE),

        uniforms: {
          transform: (value) => {
            return CONSTANTS.TRANSACTION_TYPE[value]
          },
        },
      },
      referralSource: { type: String, label: 'Referral Source', optional: true },
       cost: {
         type: Number,
         label: 'Cost of conveyancing (including GST)',
         optional: true,
         uniforms: { component: CostField },
       },
    })
  )

...

  return (
  <AutoForm schema={listingSchema} model={listing} onSubmit={handleSubmit}>
    <AutoFields />
  </AutoForm>
  )

@radekmie
Copy link
Contributor

@minhna Installing uniforms locally from the repo may be a problem, just as you saw. Until we update the documentation on that, you can try simply copy-pasting the theme's source into your project (assuming it's capable of working with TypeScript).

@minhna
Copy link

minhna commented May 30, 2022

Hi @radekmie Do you know when the pull request got merged? Thank you.

@radekmie
Copy link
Contributor

@minhna Definitely today, most likely in the next few hours. (I wanted to do it on Friday, but something came up.)

@minhna
Copy link

minhna commented May 30, 2022

@radekmie OMG. It's the best news today.

Open Source (migrated) automation moved this from In progress to Closed May 30, 2022
radekmie pushed a commit that referenced this issue May 30, 2022
@radekmie
Copy link
Contributor

Released in v3.10.0-rc.0.

@radekmie radekmie modified the milestones: v3.x, v3.10 Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New features and feature requests
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

8 participants