Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/components/fields/ArrayField.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
toIdSchema,
getDefaultRegistry,
} from "../../utils";
import { registryShape } from "../../types";

function ArrayFieldTitle({ TitleField, idSchema, title, required }) {
if (!title) {
Expand Down Expand Up @@ -649,14 +650,7 @@ if (process.env.NODE_ENV !== "production") {
disabled: PropTypes.bool,
readonly: PropTypes.bool,
autofocus: PropTypes.bool,
registry: PropTypes.shape({
widgets: PropTypes.objectOf(
PropTypes.oneOfType([PropTypes.func, PropTypes.object])
).isRequired,
fields: PropTypes.objectOf(PropTypes.func).isRequired,
definitions: PropTypes.object.isRequired,
formContext: PropTypes.object.isRequired,
}),
registry: registryShape,
};
}

Expand Down
10 changes: 2 additions & 8 deletions src/components/fields/BooleanField.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
optionsList,
getDefaultRegistry,
} from "../../utils";
import { registryShape } from "../../types";

function BooleanField(props) {
const {
Expand Down Expand Up @@ -59,14 +60,7 @@ if (process.env.NODE_ENV !== "production") {
disabled: PropTypes.bool,
readonly: PropTypes.bool,
autofocus: PropTypes.bool,
registry: PropTypes.shape({
widgets: PropTypes.objectOf(
PropTypes.oneOfType([PropTypes.func, PropTypes.object])
).isRequired,
fields: PropTypes.objectOf(PropTypes.func).isRequired,
definitions: PropTypes.object.isRequired,
formContext: PropTypes.object.isRequired,
}),
registry: registryShape,
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/components/fields/NumberField.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import PropTypes from "prop-types";

import { asNumber } from "../../utils";
import { registryShape } from "../../types";

function NumberField(props) {
const { StringField } = props.registry.fields;
Expand All @@ -15,6 +16,7 @@ function NumberField(props) {

if (process.env.NODE_ENV !== "production") {
NumberField.propTypes = {
registry: registryShape.isRequired,
schema: PropTypes.object.isRequired,
uiSchema: PropTypes.object,
idSchema: PropTypes.object,
Expand Down
10 changes: 2 additions & 8 deletions src/components/fields/ObjectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
retrieveSchema,
getDefaultRegistry,
} from "../../utils";
import { registryShape } from "../../types";

function DefaultObjectFieldTemplate(props) {
const { TitleField, DescriptionField } = props;
Expand Down Expand Up @@ -147,14 +148,7 @@ if (process.env.NODE_ENV !== "production") {
required: PropTypes.bool,
disabled: PropTypes.bool,
readonly: PropTypes.bool,
registry: PropTypes.shape({
widgets: PropTypes.objectOf(
PropTypes.oneOfType([PropTypes.func, PropTypes.object])
).isRequired,
fields: PropTypes.objectOf(PropTypes.func).isRequired,
definitions: PropTypes.object.isRequired,
formContext: PropTypes.object.isRequired,
}),
registry: registryShape,
};
}

Expand Down
13 changes: 2 additions & 11 deletions src/components/fields/SchemaField.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
isFilesArray,
deepEquals,
} from "../../utils";
import { registryShape } from "../../types";
import UnsupportedField from "./UnsupportedField";

const REQUIRED_FIELD_SYMBOL = "*";
Expand Down Expand Up @@ -288,17 +289,7 @@ if (process.env.NODE_ENV !== "production") {
idSchema: PropTypes.object,
formData: PropTypes.any,
errorSchema: PropTypes.object,
registry: PropTypes.shape({
widgets: PropTypes.objectOf(
PropTypes.oneOfType([PropTypes.func, PropTypes.object])
).isRequired,
fields: PropTypes.objectOf(PropTypes.func).isRequired,
definitions: PropTypes.object.isRequired,
ArrayFieldTemplate: PropTypes.func,
ObjectFieldTemplate: PropTypes.func,
FieldTemplate: PropTypes.func,
formContext: PropTypes.object.isRequired,
}),
registry: registryShape,
};
}

Expand Down
10 changes: 2 additions & 8 deletions src/components/fields/StringField.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
optionsList,
getDefaultRegistry,
} from "../../utils";
import { registryShape } from "../../types";

function StringField(props) {
const {
Expand Down Expand Up @@ -64,14 +65,7 @@ if (process.env.NODE_ENV !== "production") {
onBlur: PropTypes.func,
onFocus: PropTypes.func,
formData: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
registry: PropTypes.shape({
widgets: PropTypes.objectOf(
PropTypes.oneOfType([PropTypes.func, PropTypes.object])
).isRequired,
fields: PropTypes.objectOf(PropTypes.func).isRequired,
definitions: PropTypes.object.isRequired,
formContext: PropTypes.object.isRequired,
}),
registry: registryShape,
formContext: PropTypes.object.isRequired,
required: PropTypes.bool,
disabled: PropTypes.bool,
Expand Down
3 changes: 3 additions & 0 deletions src/components/widgets/AltDateTimeWidget.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import React from "react";
import PropTypes from "prop-types";

import { registryShape } from "../../types";

function AltDateTimeWidget(props) {
const { AltDateWidget } = props.registry.widgets;
return <AltDateWidget time {...props} />;
}

if (process.env.NODE_ENV !== "production") {
AltDateTimeWidget.propTypes = {
registry: registryShape.isRequired,
schema: PropTypes.object.isRequired,
id: PropTypes.string.isRequired,
value: PropTypes.string,
Expand Down
2 changes: 2 additions & 0 deletions src/components/widgets/AltDateWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from "react";
import PropTypes from "prop-types";

import { shouldRender, parseDateString, toDateString, pad } from "../../utils";
import { registryShape } from "../../types";

function rangeOptions(start, stop) {
let options = [];
Expand Down Expand Up @@ -155,6 +156,7 @@ class AltDateWidget extends Component {

if (process.env.NODE_ENV !== "production") {
AltDateWidget.propTypes = {
registry: registryShape.isRequired,
schema: PropTypes.object.isRequired,
id: PropTypes.string.isRequired,
value: PropTypes.string,
Expand Down
3 changes: 3 additions & 0 deletions src/components/widgets/ColorWidget.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import React from "react";
import PropTypes from "prop-types";

import { registryShape } from "../../types";

function ColorWidget(props) {
const { disabled, readonly, registry: { widgets: { BaseInput } } } = props;
return <BaseInput type="color" {...props} disabled={disabled || readonly} />;
}

if (process.env.NODE_ENV !== "production") {
ColorWidget.propTypes = {
registry: registryShape.isRequired,
schema: PropTypes.object.isRequired,
id: PropTypes.string.isRequired,
value: PropTypes.string,
Expand Down
3 changes: 3 additions & 0 deletions src/components/widgets/DateTimeWidget.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from "react";
import PropTypes from "prop-types";

import { pad } from "../../utils";
import { registryShape } from "../../types";

export function utcToLocal(jsonDate) {
if (!jsonDate) {
Expand Down Expand Up @@ -46,6 +48,7 @@ function DateTimeWidget(props) {

if (process.env.NODE_ENV !== "production") {
DateTimeWidget.propTypes = {
registry: registryShape.isRequired,
value: PropTypes.string,
};
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/widgets/DateWidget.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from "react";
import PropTypes from "prop-types";

import { registryShape } from "../../types";

function DateWidget(props) {
const { onChange, registry: { widgets: { BaseInput } } } = props;
return (
Expand All @@ -14,6 +16,7 @@ function DateWidget(props) {

if (process.env.NODE_ENV !== "production") {
DateWidget.propTypes = {
registry: registryShape.isRequired,
value: PropTypes.string,
};
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/widgets/EmailWidget.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import React from "react";
import PropTypes from "prop-types";

import { registryShape } from "../../types";

function EmailWidget(props) {
const { BaseInput } = props.registry.widgets;
return <BaseInput type="email" {...props} />;
}

if (process.env.NODE_ENV !== "production") {
EmailWidget.propTypes = {
registry: registryShape.isRequired,
value: PropTypes.string,
};
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/widgets/PasswordWidget.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import React from "react";
import PropTypes from "prop-types";

import { registryShape } from "../../types";

function PasswordWidget(props) {
const { BaseInput } = props.registry.widgets;
return <BaseInput type="password" {...props} />;
}

if (process.env.NODE_ENV !== "production") {
PasswordWidget.propTypes = {
registry: registryShape.isRequired,
value: PropTypes.string,
};
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/widgets/RangeWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import PropTypes from "prop-types";

import { rangeSpec } from "../../utils";
import { registryShape } from "../../types";

function RangeWidget(props) {
const { schema, value, registry: { widgets: { BaseInput } } } = props;
Expand All @@ -15,6 +16,7 @@ function RangeWidget(props) {

if (process.env.NODE_ENV !== "production") {
RangeWidget.propTypes = {
registry: registryShape.isRequired,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
};
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/widgets/TextWidget.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import React from "react";
import PropTypes from "prop-types";

import { registryShape } from "../../types";

function TextWidget(props) {
const { BaseInput } = props.registry.widgets;
return <BaseInput {...props} />;
}

if (process.env.NODE_ENV !== "production") {
TextWidget.propTypes = {
registry: registryShape.isRequired,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
};
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/widgets/URLWidget.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import React from "react";
import PropTypes from "prop-types";

import { registryShape } from "../../types";

function URLWidget(props) {
const { BaseInput } = props.registry.widgets;
return <BaseInput type="url" {...props} />;
}

if (process.env.NODE_ENV !== "production") {
URLWidget.propTypes = {
registry: registryShape.isRequired,
value: PropTypes.string,
};
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/widgets/UpDownWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import PropTypes from "prop-types";

import { rangeSpec } from "../../utils";
import { registryShape } from "../../types";

function UpDownWidget(props) {
const { registry: { widgets: { BaseInput } } } = props;
Expand All @@ -10,6 +11,7 @@ function UpDownWidget(props) {

if (process.env.NODE_ENV !== "production") {
UpDownWidget.propTypes = {
registry: registryShape.isRequired,
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
};
}
Expand Down
13 changes: 13 additions & 0 deletions src/types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import PropTypes from "prop-types";

const { func, object, objectOf, oneOfType, shape } = PropTypes;

export const registryShape = shape({
widgets: objectOf(oneOfType([func, object])).isRequired,
fields: objectOf(func).isRequired,
definitions: object.isRequired,
formContext: object.isRequired,
ArrayFieldTemplate: func,
ObjectFieldTemplate: func,
FieldTemplate: func,
});