-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make material-ui and fluent-ui pull TextWidget from the registry; rem…
…ove registry prop from <div> in TextWidget (#2515) * Make material-ui and fluent-ui pull TextWidget from the registry - In all the `TextWidget` wrappers, rather than directly import `TextWidget` from the source hierarchy, instead pull from the `registry.widgets` - This allows all of these `TextWidget` wrappers (like `EmailWidget`, etc...) to immediately use a custom `TextWidget` class - Added a new `Registry` type in the `core/index.d.ts` file, refactoring it from `FieldProps`, and adding it to `WidgetProps` as well - Needed to updated the snapshots for the `material-ui` tests for `Form` since registry is now part of the snapshot - Also needed to update `UpDownWidget.test.tst` to add a mock `registry` - Updated `packages/bootstrap-4/test/helpers/createMocks.ts` to add a mock `registry` * - Updated `TextWidget` to strip out `registry` so that it doesn't become part of `textFieldProps` which just seems wrong
- Loading branch information
1 parent
7897735
commit fa91f2b
Showing
20 changed files
with
74 additions
and
914 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
packages/fluent-ui/src/AltDateTimeWidget/AltDateTimeWidget.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
import React from "react"; | ||
import { WidgetProps } from "@rjsf/core"; | ||
import TextWidget from '../TextWidget'; | ||
|
||
export default (props: WidgetProps) => <TextWidget {...props} />; | ||
const AltDateTimeWidget = (props: WidgetProps) => { | ||
const { registry } = props; | ||
const { TextWidget } = registry.widgets; | ||
return ( | ||
<TextWidget {...props} /> | ||
); | ||
}; | ||
|
||
export default AltDateTimeWidget; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
import React from "react"; | ||
import { WidgetProps } from "@rjsf/core"; | ||
import TextWidget from '../TextWidget'; | ||
|
||
export default (props: WidgetProps) => <TextWidget {...props} />; | ||
const AltDateWidget = (props: WidgetProps) => { | ||
const { registry } = props; | ||
const { TextWidget } = registry.widgets; | ||
return ( | ||
<TextWidget {...props} /> | ||
); | ||
}; | ||
|
||
export default AltDateWidget; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 5 additions & 43 deletions
48
packages/material-ui/src/PasswordWidget/PasswordWidget.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,11 @@ | ||
import React from "react"; | ||
|
||
import TextField from "@material-ui/core/TextField"; | ||
import { TextWidgetProps } from "../TextWidget"; | ||
|
||
import { WidgetProps } from "@rjsf/core"; | ||
|
||
const PasswordWidget = ({ | ||
id, | ||
required, | ||
readonly, | ||
disabled, | ||
value, | ||
label, | ||
onFocus, | ||
onBlur, | ||
onChange, | ||
options, | ||
autofocus, | ||
schema, | ||
rawErrors = [], | ||
}: WidgetProps) => { | ||
const _onChange = ({ | ||
target: { value }, | ||
}: React.ChangeEvent<HTMLInputElement>) => | ||
onChange(value === "" ? options.emptyValue : value); | ||
const _onBlur = ({ target: { value } }: React.FocusEvent<HTMLInputElement>) => | ||
onBlur(id, value); | ||
const _onFocus = ({ | ||
target: { value }, | ||
}: React.FocusEvent<HTMLInputElement>) => onFocus(id, value); | ||
|
||
return ( | ||
<TextField | ||
id={id} | ||
label={label || schema.title} | ||
autoFocus={autofocus} | ||
required={required} | ||
disabled={disabled || readonly} | ||
type="password" | ||
value={value ? value : ""} | ||
error={rawErrors.length > 0} | ||
onFocus={_onFocus} | ||
onBlur={_onBlur} | ||
onChange={_onChange} | ||
/> | ||
); | ||
const PasswordWidget = (props: TextWidgetProps) => { | ||
const { registry } = props; | ||
const { TextWidget } = registry.widgets; | ||
return <TextWidget type="password" {...props} />; | ||
}; | ||
|
||
export default PasswordWidget; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.