@rjsf/antd 6.1.1 → 6.2.3
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/antd.esm.js +53 -30
- package/dist/antd.esm.js.map +4 -4
- package/dist/antd.umd.js +47 -26
- package/dist/index.cjs +59 -36
- package/dist/index.cjs.map +4 -4
- package/lib/templates/BaseInputTemplate/index.js +11 -1
- package/lib/templates/BaseInputTemplate/index.js.map +1 -1
- package/lib/templates/IconButton/index.d.ts +1 -0
- package/lib/templates/IconButton/index.js +5 -0
- package/lib/templates/IconButton/index.js.map +1 -1
- package/lib/templates/index.js +2 -1
- package/lib/templates/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/widgets/AltDateTimeWidget/index.d.ts +1 -13
- package/lib/widgets/AltDateTimeWidget/index.js +2 -7
- package/lib/widgets/AltDateTimeWidget/index.js.map +1 -1
- package/lib/widgets/AltDateWidget/index.d.ts +1 -13
- package/lib/widgets/AltDateWidget/index.js +8 -12
- package/lib/widgets/AltDateWidget/index.js.map +1 -1
- package/lib/widgets/SelectWidget/index.d.ts +5 -1
- package/lib/widgets/SelectWidget/index.js +11 -3
- package/lib/widgets/SelectWidget/index.js.map +1 -1
- package/package.json +6 -6
- package/src/templates/BaseInputTemplate/index.tsx +16 -1
- package/src/templates/IconButton/index.tsx +17 -0
- package/src/templates/index.ts +2 -1
- package/src/widgets/AltDateTimeWidget/index.tsx +2 -9
- package/src/widgets/AltDateWidget/index.tsx +8 -13
- package/src/widgets/SelectWidget/index.tsx +12 -2
package/dist/antd.esm.js
CHANGED
|
@@ -109,6 +109,7 @@ function ArrayFieldTemplate(props) {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
// src/templates/BaseInputTemplate/index.tsx
|
|
112
|
+
import { useCallback } from "react";
|
|
112
113
|
import { Input, InputNumber } from "antd";
|
|
113
114
|
import {
|
|
114
115
|
ariaDescribedByIds,
|
|
@@ -139,10 +140,19 @@ function BaseInputTemplate(props) {
|
|
|
139
140
|
const { formContext } = registry;
|
|
140
141
|
const inputProps = getInputProps(schema, type, options, false);
|
|
141
142
|
const { readonlyAsDisabled = true } = formContext;
|
|
143
|
+
const { ClearButton: ClearButton2 } = registry.templates.ButtonTemplates;
|
|
142
144
|
const handleNumberChange = (nextValue) => onChange(nextValue);
|
|
143
145
|
const handleTextChange = onChangeOverride ? onChangeOverride : ({ target }) => onChange(target.value === "" ? options.emptyValue : target.value);
|
|
144
146
|
const handleBlur = ({ target }) => onBlur(id, target && target.value);
|
|
145
147
|
const handleFocus = ({ target }) => onFocus(id, target && target.value);
|
|
148
|
+
const handleClear = useCallback(
|
|
149
|
+
(e) => {
|
|
150
|
+
e.preventDefault();
|
|
151
|
+
e.stopPropagation();
|
|
152
|
+
onChange(options.emptyValue ?? "");
|
|
153
|
+
},
|
|
154
|
+
[onChange, options.emptyValue]
|
|
155
|
+
);
|
|
146
156
|
const input = inputProps.type === "number" || inputProps.type === "integer" ? /* @__PURE__ */ jsx3(
|
|
147
157
|
InputNumber,
|
|
148
158
|
{
|
|
@@ -178,6 +188,7 @@ function BaseInputTemplate(props) {
|
|
|
178
188
|
);
|
|
179
189
|
return /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
180
190
|
input,
|
|
191
|
+
options.allowClearTextInputs && !readonly && !disabled && value && /* @__PURE__ */ jsx3(ClearButton2, { registry, onClick: handleClear }),
|
|
181
192
|
Array.isArray(schema.examples) && /* @__PURE__ */ jsx3("datalist", { id: examplesId(id), children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map((example) => {
|
|
182
193
|
return /* @__PURE__ */ jsx3("option", { value: example }, example);
|
|
183
194
|
}) })
|
|
@@ -227,6 +238,7 @@ import ArrowUpOutlined from "@ant-design/icons/ArrowUpOutlined";
|
|
|
227
238
|
import CopyOutlined from "@ant-design/icons/CopyOutlined";
|
|
228
239
|
import DeleteOutlined from "@ant-design/icons/DeleteOutlined";
|
|
229
240
|
import PlusCircleOutlined from "@ant-design/icons/PlusCircleOutlined";
|
|
241
|
+
import CloseOutlined from "@ant-design/icons/CloseOutlined";
|
|
230
242
|
import {
|
|
231
243
|
getUiOptions as getUiOptions3,
|
|
232
244
|
TranslatableString as TranslatableString2
|
|
@@ -299,6 +311,20 @@ function RemoveButton(props) {
|
|
|
299
311
|
}
|
|
300
312
|
);
|
|
301
313
|
}
|
|
314
|
+
function ClearButton(props) {
|
|
315
|
+
const {
|
|
316
|
+
registry: { translateString }
|
|
317
|
+
} = props;
|
|
318
|
+
return /* @__PURE__ */ jsx6(
|
|
319
|
+
IconButton,
|
|
320
|
+
{
|
|
321
|
+
title: translateString(TranslatableString2.ClearButton),
|
|
322
|
+
...props,
|
|
323
|
+
iconType: "link",
|
|
324
|
+
icon: /* @__PURE__ */ jsx6(CloseOutlined, {})
|
|
325
|
+
}
|
|
326
|
+
);
|
|
327
|
+
}
|
|
302
328
|
|
|
303
329
|
// src/templates/FieldErrorTemplate/index.tsx
|
|
304
330
|
import { errorId } from "@rjsf/utils";
|
|
@@ -726,7 +752,8 @@ function generateTemplates() {
|
|
|
726
752
|
MoveDownButton,
|
|
727
753
|
MoveUpButton,
|
|
728
754
|
RemoveButton,
|
|
729
|
-
SubmitButton
|
|
755
|
+
SubmitButton,
|
|
756
|
+
ClearButton
|
|
730
757
|
},
|
|
731
758
|
DescriptionFieldTemplate: DescriptionField,
|
|
732
759
|
ErrorListTemplate: ErrorList,
|
|
@@ -742,6 +769,13 @@ function generateTemplates() {
|
|
|
742
769
|
}
|
|
743
770
|
var templates_default = generateTemplates();
|
|
744
771
|
|
|
772
|
+
// src/widgets/AltDateTimeWidget/index.tsx
|
|
773
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
774
|
+
function AltDateTimeWidget({ time = true, ...props }) {
|
|
775
|
+
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
776
|
+
return /* @__PURE__ */ jsx16(AltDateWidget2, { time, ...props });
|
|
777
|
+
}
|
|
778
|
+
|
|
745
779
|
// src/widgets/AltDateWidget/index.tsx
|
|
746
780
|
import { Row as Row7, Col as Col7, Button as Button3 } from "antd";
|
|
747
781
|
import {
|
|
@@ -749,16 +783,21 @@ import {
|
|
|
749
783
|
TranslatableString as TranslatableString4,
|
|
750
784
|
useAltDateWidgetProps
|
|
751
785
|
} from "@rjsf/utils";
|
|
752
|
-
import { jsx as
|
|
753
|
-
function AltDateWidget(props) {
|
|
754
|
-
const {
|
|
786
|
+
import { jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
787
|
+
function AltDateWidget({ autofocus = false, disabled = false, options, readonly = false, time = false, ...props }) {
|
|
788
|
+
const { id, name, onBlur, onFocus, registry } = props;
|
|
755
789
|
const { formContext, translateString } = registry;
|
|
756
790
|
const { rowGutter = 24 } = formContext;
|
|
757
|
-
const {
|
|
791
|
+
const realOptions = { yearsRange: [1900, (/* @__PURE__ */ new Date()).getFullYear() + 2], ...options };
|
|
792
|
+
const { elements, handleChange, handleClear, handleSetNow } = useAltDateWidgetProps({
|
|
793
|
+
...props,
|
|
794
|
+
autofocus,
|
|
795
|
+
options: realOptions
|
|
796
|
+
});
|
|
758
797
|
return /* @__PURE__ */ jsxs9(Row7, { gutter: [Math.floor(rowGutter / 2), Math.floor(rowGutter / 2)], children: [
|
|
759
798
|
elements.map((elemProps, i) => {
|
|
760
799
|
const elemId = `${id}_${elemProps.type}`;
|
|
761
|
-
return /* @__PURE__ */
|
|
800
|
+
return /* @__PURE__ */ jsx17(Col7, { flex: "88px", children: /* @__PURE__ */ jsx17(
|
|
762
801
|
DateElement,
|
|
763
802
|
{
|
|
764
803
|
rootId: id,
|
|
@@ -774,30 +813,10 @@ function AltDateWidget(props) {
|
|
|
774
813
|
}
|
|
775
814
|
) }, elemId);
|
|
776
815
|
}),
|
|
777
|
-
!options.hideNowButton && /* @__PURE__ */
|
|
778
|
-
!options.hideClearButton && /* @__PURE__ */
|
|
816
|
+
!options.hideNowButton && /* @__PURE__ */ jsx17(Col7, { flex: "88px", children: /* @__PURE__ */ jsx17(Button3, { block: true, className: "btn-now", onClick: handleSetNow, type: "primary", children: translateString(TranslatableString4.NowLabel) }) }),
|
|
817
|
+
!options.hideClearButton && /* @__PURE__ */ jsx17(Col7, { flex: "88px", children: /* @__PURE__ */ jsx17(Button3, { block: true, className: "btn-clear", danger: true, onClick: handleClear, type: "primary", children: translateString(TranslatableString4.ClearLabel) }) })
|
|
779
818
|
] });
|
|
780
819
|
}
|
|
781
|
-
AltDateWidget.defaultProps = {
|
|
782
|
-
autofocus: false,
|
|
783
|
-
disabled: false,
|
|
784
|
-
options: {
|
|
785
|
-
yearsRange: [1900, (/* @__PURE__ */ new Date()).getFullYear() + 2]
|
|
786
|
-
},
|
|
787
|
-
readonly: false,
|
|
788
|
-
time: false
|
|
789
|
-
};
|
|
790
|
-
|
|
791
|
-
// src/widgets/AltDateTimeWidget/index.tsx
|
|
792
|
-
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
793
|
-
function AltDateTimeWidget(props) {
|
|
794
|
-
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
795
|
-
return /* @__PURE__ */ jsx17(AltDateWidget2, { time: true, ...props });
|
|
796
|
-
}
|
|
797
|
-
AltDateTimeWidget.defaultProps = {
|
|
798
|
-
...AltDateWidget.defaultProps,
|
|
799
|
-
time: true
|
|
800
|
-
};
|
|
801
820
|
|
|
802
821
|
// src/widgets/CheckboxesWidget/index.tsx
|
|
803
822
|
import { Checkbox } from "antd";
|
|
@@ -1107,6 +1126,7 @@ function RangeWidget(props) {
|
|
|
1107
1126
|
}
|
|
1108
1127
|
|
|
1109
1128
|
// src/widgets/SelectWidget/index.tsx
|
|
1129
|
+
import { useMemo, useState } from "react";
|
|
1110
1130
|
import { Select } from "antd";
|
|
1111
1131
|
import {
|
|
1112
1132
|
ariaDescribedByIds as ariaDescribedByIds9,
|
|
@@ -1114,7 +1134,6 @@ import {
|
|
|
1114
1134
|
enumOptionsValueForIndex as enumOptionsValueForIndex3
|
|
1115
1135
|
} from "@rjsf/utils";
|
|
1116
1136
|
import isString2 from "lodash/isString";
|
|
1117
|
-
import { useMemo } from "react";
|
|
1118
1137
|
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
1119
1138
|
var SELECT_STYLE = {
|
|
1120
1139
|
width: "100%"
|
|
@@ -1135,6 +1154,7 @@ function SelectWidget({
|
|
|
1135
1154
|
value,
|
|
1136
1155
|
schema
|
|
1137
1156
|
}) {
|
|
1157
|
+
const [open, setOpen] = useState(false);
|
|
1138
1158
|
const { formContext } = registry;
|
|
1139
1159
|
const { readonlyAsDisabled = true } = formContext;
|
|
1140
1160
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
@@ -1147,7 +1167,7 @@ function SelectWidget({
|
|
|
1147
1167
|
}
|
|
1148
1168
|
return false;
|
|
1149
1169
|
};
|
|
1150
|
-
const getPopupContainer = (
|
|
1170
|
+
const getPopupContainer = SelectWidget.getPopupContainerCallback();
|
|
1151
1171
|
const selectedIndexes = enumOptionsIndexForValue3(value, enumOptions, multiple);
|
|
1152
1172
|
const extraProps = {
|
|
1153
1173
|
name: htmlName || id
|
|
@@ -1171,6 +1191,7 @@ function SelectWidget({
|
|
|
1171
1191
|
return /* @__PURE__ */ jsx25(
|
|
1172
1192
|
Select,
|
|
1173
1193
|
{
|
|
1194
|
+
open,
|
|
1174
1195
|
autoFocus: autofocus,
|
|
1175
1196
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1176
1197
|
getPopupContainer,
|
|
@@ -1183,12 +1204,14 @@ function SelectWidget({
|
|
|
1183
1204
|
style: SELECT_STYLE,
|
|
1184
1205
|
value: selectedIndexes,
|
|
1185
1206
|
...extraProps,
|
|
1207
|
+
onOpenChange: setOpen,
|
|
1186
1208
|
filterOption,
|
|
1187
1209
|
"aria-describedby": ariaDescribedByIds9(id),
|
|
1188
1210
|
options: selectOptions
|
|
1189
1211
|
}
|
|
1190
1212
|
);
|
|
1191
1213
|
}
|
|
1214
|
+
SelectWidget.getPopupContainerCallback = () => (node) => node.parentElement;
|
|
1192
1215
|
|
|
1193
1216
|
// src/widgets/TextareaWidget/index.tsx
|
|
1194
1217
|
import { Input as Input4 } from "antd";
|