fastapi-rtk 2.3.4 → 2.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.bundled/jsonforms/cjs/_virtual/index10.cjs +2 -2
- package/dist/.bundled/jsonforms/cjs/_virtual/index6.cjs +2 -2
- package/dist/.bundled/jsonforms/cjs/_virtual/index7.cjs +2 -2
- package/dist/.bundled/jsonforms/cjs/_virtual/index8.cjs +2 -2
- package/dist/.bundled/jsonforms/cjs/_virtual/index9.cjs +2 -2
- package/dist/.bundled/jsonforms/cjs/index.cjs +2 -0
- package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/MantineInputs/MantineBooleanInput.cjs +6 -1
- package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/MantineInputs/MantineDateInput.cjs +7 -2
- package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/MantineInputs/MantineDateTimeInput.cjs +7 -2
- package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/MantineInputs/MantineEnumInput.cjs +6 -1
- package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/MantineInputs/MantineNumberInput.cjs +7 -2
- package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/MantineInputs/MantineOneOfEnumInput.cjs +2 -8
- package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/MantineInputs/MantineTextInput.cjs +6 -1
- package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/MantineInputs/MantineTimeInput.cjs +7 -2
- package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/hooks/useNullableErrorProps.cjs +23 -0
- package/dist/.bundled/jsonforms/esm/_virtual/index10.mjs +2 -2
- package/dist/.bundled/jsonforms/esm/_virtual/index6.mjs +2 -2
- package/dist/.bundled/jsonforms/esm/_virtual/index7.mjs +2 -2
- package/dist/.bundled/jsonforms/esm/_virtual/index8.mjs +2 -2
- package/dist/.bundled/jsonforms/esm/_virtual/index9.mjs +2 -2
- package/dist/.bundled/jsonforms/esm/index.mjs +2 -0
- package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/MantineInputs/MantineBooleanInput.mjs +6 -1
- package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/MantineInputs/MantineDateInput.mjs +7 -2
- package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/MantineInputs/MantineDateTimeInput.mjs +7 -2
- package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/MantineInputs/MantineEnumInput.mjs +6 -1
- package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/MantineInputs/MantineNumberInput.mjs +7 -2
- package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/MantineInputs/MantineOneOfEnumInput.mjs +2 -8
- package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/MantineInputs/MantineTextInput.mjs +6 -1
- package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/MantineInputs/MantineTimeInput.mjs +7 -2
- package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/hooks/useNullableErrorProps.mjs +23 -0
- package/dist/.external/cjs/ajv@8.17.1/ajv/dist/compile/index.cjs +1 -1
- package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/applicator/index.cjs +1 -1
- package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/core/index.cjs +1 -1
- package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/format/index.cjs +1 -1
- package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/validation/index.cjs +1 -1
- package/dist/.external/esm/ajv@8.17.1/ajv/dist/compile/index.mjs +1 -1
- package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/applicator/index.mjs +1 -1
- package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/core/index.mjs +1 -1
- package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/format/index.mjs +1 -1
- package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/validation/index.mjs +1 -1
- package/dist/jsonforms/cjs/MantineInputs/MantineBooleanInput.cjs +6 -1
- package/dist/jsonforms/cjs/MantineInputs/MantineDateInput.cjs +7 -2
- package/dist/jsonforms/cjs/MantineInputs/MantineDateTimeInput.cjs +7 -2
- package/dist/jsonforms/cjs/MantineInputs/MantineEnumInput.cjs +6 -1
- package/dist/jsonforms/cjs/MantineInputs/MantineNumberInput.cjs +7 -2
- package/dist/jsonforms/cjs/MantineInputs/MantineOneOfEnumInput.cjs +2 -8
- package/dist/jsonforms/cjs/MantineInputs/MantineTextInput.cjs +6 -1
- package/dist/jsonforms/cjs/MantineInputs/MantineTimeInput.cjs +7 -2
- package/dist/jsonforms/cjs/hooks/useNullableErrorProps.cjs +23 -0
- package/dist/jsonforms/cjs/index.cjs +2 -0
- package/dist/jsonforms/esm/MantineInputs/MantineBooleanInput.mjs +6 -1
- package/dist/jsonforms/esm/MantineInputs/MantineDateInput.mjs +7 -2
- package/dist/jsonforms/esm/MantineInputs/MantineDateTimeInput.mjs +7 -2
- package/dist/jsonforms/esm/MantineInputs/MantineEnumInput.mjs +6 -1
- package/dist/jsonforms/esm/MantineInputs/MantineNumberInput.mjs +7 -2
- package/dist/jsonforms/esm/MantineInputs/MantineOneOfEnumInput.mjs +2 -8
- package/dist/jsonforms/esm/MantineInputs/MantineTextInput.mjs +6 -1
- package/dist/jsonforms/esm/MantineInputs/MantineTimeInput.mjs +7 -2
- package/dist/jsonforms/esm/hooks/useNullableErrorProps.mjs +23 -0
- package/dist/jsonforms/esm/index.mjs +2 -0
- package/dist/jsonforms/lib/hooks/useNullableErrorProps.d.ts +17 -0
- package/dist/jsonforms/lib/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ const useFileProps = require("./packages/jsonforms/src/hooks/useFileProps.cjs");
|
|
|
11
11
|
const useJsonProps = require("./packages/jsonforms/src/hooks/useJsonProps.cjs");
|
|
12
12
|
const useMultiSelectProps = require("./packages/jsonforms/src/hooks/useMultiSelectProps.cjs");
|
|
13
13
|
const useNumberProps = require("./packages/jsonforms/src/hooks/useNumberProps.cjs");
|
|
14
|
+
const useNullableErrorProps = require("./packages/jsonforms/src/hooks/useNullableErrorProps.cjs");
|
|
14
15
|
const useSelectProps = require("./packages/jsonforms/src/hooks/useSelectProps.cjs");
|
|
15
16
|
const useTextProps = require("./packages/jsonforms/src/hooks/useTextProps.cjs");
|
|
16
17
|
const useThemeCustomizer = require("./packages/jsonforms/src/hooks/useThemeCustomizer.cjs");
|
|
@@ -37,6 +38,7 @@ exports.useFileProps = useFileProps.useFileProps;
|
|
|
37
38
|
exports.useJsonProps = useJsonProps.useJsonProps;
|
|
38
39
|
exports.useMultiSelectProps = useMultiSelectProps.useMultiSelectProps;
|
|
39
40
|
exports.useNumberProps = useNumberProps.useNumberProps;
|
|
41
|
+
exports.useNullableErrorProps = useNullableErrorProps.useNullableErrorProps;
|
|
40
42
|
exports.useSelectProps = useSelectProps.useSelectProps;
|
|
41
43
|
exports.useTextProps = useTextProps.useTextProps;
|
|
42
44
|
exports.useThemeCustomizer = useThemeCustomizer.useThemeCustomizer;
|
package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/MantineInputs/MantineBooleanInput.cjs
CHANGED
|
@@ -7,13 +7,18 @@ const React = require("react");
|
|
|
7
7
|
const useBooleanProps = require("../hooks/useBooleanProps.cjs");
|
|
8
8
|
const useCommonProps = require("../hooks/useCommonProps.cjs");
|
|
9
9
|
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
10
|
+
const useNullableErrorProps = require("../hooks/useNullableErrorProps.cjs");
|
|
10
11
|
function MantineBooleanInput(props) {
|
|
11
12
|
var _a;
|
|
12
13
|
const { value, ...commonProps } = useCommonProps.useCommonProps(props);
|
|
13
14
|
const { path, schema, uischema } = props;
|
|
14
15
|
const format = ((_a = uischema.options) == null ? void 0 : _a.variant) ?? schema.format ?? "select";
|
|
15
16
|
const booleanProps = useBooleanProps.useBooleanProps(format, { value, onChange: commonProps.onChange });
|
|
16
|
-
const
|
|
17
|
+
const errorProps = useNullableErrorProps.useNullableErrorProps(value, commonProps.error, schema);
|
|
18
|
+
const componentProps = React.useMemo(
|
|
19
|
+
() => ({ ...commonProps, ...booleanProps, ...errorProps }),
|
|
20
|
+
[booleanProps, commonProps, errorProps]
|
|
21
|
+
);
|
|
17
22
|
const [Component, _props] = useContextProps.useContextProps("Boolean", path, componentProps, props);
|
|
18
23
|
if (!props.visible) {
|
|
19
24
|
return null;
|
package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/MantineInputs/MantineDateInput.cjs
CHANGED
|
@@ -7,11 +7,16 @@ const React = require("react");
|
|
|
7
7
|
const useCommonProps = require("../hooks/useCommonProps.cjs");
|
|
8
8
|
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
9
9
|
const useDateProps = require("../hooks/useDateProps.cjs");
|
|
10
|
+
const useNullableErrorProps = require("../hooks/useNullableErrorProps.cjs");
|
|
10
11
|
function MantineDateInput(props) {
|
|
11
12
|
const { value, ...commonProps } = useCommonProps.useCommonProps(props);
|
|
12
|
-
const { path } = props;
|
|
13
|
+
const { path, schema } = props;
|
|
13
14
|
const dateProps = useDateProps.useDateProps("date", true, { value, toggle: () => null, onChange: commonProps.onChange });
|
|
14
|
-
const
|
|
15
|
+
const errorProps = useNullableErrorProps.useNullableErrorProps(value, commonProps.error, schema);
|
|
16
|
+
const componentProps = React.useMemo(
|
|
17
|
+
() => ({ ...commonProps, ...dateProps, ...errorProps }),
|
|
18
|
+
[commonProps, dateProps, errorProps]
|
|
19
|
+
);
|
|
15
20
|
const [Component, _props] = useContextProps.useContextProps("Date", path, componentProps, props);
|
|
16
21
|
if (!props.visible) {
|
|
17
22
|
return null;
|
package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/MantineInputs/MantineDateTimeInput.cjs
CHANGED
|
@@ -8,9 +8,10 @@ const React = require("react");
|
|
|
8
8
|
const useCommonProps = require("../hooks/useCommonProps.cjs");
|
|
9
9
|
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
10
10
|
const useDateProps = require("../hooks/useDateProps.cjs");
|
|
11
|
+
const useNullableErrorProps = require("../hooks/useNullableErrorProps.cjs");
|
|
11
12
|
function MantineDateTimeInput(props) {
|
|
12
13
|
const { value, ...commonProps } = useCommonProps.useCommonProps(props);
|
|
13
|
-
const { path, uischema } = props;
|
|
14
|
+
const { path, schema, uischema } = props;
|
|
14
15
|
const { initialUTC: __initialUTC } = uischema.options || {};
|
|
15
16
|
const _dateProps = useDateProps.useDateProps("date-time", false, { value, toggle: () => null, onChange: commonProps.onChange });
|
|
16
17
|
const [, { initialUTC }] = useContextProps.useContextProps("DateTime", path, { ...commonProps, ..._dateProps }, props);
|
|
@@ -29,7 +30,11 @@ function MantineDateTimeInput(props) {
|
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
}, [value, setToLocal, setToUTC]);
|
|
32
|
-
const
|
|
33
|
+
const errorProps = useNullableErrorProps.useNullableErrorProps(value, commonProps.error, schema);
|
|
34
|
+
const componentProps = React.useMemo(
|
|
35
|
+
() => ({ ...commonProps, ...dateProps, ...errorProps }),
|
|
36
|
+
[commonProps, dateProps, errorProps]
|
|
37
|
+
);
|
|
33
38
|
const [Component, { initialUTC: _, ..._props }] = useContextProps.useContextProps("DateTime", path, componentProps, props);
|
|
34
39
|
if (!props.visible) {
|
|
35
40
|
return null;
|
package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/MantineInputs/MantineEnumInput.cjs
CHANGED
|
@@ -6,6 +6,7 @@ const core = require("@mantine/core");
|
|
|
6
6
|
const React = require("react");
|
|
7
7
|
const useCommonProps = require("../hooks/useCommonProps.cjs");
|
|
8
8
|
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
9
|
+
const useNullableErrorProps = require("../hooks/useNullableErrorProps.cjs");
|
|
9
10
|
const useSelectProps = require("../hooks/useSelectProps.cjs");
|
|
10
11
|
function MantineEnumInput(props) {
|
|
11
12
|
var _a;
|
|
@@ -13,7 +14,11 @@ function MantineEnumInput(props) {
|
|
|
13
14
|
const { path, schema, uischema } = props;
|
|
14
15
|
const isNative = (((_a = uischema.options) == null ? void 0 : _a.variant) ?? schema.format) === "native";
|
|
15
16
|
const selectProps = useSelectProps.useSelectProps(value, props.options, isNative, { onChange: commonProps.onChange });
|
|
16
|
-
const
|
|
17
|
+
const errorProps = useNullableErrorProps.useNullableErrorProps(value, commonProps.error, schema);
|
|
18
|
+
const componentProps = React.useMemo(
|
|
19
|
+
() => ({ ...commonProps, ...selectProps, ...errorProps }),
|
|
20
|
+
[commonProps, errorProps, selectProps]
|
|
21
|
+
);
|
|
17
22
|
const [Component, _props] = useContextProps.useContextProps("Enum", path, componentProps, props);
|
|
18
23
|
if (!props.visible) {
|
|
19
24
|
return null;
|
package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/MantineInputs/MantineNumberInput.cjs
CHANGED
|
@@ -6,16 +6,21 @@ const core = require("@mantine/core");
|
|
|
6
6
|
const React = require("react");
|
|
7
7
|
const useCommonProps = require("../hooks/useCommonProps.cjs");
|
|
8
8
|
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
9
|
+
const useNullableErrorProps = require("../hooks/useNullableErrorProps.cjs");
|
|
9
10
|
const useNumberProps = require("../hooks/useNumberProps.cjs");
|
|
10
11
|
const InnerMantineNumberInput = (props) => {
|
|
11
12
|
const { contextName, componentName, ...rest } = props;
|
|
12
13
|
const { value, ...commonProps } = useCommonProps.useCommonProps(rest);
|
|
13
|
-
const { path } = rest;
|
|
14
|
+
const { path, schema } = rest;
|
|
14
15
|
const numberProps = useNumberProps.useNumberProps(contextName.toLowerCase(), {
|
|
15
16
|
value,
|
|
16
17
|
onChange: commonProps.onChange
|
|
17
18
|
});
|
|
18
|
-
const
|
|
19
|
+
const errorProps = useNullableErrorProps.useNullableErrorProps(value, commonProps.error, schema);
|
|
20
|
+
const componentProps = React.useMemo(
|
|
21
|
+
() => ({ ...commonProps, ...numberProps, ...errorProps }),
|
|
22
|
+
[commonProps, numberProps, errorProps]
|
|
23
|
+
);
|
|
19
24
|
const [Component, _props] = useContextProps.useContextProps(contextName, path, componentProps, rest);
|
|
20
25
|
if (!rest.visible) {
|
|
21
26
|
return null;
|
package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/MantineInputs/MantineOneOfEnumInput.cjs
CHANGED
|
@@ -6,6 +6,7 @@ const core = require("@mantine/core");
|
|
|
6
6
|
const React = require("react");
|
|
7
7
|
const useCommonProps = require("../hooks/useCommonProps.cjs");
|
|
8
8
|
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
9
|
+
const useNullableErrorProps = require("../hooks/useNullableErrorProps.cjs");
|
|
9
10
|
const useSelectProps = require("../hooks/useSelectProps.cjs");
|
|
10
11
|
function MantineOneOfEnumInput(props) {
|
|
11
12
|
var _a;
|
|
@@ -13,14 +14,7 @@ function MantineOneOfEnumInput(props) {
|
|
|
13
14
|
const { path, schema, uischema } = props;
|
|
14
15
|
const isNative = (((_a = uischema.options) == null ? void 0 : _a.variant) ?? schema.format) === "native";
|
|
15
16
|
const selectProps = useSelectProps.useSelectProps(value, props.options, isNative, { onChange: commonProps.onChange });
|
|
16
|
-
const errorProps =
|
|
17
|
-
var _a2;
|
|
18
|
-
const isNull = value === null;
|
|
19
|
-
const error = (_a2 = commonProps.error) == null ? void 0 : _a2.filter(
|
|
20
|
-
(error2) => error2.key === "is a required property" || !isNull ? error2 : false
|
|
21
|
-
);
|
|
22
|
-
return (error == null ? void 0 : error.length) ? { error } : { error: isNull && commonProps.required ? "is a required property" : void 0 };
|
|
23
|
-
}, [commonProps.error, commonProps.required, value]);
|
|
17
|
+
const errorProps = useNullableErrorProps.useNullableErrorProps(value, commonProps.error, schema);
|
|
24
18
|
const componentProps = React.useMemo(
|
|
25
19
|
() => ({ ...commonProps, ...selectProps, ...errorProps }),
|
|
26
20
|
[commonProps, errorProps, selectProps]
|
package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/MantineInputs/MantineTextInput.cjs
CHANGED
|
@@ -6,12 +6,17 @@ const core = require("@mantine/core");
|
|
|
6
6
|
const React = require("react");
|
|
7
7
|
const useCommonProps = require("../hooks/useCommonProps.cjs");
|
|
8
8
|
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
9
|
+
const useNullableErrorProps = require("../hooks/useNullableErrorProps.cjs");
|
|
9
10
|
const useTextProps = require("../hooks/useTextProps.cjs");
|
|
10
11
|
function MantineTextInput(props) {
|
|
11
12
|
const { value, ...commonProps } = useCommonProps.useCommonProps(props);
|
|
12
13
|
const { path, schema } = props;
|
|
13
14
|
const textProps = useTextProps.useTextProps({ value, onChange: commonProps.onChange });
|
|
14
|
-
const
|
|
15
|
+
const errorProps = useNullableErrorProps.useNullableErrorProps(value, commonProps.error, schema);
|
|
16
|
+
const componentProps = React.useMemo(
|
|
17
|
+
() => ({ ...commonProps, ...textProps, ...errorProps }),
|
|
18
|
+
[commonProps, textProps, errorProps]
|
|
19
|
+
);
|
|
15
20
|
const [Component, _props] = useContextProps.useContextProps("Text", path, componentProps, props);
|
|
16
21
|
if (!props.visible) {
|
|
17
22
|
return null;
|
package/dist/.bundled/jsonforms/cjs/packages/jsonforms/src/MantineInputs/MantineTimeInput.cjs
CHANGED
|
@@ -6,11 +6,12 @@ const utils = require("fastapi-rtk/utils");
|
|
|
6
6
|
const React = require("react");
|
|
7
7
|
const useCommonProps = require("../hooks/useCommonProps.cjs");
|
|
8
8
|
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
9
|
+
const useNullableErrorProps = require("../hooks/useNullableErrorProps.cjs");
|
|
9
10
|
const useTimeProps = require("../hooks/useTimeProps.cjs");
|
|
10
11
|
function MantineTimeInput(props) {
|
|
11
12
|
var _a, _b;
|
|
12
13
|
const { value, ...commonProps } = useCommonProps.useCommonProps(props);
|
|
13
|
-
const { path } = props;
|
|
14
|
+
const { path, schema } = props;
|
|
14
15
|
const _timeProps = useTimeProps.useTimeProps({ value, onChange: commonProps.onChange, withSeconds: void 0 });
|
|
15
16
|
const [, { withSeconds }] = useContextProps.useContextProps("Time", path, { ...commonProps, ..._timeProps }, props);
|
|
16
17
|
const timeProps = useTimeProps.useTimeProps({
|
|
@@ -18,7 +19,11 @@ function MantineTimeInput(props) {
|
|
|
18
19
|
onChange: commonProps.onChange,
|
|
19
20
|
withSeconds: withSeconds ?? ((_b = (_a = props.uischema) == null ? void 0 : _a.options) == null ? void 0 : _b.withSeconds)
|
|
20
21
|
});
|
|
21
|
-
const
|
|
22
|
+
const errorProps = useNullableErrorProps.useNullableErrorProps(value, commonProps.error, schema);
|
|
23
|
+
const componentProps = React.useMemo(
|
|
24
|
+
() => ({ ...commonProps, ...timeProps, ...errorProps }),
|
|
25
|
+
[commonProps, timeProps, errorProps]
|
|
26
|
+
);
|
|
22
27
|
const [Component, _props] = useContextProps.useContextProps("Time", path, componentProps, props);
|
|
23
28
|
if (!props.visible) {
|
|
24
29
|
return null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const isSchemaTypeInclude = require("../utils/isSchemaTypeInclude.cjs");
|
|
5
|
+
const NULL_OPTION_ERRORS = /* @__PURE__ */ new Set([
|
|
6
|
+
"must be equal to one of the allowed values",
|
|
7
|
+
"must be equal to constant",
|
|
8
|
+
"must match exactly one schema in oneOf"
|
|
9
|
+
]);
|
|
10
|
+
const REQUIRED_ERROR = "is a required property";
|
|
11
|
+
function useNullableErrorProps(value, error, schema) {
|
|
12
|
+
return React.useMemo(() => {
|
|
13
|
+
if (value !== null && value !== "") {
|
|
14
|
+
return { error };
|
|
15
|
+
}
|
|
16
|
+
if (isSchemaTypeInclude.isSchemaTypeInclude(schema.type ?? "", "null")) {
|
|
17
|
+
const kept = error == null ? void 0 : error.filter((e) => !NULL_OPTION_ERRORS.has(e.key ?? ""));
|
|
18
|
+
return { error: (kept == null ? void 0 : kept.length) ? kept : void 0 };
|
|
19
|
+
}
|
|
20
|
+
return { error: REQUIRED_ERROR };
|
|
21
|
+
}, [error, schema.type, value]);
|
|
22
|
+
}
|
|
23
|
+
exports.useNullableErrorProps = useNullableErrorProps;
|
|
@@ -9,6 +9,7 @@ import { useFileProps } from "./packages/jsonforms/src/hooks/useFileProps.mjs";
|
|
|
9
9
|
import { useJsonProps } from "./packages/jsonforms/src/hooks/useJsonProps.mjs";
|
|
10
10
|
import { useMultiSelectProps } from "./packages/jsonforms/src/hooks/useMultiSelectProps.mjs";
|
|
11
11
|
import { useNumberProps } from "./packages/jsonforms/src/hooks/useNumberProps.mjs";
|
|
12
|
+
import { useNullableErrorProps } from "./packages/jsonforms/src/hooks/useNullableErrorProps.mjs";
|
|
12
13
|
import { useSelectProps } from "./packages/jsonforms/src/hooks/useSelectProps.mjs";
|
|
13
14
|
import { useTextProps } from "./packages/jsonforms/src/hooks/useTextProps.mjs";
|
|
14
15
|
import { useThemeCustomizer } from "./packages/jsonforms/src/hooks/useThemeCustomizer.mjs";
|
|
@@ -46,6 +47,7 @@ export {
|
|
|
46
47
|
useFileProps,
|
|
47
48
|
useJsonProps,
|
|
48
49
|
useMultiSelectProps,
|
|
50
|
+
useNullableErrorProps,
|
|
49
51
|
useNumberProps,
|
|
50
52
|
useSelectProps,
|
|
51
53
|
useTextProps,
|
package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/MantineInputs/MantineBooleanInput.mjs
CHANGED
|
@@ -5,13 +5,18 @@ import { useMemo } from "react";
|
|
|
5
5
|
import { useBooleanProps } from "../hooks/useBooleanProps.mjs";
|
|
6
6
|
import { useCommonProps } from "../hooks/useCommonProps.mjs";
|
|
7
7
|
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
8
|
+
import { useNullableErrorProps } from "../hooks/useNullableErrorProps.mjs";
|
|
8
9
|
function MantineBooleanInput(props) {
|
|
9
10
|
var _a;
|
|
10
11
|
const { value, ...commonProps } = useCommonProps(props);
|
|
11
12
|
const { path, schema, uischema } = props;
|
|
12
13
|
const format = ((_a = uischema.options) == null ? void 0 : _a.variant) ?? schema.format ?? "select";
|
|
13
14
|
const booleanProps = useBooleanProps(format, { value, onChange: commonProps.onChange });
|
|
14
|
-
const
|
|
15
|
+
const errorProps = useNullableErrorProps(value, commonProps.error, schema);
|
|
16
|
+
const componentProps = useMemo(
|
|
17
|
+
() => ({ ...commonProps, ...booleanProps, ...errorProps }),
|
|
18
|
+
[booleanProps, commonProps, errorProps]
|
|
19
|
+
);
|
|
15
20
|
const [Component, _props] = useContextProps("Boolean", path, componentProps, props);
|
|
16
21
|
if (!props.visible) {
|
|
17
22
|
return null;
|
package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/MantineInputs/MantineDateInput.mjs
CHANGED
|
@@ -5,11 +5,16 @@ import { useMemo } from "react";
|
|
|
5
5
|
import { useCommonProps } from "../hooks/useCommonProps.mjs";
|
|
6
6
|
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
7
7
|
import { useDateProps } from "../hooks/useDateProps.mjs";
|
|
8
|
+
import { useNullableErrorProps } from "../hooks/useNullableErrorProps.mjs";
|
|
8
9
|
function MantineDateInput(props) {
|
|
9
10
|
const { value, ...commonProps } = useCommonProps(props);
|
|
10
|
-
const { path } = props;
|
|
11
|
+
const { path, schema } = props;
|
|
11
12
|
const dateProps = useDateProps("date", true, { value, toggle: () => null, onChange: commonProps.onChange });
|
|
12
|
-
const
|
|
13
|
+
const errorProps = useNullableErrorProps(value, commonProps.error, schema);
|
|
14
|
+
const componentProps = useMemo(
|
|
15
|
+
() => ({ ...commonProps, ...dateProps, ...errorProps }),
|
|
16
|
+
[commonProps, dateProps, errorProps]
|
|
17
|
+
);
|
|
13
18
|
const [Component, _props] = useContextProps("Date", path, componentProps, props);
|
|
14
19
|
if (!props.visible) {
|
|
15
20
|
return null;
|
package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/MantineInputs/MantineDateTimeInput.mjs
CHANGED
|
@@ -6,9 +6,10 @@ import { useEffect, useMemo } from "react";
|
|
|
6
6
|
import { useCommonProps } from "../hooks/useCommonProps.mjs";
|
|
7
7
|
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
8
8
|
import { useDateProps } from "../hooks/useDateProps.mjs";
|
|
9
|
+
import { useNullableErrorProps } from "../hooks/useNullableErrorProps.mjs";
|
|
9
10
|
function MantineDateTimeInput(props) {
|
|
10
11
|
const { value, ...commonProps } = useCommonProps(props);
|
|
11
|
-
const { path, uischema } = props;
|
|
12
|
+
const { path, schema, uischema } = props;
|
|
12
13
|
const { initialUTC: __initialUTC } = uischema.options || {};
|
|
13
14
|
const _dateProps = useDateProps("date-time", false, { value, toggle: () => null, onChange: commonProps.onChange });
|
|
14
15
|
const [, { initialUTC }] = useContextProps("DateTime", path, { ...commonProps, ..._dateProps }, props);
|
|
@@ -27,7 +28,11 @@ function MantineDateTimeInput(props) {
|
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
}, [value, setToLocal, setToUTC]);
|
|
30
|
-
const
|
|
31
|
+
const errorProps = useNullableErrorProps(value, commonProps.error, schema);
|
|
32
|
+
const componentProps = useMemo(
|
|
33
|
+
() => ({ ...commonProps, ...dateProps, ...errorProps }),
|
|
34
|
+
[commonProps, dateProps, errorProps]
|
|
35
|
+
);
|
|
31
36
|
const [Component, { initialUTC: _, ..._props }] = useContextProps("DateTime", path, componentProps, props);
|
|
32
37
|
if (!props.visible) {
|
|
33
38
|
return null;
|
package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/MantineInputs/MantineEnumInput.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { NativeSelect, Select } from "@mantine/core";
|
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
import { useCommonProps } from "../hooks/useCommonProps.mjs";
|
|
6
6
|
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
7
|
+
import { useNullableErrorProps } from "../hooks/useNullableErrorProps.mjs";
|
|
7
8
|
import { useSelectProps } from "../hooks/useSelectProps.mjs";
|
|
8
9
|
function MantineEnumInput(props) {
|
|
9
10
|
var _a;
|
|
@@ -11,7 +12,11 @@ function MantineEnumInput(props) {
|
|
|
11
12
|
const { path, schema, uischema } = props;
|
|
12
13
|
const isNative = (((_a = uischema.options) == null ? void 0 : _a.variant) ?? schema.format) === "native";
|
|
13
14
|
const selectProps = useSelectProps(value, props.options, isNative, { onChange: commonProps.onChange });
|
|
14
|
-
const
|
|
15
|
+
const errorProps = useNullableErrorProps(value, commonProps.error, schema);
|
|
16
|
+
const componentProps = useMemo(
|
|
17
|
+
() => ({ ...commonProps, ...selectProps, ...errorProps }),
|
|
18
|
+
[commonProps, errorProps, selectProps]
|
|
19
|
+
);
|
|
15
20
|
const [Component, _props] = useContextProps("Enum", path, componentProps, props);
|
|
16
21
|
if (!props.visible) {
|
|
17
22
|
return null;
|
package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/MantineInputs/MantineNumberInput.mjs
CHANGED
|
@@ -4,16 +4,21 @@ import { NumberInput } from "@mantine/core";
|
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
import { useCommonProps } from "../hooks/useCommonProps.mjs";
|
|
6
6
|
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
7
|
+
import { useNullableErrorProps } from "../hooks/useNullableErrorProps.mjs";
|
|
7
8
|
import { useNumberProps } from "../hooks/useNumberProps.mjs";
|
|
8
9
|
const InnerMantineNumberInput = (props) => {
|
|
9
10
|
const { contextName, componentName, ...rest } = props;
|
|
10
11
|
const { value, ...commonProps } = useCommonProps(rest);
|
|
11
|
-
const { path } = rest;
|
|
12
|
+
const { path, schema } = rest;
|
|
12
13
|
const numberProps = useNumberProps(contextName.toLowerCase(), {
|
|
13
14
|
value,
|
|
14
15
|
onChange: commonProps.onChange
|
|
15
16
|
});
|
|
16
|
-
const
|
|
17
|
+
const errorProps = useNullableErrorProps(value, commonProps.error, schema);
|
|
18
|
+
const componentProps = useMemo(
|
|
19
|
+
() => ({ ...commonProps, ...numberProps, ...errorProps }),
|
|
20
|
+
[commonProps, numberProps, errorProps]
|
|
21
|
+
);
|
|
17
22
|
const [Component, _props] = useContextProps(contextName, path, componentProps, rest);
|
|
18
23
|
if (!rest.visible) {
|
|
19
24
|
return null;
|
package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/MantineInputs/MantineOneOfEnumInput.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { NativeSelect, Select } from "@mantine/core";
|
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
import { useCommonProps } from "../hooks/useCommonProps.mjs";
|
|
6
6
|
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
7
|
+
import { useNullableErrorProps } from "../hooks/useNullableErrorProps.mjs";
|
|
7
8
|
import { useSelectProps } from "../hooks/useSelectProps.mjs";
|
|
8
9
|
function MantineOneOfEnumInput(props) {
|
|
9
10
|
var _a;
|
|
@@ -11,14 +12,7 @@ function MantineOneOfEnumInput(props) {
|
|
|
11
12
|
const { path, schema, uischema } = props;
|
|
12
13
|
const isNative = (((_a = uischema.options) == null ? void 0 : _a.variant) ?? schema.format) === "native";
|
|
13
14
|
const selectProps = useSelectProps(value, props.options, isNative, { onChange: commonProps.onChange });
|
|
14
|
-
const errorProps =
|
|
15
|
-
var _a2;
|
|
16
|
-
const isNull = value === null;
|
|
17
|
-
const error = (_a2 = commonProps.error) == null ? void 0 : _a2.filter(
|
|
18
|
-
(error2) => error2.key === "is a required property" || !isNull ? error2 : false
|
|
19
|
-
);
|
|
20
|
-
return (error == null ? void 0 : error.length) ? { error } : { error: isNull && commonProps.required ? "is a required property" : void 0 };
|
|
21
|
-
}, [commonProps.error, commonProps.required, value]);
|
|
15
|
+
const errorProps = useNullableErrorProps(value, commonProps.error, schema);
|
|
22
16
|
const componentProps = useMemo(
|
|
23
17
|
() => ({ ...commonProps, ...selectProps, ...errorProps }),
|
|
24
18
|
[commonProps, errorProps, selectProps]
|
package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/MantineInputs/MantineTextInput.mjs
CHANGED
|
@@ -4,12 +4,17 @@ import { PasswordInput, TextInput } from "@mantine/core";
|
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
import { useCommonProps } from "../hooks/useCommonProps.mjs";
|
|
6
6
|
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
7
|
+
import { useNullableErrorProps } from "../hooks/useNullableErrorProps.mjs";
|
|
7
8
|
import { useTextProps } from "../hooks/useTextProps.mjs";
|
|
8
9
|
function MantineTextInput(props) {
|
|
9
10
|
const { value, ...commonProps } = useCommonProps(props);
|
|
10
11
|
const { path, schema } = props;
|
|
11
12
|
const textProps = useTextProps({ value, onChange: commonProps.onChange });
|
|
12
|
-
const
|
|
13
|
+
const errorProps = useNullableErrorProps(value, commonProps.error, schema);
|
|
14
|
+
const componentProps = useMemo(
|
|
15
|
+
() => ({ ...commonProps, ...textProps, ...errorProps }),
|
|
16
|
+
[commonProps, textProps, errorProps]
|
|
17
|
+
);
|
|
13
18
|
const [Component, _props] = useContextProps("Text", path, componentProps, props);
|
|
14
19
|
if (!props.visible) {
|
|
15
20
|
return null;
|
package/dist/.bundled/jsonforms/esm/packages/jsonforms/src/MantineInputs/MantineTimeInput.mjs
CHANGED
|
@@ -4,11 +4,12 @@ import { MemoWrapper } from "fastapi-rtk/utils";
|
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
import { useCommonProps } from "../hooks/useCommonProps.mjs";
|
|
6
6
|
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
7
|
+
import { useNullableErrorProps } from "../hooks/useNullableErrorProps.mjs";
|
|
7
8
|
import { useTimeProps } from "../hooks/useTimeProps.mjs";
|
|
8
9
|
function MantineTimeInput(props) {
|
|
9
10
|
var _a, _b;
|
|
10
11
|
const { value, ...commonProps } = useCommonProps(props);
|
|
11
|
-
const { path } = props;
|
|
12
|
+
const { path, schema } = props;
|
|
12
13
|
const _timeProps = useTimeProps({ value, onChange: commonProps.onChange, withSeconds: void 0 });
|
|
13
14
|
const [, { withSeconds }] = useContextProps("Time", path, { ...commonProps, ..._timeProps }, props);
|
|
14
15
|
const timeProps = useTimeProps({
|
|
@@ -16,7 +17,11 @@ function MantineTimeInput(props) {
|
|
|
16
17
|
onChange: commonProps.onChange,
|
|
17
18
|
withSeconds: withSeconds ?? ((_b = (_a = props.uischema) == null ? void 0 : _a.options) == null ? void 0 : _b.withSeconds)
|
|
18
19
|
});
|
|
19
|
-
const
|
|
20
|
+
const errorProps = useNullableErrorProps(value, commonProps.error, schema);
|
|
21
|
+
const componentProps = useMemo(
|
|
22
|
+
() => ({ ...commonProps, ...timeProps, ...errorProps }),
|
|
23
|
+
[commonProps, timeProps, errorProps]
|
|
24
|
+
);
|
|
20
25
|
const [Component, _props] = useContextProps("Time", path, componentProps, props);
|
|
21
26
|
if (!props.visible) {
|
|
22
27
|
return null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { isSchemaTypeInclude } from "../utils/isSchemaTypeInclude.mjs";
|
|
3
|
+
const NULL_OPTION_ERRORS = /* @__PURE__ */ new Set([
|
|
4
|
+
"must be equal to one of the allowed values",
|
|
5
|
+
"must be equal to constant",
|
|
6
|
+
"must match exactly one schema in oneOf"
|
|
7
|
+
]);
|
|
8
|
+
const REQUIRED_ERROR = "is a required property";
|
|
9
|
+
function useNullableErrorProps(value, error, schema) {
|
|
10
|
+
return useMemo(() => {
|
|
11
|
+
if (value !== null && value !== "") {
|
|
12
|
+
return { error };
|
|
13
|
+
}
|
|
14
|
+
if (isSchemaTypeInclude(schema.type ?? "", "null")) {
|
|
15
|
+
const kept = error == null ? void 0 : error.filter((e) => !NULL_OPTION_ERRORS.has(e.key ?? ""));
|
|
16
|
+
return { error: (kept == null ? void 0 : kept.length) ? kept : void 0 };
|
|
17
|
+
}
|
|
18
|
+
return { error: REQUIRED_ERROR };
|
|
19
|
+
}, [error, schema.type, value]);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
useNullableErrorProps
|
|
23
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const index = require("../../../../../../.bundled/jsonforms/cjs/_virtual/
|
|
3
|
+
const index = require("../../../../../../.bundled/jsonforms/cjs/_virtual/index6.cjs");
|
|
4
4
|
const index$1 = require("./codegen/index.cjs");
|
|
5
5
|
const validation_error = require("../runtime/validation_error.cjs");
|
|
6
6
|
const names = require("./names.cjs");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/
|
|
3
|
+
const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index9.cjs");
|
|
4
4
|
const additionalItems = require("./additionalItems.cjs");
|
|
5
5
|
const prefixItems = require("./prefixItems.cjs");
|
|
6
6
|
const items = require("./items.cjs");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/
|
|
3
|
+
const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index7.cjs");
|
|
4
4
|
const id = require("./id.cjs");
|
|
5
5
|
const ref = require("./ref.cjs");
|
|
6
6
|
var hasRequiredCore;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/
|
|
3
|
+
const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index10.cjs");
|
|
4
4
|
const format = require("./format.cjs");
|
|
5
5
|
var hasRequiredFormat;
|
|
6
6
|
function requireFormat() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/
|
|
3
|
+
const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index8.cjs");
|
|
4
4
|
const limitNumber = require("./limitNumber.cjs");
|
|
5
5
|
const multipleOf = require("./multipleOf.cjs");
|
|
6
6
|
const limitLength = require("./limitLength.cjs");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as compile } from "../../../../../../.bundled/jsonforms/esm/_virtual/
|
|
1
|
+
import { __exports as compile } from "../../../../../../.bundled/jsonforms/esm/_virtual/index6.mjs";
|
|
2
2
|
import { __require as requireCodegen } from "./codegen/index.mjs";
|
|
3
3
|
import { __require as requireValidation_error } from "../runtime/validation_error.mjs";
|
|
4
4
|
import { __require as requireNames } from "./names.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as applicator } from "../../../../../../../.bundled/jsonforms/esm/_virtual/
|
|
1
|
+
import { __exports as applicator } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index9.mjs";
|
|
2
2
|
import { __require as requireAdditionalItems } from "./additionalItems.mjs";
|
|
3
3
|
import { __require as requirePrefixItems } from "./prefixItems.mjs";
|
|
4
4
|
import { __require as requireItems } from "./items.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as core } from "../../../../../../../.bundled/jsonforms/esm/_virtual/
|
|
1
|
+
import { __exports as core } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index7.mjs";
|
|
2
2
|
import { __require as requireId } from "./id.mjs";
|
|
3
3
|
import { __require as requireRef } from "./ref.mjs";
|
|
4
4
|
var hasRequiredCore;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as format } from "../../../../../../../.bundled/jsonforms/esm/_virtual/
|
|
1
|
+
import { __exports as format } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index10.mjs";
|
|
2
2
|
import { __require as requireFormat$1 } from "./format.mjs";
|
|
3
3
|
var hasRequiredFormat;
|
|
4
4
|
function requireFormat() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as validation } from "../../../../../../../.bundled/jsonforms/esm/_virtual/
|
|
1
|
+
import { __exports as validation } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index8.mjs";
|
|
2
2
|
import { __require as requireLimitNumber } from "./limitNumber.mjs";
|
|
3
3
|
import { __require as requireMultipleOf } from "./multipleOf.mjs";
|
|
4
4
|
import { __require as requireLimitLength } from "./limitLength.mjs";
|
|
@@ -7,13 +7,18 @@ const React = require("react");
|
|
|
7
7
|
const useBooleanProps = require("../hooks/useBooleanProps.cjs");
|
|
8
8
|
const useCommonProps = require("../hooks/useCommonProps.cjs");
|
|
9
9
|
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
10
|
+
const useNullableErrorProps = require("../hooks/useNullableErrorProps.cjs");
|
|
10
11
|
function MantineBooleanInput(props) {
|
|
11
12
|
var _a;
|
|
12
13
|
const { value, ...commonProps } = useCommonProps.useCommonProps(props);
|
|
13
14
|
const { path, schema, uischema } = props;
|
|
14
15
|
const format = ((_a = uischema.options) == null ? void 0 : _a.variant) ?? schema.format ?? "select";
|
|
15
16
|
const booleanProps = useBooleanProps.useBooleanProps(format, { value, onChange: commonProps.onChange });
|
|
16
|
-
const
|
|
17
|
+
const errorProps = useNullableErrorProps.useNullableErrorProps(value, commonProps.error, schema);
|
|
18
|
+
const componentProps = React.useMemo(
|
|
19
|
+
() => ({ ...commonProps, ...booleanProps, ...errorProps }),
|
|
20
|
+
[booleanProps, commonProps, errorProps]
|
|
21
|
+
);
|
|
17
22
|
const [Component, _props] = useContextProps.useContextProps("Boolean", path, componentProps, props);
|
|
18
23
|
if (!props.visible) {
|
|
19
24
|
return null;
|
|
@@ -7,11 +7,16 @@ const React = require("react");
|
|
|
7
7
|
const useCommonProps = require("../hooks/useCommonProps.cjs");
|
|
8
8
|
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
9
9
|
const useDateProps = require("../hooks/useDateProps.cjs");
|
|
10
|
+
const useNullableErrorProps = require("../hooks/useNullableErrorProps.cjs");
|
|
10
11
|
function MantineDateInput(props) {
|
|
11
12
|
const { value, ...commonProps } = useCommonProps.useCommonProps(props);
|
|
12
|
-
const { path } = props;
|
|
13
|
+
const { path, schema } = props;
|
|
13
14
|
const dateProps = useDateProps.useDateProps("date", true, { value, toggle: () => null, onChange: commonProps.onChange });
|
|
14
|
-
const
|
|
15
|
+
const errorProps = useNullableErrorProps.useNullableErrorProps(value, commonProps.error, schema);
|
|
16
|
+
const componentProps = React.useMemo(
|
|
17
|
+
() => ({ ...commonProps, ...dateProps, ...errorProps }),
|
|
18
|
+
[commonProps, dateProps, errorProps]
|
|
19
|
+
);
|
|
15
20
|
const [Component, _props] = useContextProps.useContextProps("Date", path, componentProps, props);
|
|
16
21
|
if (!props.visible) {
|
|
17
22
|
return null;
|
|
@@ -8,9 +8,10 @@ const React = require("react");
|
|
|
8
8
|
const useCommonProps = require("../hooks/useCommonProps.cjs");
|
|
9
9
|
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
10
10
|
const useDateProps = require("../hooks/useDateProps.cjs");
|
|
11
|
+
const useNullableErrorProps = require("../hooks/useNullableErrorProps.cjs");
|
|
11
12
|
function MantineDateTimeInput(props) {
|
|
12
13
|
const { value, ...commonProps } = useCommonProps.useCommonProps(props);
|
|
13
|
-
const { path, uischema } = props;
|
|
14
|
+
const { path, schema, uischema } = props;
|
|
14
15
|
const { initialUTC: __initialUTC } = uischema.options || {};
|
|
15
16
|
const _dateProps = useDateProps.useDateProps("date-time", false, { value, toggle: () => null, onChange: commonProps.onChange });
|
|
16
17
|
const [, { initialUTC }] = useContextProps.useContextProps("DateTime", path, { ...commonProps, ..._dateProps }, props);
|
|
@@ -29,7 +30,11 @@ function MantineDateTimeInput(props) {
|
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
}, [value, setToLocal, setToUTC]);
|
|
32
|
-
const
|
|
33
|
+
const errorProps = useNullableErrorProps.useNullableErrorProps(value, commonProps.error, schema);
|
|
34
|
+
const componentProps = React.useMemo(
|
|
35
|
+
() => ({ ...commonProps, ...dateProps, ...errorProps }),
|
|
36
|
+
[commonProps, dateProps, errorProps]
|
|
37
|
+
);
|
|
33
38
|
const [Component, { initialUTC: _, ..._props }] = useContextProps.useContextProps("DateTime", path, componentProps, props);
|
|
34
39
|
if (!props.visible) {
|
|
35
40
|
return null;
|
|
@@ -6,6 +6,7 @@ const core = require("@mantine/core");
|
|
|
6
6
|
const React = require("react");
|
|
7
7
|
const useCommonProps = require("../hooks/useCommonProps.cjs");
|
|
8
8
|
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
9
|
+
const useNullableErrorProps = require("../hooks/useNullableErrorProps.cjs");
|
|
9
10
|
const useSelectProps = require("../hooks/useSelectProps.cjs");
|
|
10
11
|
function MantineEnumInput(props) {
|
|
11
12
|
var _a;
|
|
@@ -13,7 +14,11 @@ function MantineEnumInput(props) {
|
|
|
13
14
|
const { path, schema, uischema } = props;
|
|
14
15
|
const isNative = (((_a = uischema.options) == null ? void 0 : _a.variant) ?? schema.format) === "native";
|
|
15
16
|
const selectProps = useSelectProps.useSelectProps(value, props.options, isNative, { onChange: commonProps.onChange });
|
|
16
|
-
const
|
|
17
|
+
const errorProps = useNullableErrorProps.useNullableErrorProps(value, commonProps.error, schema);
|
|
18
|
+
const componentProps = React.useMemo(
|
|
19
|
+
() => ({ ...commonProps, ...selectProps, ...errorProps }),
|
|
20
|
+
[commonProps, errorProps, selectProps]
|
|
21
|
+
);
|
|
17
22
|
const [Component, _props] = useContextProps.useContextProps("Enum", path, componentProps, props);
|
|
18
23
|
if (!props.visible) {
|
|
19
24
|
return null;
|
|
@@ -6,16 +6,21 @@ const core = require("@mantine/core");
|
|
|
6
6
|
const React = require("react");
|
|
7
7
|
const useCommonProps = require("../hooks/useCommonProps.cjs");
|
|
8
8
|
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
9
|
+
const useNullableErrorProps = require("../hooks/useNullableErrorProps.cjs");
|
|
9
10
|
const useNumberProps = require("../hooks/useNumberProps.cjs");
|
|
10
11
|
const InnerMantineNumberInput = (props) => {
|
|
11
12
|
const { contextName, componentName, ...rest } = props;
|
|
12
13
|
const { value, ...commonProps } = useCommonProps.useCommonProps(rest);
|
|
13
|
-
const { path } = rest;
|
|
14
|
+
const { path, schema } = rest;
|
|
14
15
|
const numberProps = useNumberProps.useNumberProps(contextName.toLowerCase(), {
|
|
15
16
|
value,
|
|
16
17
|
onChange: commonProps.onChange
|
|
17
18
|
});
|
|
18
|
-
const
|
|
19
|
+
const errorProps = useNullableErrorProps.useNullableErrorProps(value, commonProps.error, schema);
|
|
20
|
+
const componentProps = React.useMemo(
|
|
21
|
+
() => ({ ...commonProps, ...numberProps, ...errorProps }),
|
|
22
|
+
[commonProps, numberProps, errorProps]
|
|
23
|
+
);
|
|
19
24
|
const [Component, _props] = useContextProps.useContextProps(contextName, path, componentProps, rest);
|
|
20
25
|
if (!rest.visible) {
|
|
21
26
|
return null;
|
|
@@ -6,6 +6,7 @@ const core = require("@mantine/core");
|
|
|
6
6
|
const React = require("react");
|
|
7
7
|
const useCommonProps = require("../hooks/useCommonProps.cjs");
|
|
8
8
|
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
9
|
+
const useNullableErrorProps = require("../hooks/useNullableErrorProps.cjs");
|
|
9
10
|
const useSelectProps = require("../hooks/useSelectProps.cjs");
|
|
10
11
|
function MantineOneOfEnumInput(props) {
|
|
11
12
|
var _a;
|
|
@@ -13,14 +14,7 @@ function MantineOneOfEnumInput(props) {
|
|
|
13
14
|
const { path, schema, uischema } = props;
|
|
14
15
|
const isNative = (((_a = uischema.options) == null ? void 0 : _a.variant) ?? schema.format) === "native";
|
|
15
16
|
const selectProps = useSelectProps.useSelectProps(value, props.options, isNative, { onChange: commonProps.onChange });
|
|
16
|
-
const errorProps =
|
|
17
|
-
var _a2;
|
|
18
|
-
const isNull = value === null;
|
|
19
|
-
const error = (_a2 = commonProps.error) == null ? void 0 : _a2.filter(
|
|
20
|
-
(error2) => error2.key === "is a required property" || !isNull ? error2 : false
|
|
21
|
-
);
|
|
22
|
-
return (error == null ? void 0 : error.length) ? { error } : { error: isNull && commonProps.required ? "is a required property" : void 0 };
|
|
23
|
-
}, [commonProps.error, commonProps.required, value]);
|
|
17
|
+
const errorProps = useNullableErrorProps.useNullableErrorProps(value, commonProps.error, schema);
|
|
24
18
|
const componentProps = React.useMemo(
|
|
25
19
|
() => ({ ...commonProps, ...selectProps, ...errorProps }),
|
|
26
20
|
[commonProps, errorProps, selectProps]
|
|
@@ -6,12 +6,17 @@ const core = require("@mantine/core");
|
|
|
6
6
|
const React = require("react");
|
|
7
7
|
const useCommonProps = require("../hooks/useCommonProps.cjs");
|
|
8
8
|
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
9
|
+
const useNullableErrorProps = require("../hooks/useNullableErrorProps.cjs");
|
|
9
10
|
const useTextProps = require("../hooks/useTextProps.cjs");
|
|
10
11
|
function MantineTextInput(props) {
|
|
11
12
|
const { value, ...commonProps } = useCommonProps.useCommonProps(props);
|
|
12
13
|
const { path, schema } = props;
|
|
13
14
|
const textProps = useTextProps.useTextProps({ value, onChange: commonProps.onChange });
|
|
14
|
-
const
|
|
15
|
+
const errorProps = useNullableErrorProps.useNullableErrorProps(value, commonProps.error, schema);
|
|
16
|
+
const componentProps = React.useMemo(
|
|
17
|
+
() => ({ ...commonProps, ...textProps, ...errorProps }),
|
|
18
|
+
[commonProps, textProps, errorProps]
|
|
19
|
+
);
|
|
15
20
|
const [Component, _props] = useContextProps.useContextProps("Text", path, componentProps, props);
|
|
16
21
|
if (!props.visible) {
|
|
17
22
|
return null;
|
|
@@ -6,11 +6,12 @@ const utils = require("fastapi-rtk/utils");
|
|
|
6
6
|
const React = require("react");
|
|
7
7
|
const useCommonProps = require("../hooks/useCommonProps.cjs");
|
|
8
8
|
const useContextProps = require("../hooks/useContextProps.cjs");
|
|
9
|
+
const useNullableErrorProps = require("../hooks/useNullableErrorProps.cjs");
|
|
9
10
|
const useTimeProps = require("../hooks/useTimeProps.cjs");
|
|
10
11
|
function MantineTimeInput(props) {
|
|
11
12
|
var _a, _b;
|
|
12
13
|
const { value, ...commonProps } = useCommonProps.useCommonProps(props);
|
|
13
|
-
const { path } = props;
|
|
14
|
+
const { path, schema } = props;
|
|
14
15
|
const _timeProps = useTimeProps.useTimeProps({ value, onChange: commonProps.onChange, withSeconds: void 0 });
|
|
15
16
|
const [, { withSeconds }] = useContextProps.useContextProps("Time", path, { ...commonProps, ..._timeProps }, props);
|
|
16
17
|
const timeProps = useTimeProps.useTimeProps({
|
|
@@ -18,7 +19,11 @@ function MantineTimeInput(props) {
|
|
|
18
19
|
onChange: commonProps.onChange,
|
|
19
20
|
withSeconds: withSeconds ?? ((_b = (_a = props.uischema) == null ? void 0 : _a.options) == null ? void 0 : _b.withSeconds)
|
|
20
21
|
});
|
|
21
|
-
const
|
|
22
|
+
const errorProps = useNullableErrorProps.useNullableErrorProps(value, commonProps.error, schema);
|
|
23
|
+
const componentProps = React.useMemo(
|
|
24
|
+
() => ({ ...commonProps, ...timeProps, ...errorProps }),
|
|
25
|
+
[commonProps, timeProps, errorProps]
|
|
26
|
+
);
|
|
22
27
|
const [Component, _props] = useContextProps.useContextProps("Time", path, componentProps, props);
|
|
23
28
|
if (!props.visible) {
|
|
24
29
|
return null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const isSchemaTypeInclude = require("../utils/isSchemaTypeInclude.cjs");
|
|
5
|
+
const NULL_OPTION_ERRORS = /* @__PURE__ */ new Set([
|
|
6
|
+
"must be equal to one of the allowed values",
|
|
7
|
+
"must be equal to constant",
|
|
8
|
+
"must match exactly one schema in oneOf"
|
|
9
|
+
]);
|
|
10
|
+
const REQUIRED_ERROR = "is a required property";
|
|
11
|
+
function useNullableErrorProps(value, error, schema) {
|
|
12
|
+
return React.useMemo(() => {
|
|
13
|
+
if (value !== null && value !== "") {
|
|
14
|
+
return { error };
|
|
15
|
+
}
|
|
16
|
+
if (isSchemaTypeInclude.isSchemaTypeInclude(schema.type ?? "", "null")) {
|
|
17
|
+
const kept = error == null ? void 0 : error.filter((e) => !NULL_OPTION_ERRORS.has(e.key ?? ""));
|
|
18
|
+
return { error: (kept == null ? void 0 : kept.length) ? kept : void 0 };
|
|
19
|
+
}
|
|
20
|
+
return { error: REQUIRED_ERROR };
|
|
21
|
+
}, [error, schema.type, value]);
|
|
22
|
+
}
|
|
23
|
+
exports.useNullableErrorProps = useNullableErrorProps;
|
|
@@ -11,6 +11,7 @@ const useFileProps = require("./hooks/useFileProps.cjs");
|
|
|
11
11
|
const useJsonProps = require("./hooks/useJsonProps.cjs");
|
|
12
12
|
const useMultiSelectProps = require("./hooks/useMultiSelectProps.cjs");
|
|
13
13
|
const useNumberProps = require("./hooks/useNumberProps.cjs");
|
|
14
|
+
const useNullableErrorProps = require("./hooks/useNullableErrorProps.cjs");
|
|
14
15
|
const useSelectProps = require("./hooks/useSelectProps.cjs");
|
|
15
16
|
const useTextProps = require("./hooks/useTextProps.cjs");
|
|
16
17
|
const useThemeCustomizer = require("./hooks/useThemeCustomizer.cjs");
|
|
@@ -55,6 +56,7 @@ exports.useFileProps = useFileProps.useFileProps;
|
|
|
55
56
|
exports.useJsonProps = useJsonProps.useJsonProps;
|
|
56
57
|
exports.useMultiSelectProps = useMultiSelectProps.useMultiSelectProps;
|
|
57
58
|
exports.useNumberProps = useNumberProps.useNumberProps;
|
|
59
|
+
exports.useNullableErrorProps = useNullableErrorProps.useNullableErrorProps;
|
|
58
60
|
exports.useSelectProps = useSelectProps.useSelectProps;
|
|
59
61
|
exports.useTextProps = useTextProps.useTextProps;
|
|
60
62
|
exports.useThemeCustomizer = useThemeCustomizer.useThemeCustomizer;
|
|
@@ -5,13 +5,18 @@ import { useMemo } from "react";
|
|
|
5
5
|
import { useBooleanProps } from "../hooks/useBooleanProps.mjs";
|
|
6
6
|
import { useCommonProps } from "../hooks/useCommonProps.mjs";
|
|
7
7
|
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
8
|
+
import { useNullableErrorProps } from "../hooks/useNullableErrorProps.mjs";
|
|
8
9
|
function MantineBooleanInput(props) {
|
|
9
10
|
var _a;
|
|
10
11
|
const { value, ...commonProps } = useCommonProps(props);
|
|
11
12
|
const { path, schema, uischema } = props;
|
|
12
13
|
const format = ((_a = uischema.options) == null ? void 0 : _a.variant) ?? schema.format ?? "select";
|
|
13
14
|
const booleanProps = useBooleanProps(format, { value, onChange: commonProps.onChange });
|
|
14
|
-
const
|
|
15
|
+
const errorProps = useNullableErrorProps(value, commonProps.error, schema);
|
|
16
|
+
const componentProps = useMemo(
|
|
17
|
+
() => ({ ...commonProps, ...booleanProps, ...errorProps }),
|
|
18
|
+
[booleanProps, commonProps, errorProps]
|
|
19
|
+
);
|
|
15
20
|
const [Component, _props] = useContextProps("Boolean", path, componentProps, props);
|
|
16
21
|
if (!props.visible) {
|
|
17
22
|
return null;
|
|
@@ -5,11 +5,16 @@ import { useMemo } from "react";
|
|
|
5
5
|
import { useCommonProps } from "../hooks/useCommonProps.mjs";
|
|
6
6
|
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
7
7
|
import { useDateProps } from "../hooks/useDateProps.mjs";
|
|
8
|
+
import { useNullableErrorProps } from "../hooks/useNullableErrorProps.mjs";
|
|
8
9
|
function MantineDateInput(props) {
|
|
9
10
|
const { value, ...commonProps } = useCommonProps(props);
|
|
10
|
-
const { path } = props;
|
|
11
|
+
const { path, schema } = props;
|
|
11
12
|
const dateProps = useDateProps("date", true, { value, toggle: () => null, onChange: commonProps.onChange });
|
|
12
|
-
const
|
|
13
|
+
const errorProps = useNullableErrorProps(value, commonProps.error, schema);
|
|
14
|
+
const componentProps = useMemo(
|
|
15
|
+
() => ({ ...commonProps, ...dateProps, ...errorProps }),
|
|
16
|
+
[commonProps, dateProps, errorProps]
|
|
17
|
+
);
|
|
13
18
|
const [Component, _props] = useContextProps("Date", path, componentProps, props);
|
|
14
19
|
if (!props.visible) {
|
|
15
20
|
return null;
|
|
@@ -6,9 +6,10 @@ import { useEffect, useMemo } from "react";
|
|
|
6
6
|
import { useCommonProps } from "../hooks/useCommonProps.mjs";
|
|
7
7
|
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
8
8
|
import { useDateProps } from "../hooks/useDateProps.mjs";
|
|
9
|
+
import { useNullableErrorProps } from "../hooks/useNullableErrorProps.mjs";
|
|
9
10
|
function MantineDateTimeInput(props) {
|
|
10
11
|
const { value, ...commonProps } = useCommonProps(props);
|
|
11
|
-
const { path, uischema } = props;
|
|
12
|
+
const { path, schema, uischema } = props;
|
|
12
13
|
const { initialUTC: __initialUTC } = uischema.options || {};
|
|
13
14
|
const _dateProps = useDateProps("date-time", false, { value, toggle: () => null, onChange: commonProps.onChange });
|
|
14
15
|
const [, { initialUTC }] = useContextProps("DateTime", path, { ...commonProps, ..._dateProps }, props);
|
|
@@ -27,7 +28,11 @@ function MantineDateTimeInput(props) {
|
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
}, [value, setToLocal, setToUTC]);
|
|
30
|
-
const
|
|
31
|
+
const errorProps = useNullableErrorProps(value, commonProps.error, schema);
|
|
32
|
+
const componentProps = useMemo(
|
|
33
|
+
() => ({ ...commonProps, ...dateProps, ...errorProps }),
|
|
34
|
+
[commonProps, dateProps, errorProps]
|
|
35
|
+
);
|
|
31
36
|
const [Component, { initialUTC: _, ..._props }] = useContextProps("DateTime", path, componentProps, props);
|
|
32
37
|
if (!props.visible) {
|
|
33
38
|
return null;
|
|
@@ -4,6 +4,7 @@ import { NativeSelect, Select } from "@mantine/core";
|
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
import { useCommonProps } from "../hooks/useCommonProps.mjs";
|
|
6
6
|
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
7
|
+
import { useNullableErrorProps } from "../hooks/useNullableErrorProps.mjs";
|
|
7
8
|
import { useSelectProps } from "../hooks/useSelectProps.mjs";
|
|
8
9
|
function MantineEnumInput(props) {
|
|
9
10
|
var _a;
|
|
@@ -11,7 +12,11 @@ function MantineEnumInput(props) {
|
|
|
11
12
|
const { path, schema, uischema } = props;
|
|
12
13
|
const isNative = (((_a = uischema.options) == null ? void 0 : _a.variant) ?? schema.format) === "native";
|
|
13
14
|
const selectProps = useSelectProps(value, props.options, isNative, { onChange: commonProps.onChange });
|
|
14
|
-
const
|
|
15
|
+
const errorProps = useNullableErrorProps(value, commonProps.error, schema);
|
|
16
|
+
const componentProps = useMemo(
|
|
17
|
+
() => ({ ...commonProps, ...selectProps, ...errorProps }),
|
|
18
|
+
[commonProps, errorProps, selectProps]
|
|
19
|
+
);
|
|
15
20
|
const [Component, _props] = useContextProps("Enum", path, componentProps, props);
|
|
16
21
|
if (!props.visible) {
|
|
17
22
|
return null;
|
|
@@ -4,16 +4,21 @@ import { NumberInput } from "@mantine/core";
|
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
import { useCommonProps } from "../hooks/useCommonProps.mjs";
|
|
6
6
|
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
7
|
+
import { useNullableErrorProps } from "../hooks/useNullableErrorProps.mjs";
|
|
7
8
|
import { useNumberProps } from "../hooks/useNumberProps.mjs";
|
|
8
9
|
const InnerMantineNumberInput = (props) => {
|
|
9
10
|
const { contextName, componentName, ...rest } = props;
|
|
10
11
|
const { value, ...commonProps } = useCommonProps(rest);
|
|
11
|
-
const { path } = rest;
|
|
12
|
+
const { path, schema } = rest;
|
|
12
13
|
const numberProps = useNumberProps(contextName.toLowerCase(), {
|
|
13
14
|
value,
|
|
14
15
|
onChange: commonProps.onChange
|
|
15
16
|
});
|
|
16
|
-
const
|
|
17
|
+
const errorProps = useNullableErrorProps(value, commonProps.error, schema);
|
|
18
|
+
const componentProps = useMemo(
|
|
19
|
+
() => ({ ...commonProps, ...numberProps, ...errorProps }),
|
|
20
|
+
[commonProps, numberProps, errorProps]
|
|
21
|
+
);
|
|
17
22
|
const [Component, _props] = useContextProps(contextName, path, componentProps, rest);
|
|
18
23
|
if (!rest.visible) {
|
|
19
24
|
return null;
|
|
@@ -4,6 +4,7 @@ import { NativeSelect, Select } from "@mantine/core";
|
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
import { useCommonProps } from "../hooks/useCommonProps.mjs";
|
|
6
6
|
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
7
|
+
import { useNullableErrorProps } from "../hooks/useNullableErrorProps.mjs";
|
|
7
8
|
import { useSelectProps } from "../hooks/useSelectProps.mjs";
|
|
8
9
|
function MantineOneOfEnumInput(props) {
|
|
9
10
|
var _a;
|
|
@@ -11,14 +12,7 @@ function MantineOneOfEnumInput(props) {
|
|
|
11
12
|
const { path, schema, uischema } = props;
|
|
12
13
|
const isNative = (((_a = uischema.options) == null ? void 0 : _a.variant) ?? schema.format) === "native";
|
|
13
14
|
const selectProps = useSelectProps(value, props.options, isNative, { onChange: commonProps.onChange });
|
|
14
|
-
const errorProps =
|
|
15
|
-
var _a2;
|
|
16
|
-
const isNull = value === null;
|
|
17
|
-
const error = (_a2 = commonProps.error) == null ? void 0 : _a2.filter(
|
|
18
|
-
(error2) => error2.key === "is a required property" || !isNull ? error2 : false
|
|
19
|
-
);
|
|
20
|
-
return (error == null ? void 0 : error.length) ? { error } : { error: isNull && commonProps.required ? "is a required property" : void 0 };
|
|
21
|
-
}, [commonProps.error, commonProps.required, value]);
|
|
15
|
+
const errorProps = useNullableErrorProps(value, commonProps.error, schema);
|
|
22
16
|
const componentProps = useMemo(
|
|
23
17
|
() => ({ ...commonProps, ...selectProps, ...errorProps }),
|
|
24
18
|
[commonProps, errorProps, selectProps]
|
|
@@ -4,12 +4,17 @@ import { PasswordInput, TextInput } from "@mantine/core";
|
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
import { useCommonProps } from "../hooks/useCommonProps.mjs";
|
|
6
6
|
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
7
|
+
import { useNullableErrorProps } from "../hooks/useNullableErrorProps.mjs";
|
|
7
8
|
import { useTextProps } from "../hooks/useTextProps.mjs";
|
|
8
9
|
function MantineTextInput(props) {
|
|
9
10
|
const { value, ...commonProps } = useCommonProps(props);
|
|
10
11
|
const { path, schema } = props;
|
|
11
12
|
const textProps = useTextProps({ value, onChange: commonProps.onChange });
|
|
12
|
-
const
|
|
13
|
+
const errorProps = useNullableErrorProps(value, commonProps.error, schema);
|
|
14
|
+
const componentProps = useMemo(
|
|
15
|
+
() => ({ ...commonProps, ...textProps, ...errorProps }),
|
|
16
|
+
[commonProps, textProps, errorProps]
|
|
17
|
+
);
|
|
13
18
|
const [Component, _props] = useContextProps("Text", path, componentProps, props);
|
|
14
19
|
if (!props.visible) {
|
|
15
20
|
return null;
|
|
@@ -4,11 +4,12 @@ import { MemoWrapper } from "fastapi-rtk/utils";
|
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
import { useCommonProps } from "../hooks/useCommonProps.mjs";
|
|
6
6
|
import { useContextProps } from "../hooks/useContextProps.mjs";
|
|
7
|
+
import { useNullableErrorProps } from "../hooks/useNullableErrorProps.mjs";
|
|
7
8
|
import { useTimeProps } from "../hooks/useTimeProps.mjs";
|
|
8
9
|
function MantineTimeInput(props) {
|
|
9
10
|
var _a, _b;
|
|
10
11
|
const { value, ...commonProps } = useCommonProps(props);
|
|
11
|
-
const { path } = props;
|
|
12
|
+
const { path, schema } = props;
|
|
12
13
|
const _timeProps = useTimeProps({ value, onChange: commonProps.onChange, withSeconds: void 0 });
|
|
13
14
|
const [, { withSeconds }] = useContextProps("Time", path, { ...commonProps, ..._timeProps }, props);
|
|
14
15
|
const timeProps = useTimeProps({
|
|
@@ -16,7 +17,11 @@ function MantineTimeInput(props) {
|
|
|
16
17
|
onChange: commonProps.onChange,
|
|
17
18
|
withSeconds: withSeconds ?? ((_b = (_a = props.uischema) == null ? void 0 : _a.options) == null ? void 0 : _b.withSeconds)
|
|
18
19
|
});
|
|
19
|
-
const
|
|
20
|
+
const errorProps = useNullableErrorProps(value, commonProps.error, schema);
|
|
21
|
+
const componentProps = useMemo(
|
|
22
|
+
() => ({ ...commonProps, ...timeProps, ...errorProps }),
|
|
23
|
+
[commonProps, timeProps, errorProps]
|
|
24
|
+
);
|
|
20
25
|
const [Component, _props] = useContextProps("Time", path, componentProps, props);
|
|
21
26
|
if (!props.visible) {
|
|
22
27
|
return null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { isSchemaTypeInclude } from "../utils/isSchemaTypeInclude.mjs";
|
|
3
|
+
const NULL_OPTION_ERRORS = /* @__PURE__ */ new Set([
|
|
4
|
+
"must be equal to one of the allowed values",
|
|
5
|
+
"must be equal to constant",
|
|
6
|
+
"must match exactly one schema in oneOf"
|
|
7
|
+
]);
|
|
8
|
+
const REQUIRED_ERROR = "is a required property";
|
|
9
|
+
function useNullableErrorProps(value, error, schema) {
|
|
10
|
+
return useMemo(() => {
|
|
11
|
+
if (value !== null && value !== "") {
|
|
12
|
+
return { error };
|
|
13
|
+
}
|
|
14
|
+
if (isSchemaTypeInclude(schema.type ?? "", "null")) {
|
|
15
|
+
const kept = error == null ? void 0 : error.filter((e) => !NULL_OPTION_ERRORS.has(e.key ?? ""));
|
|
16
|
+
return { error: (kept == null ? void 0 : kept.length) ? kept : void 0 };
|
|
17
|
+
}
|
|
18
|
+
return { error: REQUIRED_ERROR };
|
|
19
|
+
}, [error, schema.type, value]);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
useNullableErrorProps
|
|
23
|
+
};
|
|
@@ -9,6 +9,7 @@ import { useFileProps } from "./hooks/useFileProps.mjs";
|
|
|
9
9
|
import { useJsonProps } from "./hooks/useJsonProps.mjs";
|
|
10
10
|
import { useMultiSelectProps } from "./hooks/useMultiSelectProps.mjs";
|
|
11
11
|
import { useNumberProps } from "./hooks/useNumberProps.mjs";
|
|
12
|
+
import { useNullableErrorProps } from "./hooks/useNullableErrorProps.mjs";
|
|
12
13
|
import { useSelectProps } from "./hooks/useSelectProps.mjs";
|
|
13
14
|
import { useTextProps } from "./hooks/useTextProps.mjs";
|
|
14
15
|
import { useThemeCustomizer } from "./hooks/useThemeCustomizer.mjs";
|
|
@@ -46,6 +47,7 @@ export {
|
|
|
46
47
|
useFileProps,
|
|
47
48
|
useJsonProps,
|
|
48
49
|
useMultiSelectProps,
|
|
50
|
+
useNullableErrorProps,
|
|
49
51
|
useNumberProps,
|
|
50
52
|
useSelectProps,
|
|
51
53
|
useTextProps,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { JsonSchema } from '@jsonforms/core';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
import { JsonFormsDataValue } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Builds the `error` prop for a single-value input where an empty value (`null` or `''`) is never a
|
|
6
|
+
* valid entry (enum, oneOf, date, time, number, boolean). When the field is empty: a nullable field
|
|
7
|
+
* is valid, so the option-mismatch errors are hidden; a non-nullable field is missing, so a single
|
|
8
|
+
* "is a required property" error is shown. A non-empty value passes its errors through unchanged.
|
|
9
|
+
*
|
|
10
|
+
* @param value the current value; `null` or `''` counts as empty
|
|
11
|
+
* @param error the rendered error nodes from `useCommonProps`
|
|
12
|
+
* @param schema the control schema; a `type` that includes `'null'` marks the field nullable
|
|
13
|
+
* @returns the `error` prop for the input
|
|
14
|
+
*/
|
|
15
|
+
export declare function useNullableErrorProps(value: JsonFormsDataValue, error: ReactElement[] | undefined, schema: JsonSchema): {
|
|
16
|
+
error: ReactElement[] | string | undefined;
|
|
17
|
+
};
|
|
@@ -9,6 +9,7 @@ export { useFileProps } from './hooks/useFileProps';
|
|
|
9
9
|
export { useJsonProps } from './hooks/useJsonProps';
|
|
10
10
|
export { useMultiSelectProps } from './hooks/useMultiSelectProps';
|
|
11
11
|
export { useNumberProps } from './hooks/useNumberProps';
|
|
12
|
+
export { useNullableErrorProps } from './hooks/useNullableErrorProps';
|
|
12
13
|
export { useSelectProps } from './hooks/useSelectProps';
|
|
13
14
|
export { useTextProps } from './hooks/useTextProps';
|
|
14
15
|
export { useThemeCustomizer } from './hooks/useThemeCustomizer';
|
package/package.json
CHANGED