@rjsf/antd 5.3.0 → 5.4.0

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.
@@ -196,7 +196,7 @@
196
196
  span: 24,
197
197
  style: DESCRIPTION_COL_STYLE$1,
198
198
  children: jsxRuntime.jsx(ArrayFieldDescriptionTemplate, {
199
- description: uiOptions.description || schema.description || '',
199
+ description: uiOptions.description || schema.description,
200
200
  idSchema: idSchema,
201
201
  schema: schema,
202
202
  uiSchema: uiSchema,
@@ -478,7 +478,9 @@
478
478
  labelCol = _formContext$labelCol === void 0 ? VERTICAL_LABEL_COL$1 : _formContext$labelCol,
479
479
  _formContext$wrapperC = formContext.wrapperCol,
480
480
  wrapperCol = _formContext$wrapperC === void 0 ? VERTICAL_WRAPPER_COL$1 : _formContext$wrapperC,
481
- wrapperStyle = formContext.wrapperStyle;
481
+ wrapperStyle = formContext.wrapperStyle,
482
+ _formContext$descript = formContext.descriptionLocation,
483
+ descriptionLocation = _formContext$descript === void 0 ? 'below' : _formContext$descript;
482
484
  var uiOptions = utils.getUiOptions(uiSchema);
483
485
  var WrapIfAdditionalTemplate = utils.getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
484
486
  if (hidden) {
@@ -487,6 +489,19 @@
487
489
  children: children
488
490
  });
489
491
  }
492
+ // check to see if there is rawDescription(string) before using description(ReactNode)
493
+ // to prevent showing a blank description area
494
+ var descriptionNode = rawDescription ? description : undefined;
495
+ var descriptionProps = {};
496
+ switch (descriptionLocation) {
497
+ case 'tooltip':
498
+ descriptionProps.tooltip = descriptionNode;
499
+ break;
500
+ case 'below':
501
+ default:
502
+ descriptionProps.extra = descriptionNode;
503
+ break;
504
+ }
490
505
  return jsxRuntime.jsx(WrapIfAdditionalTemplate, {
491
506
  classNames: classNames,
492
507
  style: style,
@@ -500,9 +515,8 @@
500
515
  schema: schema,
501
516
  uiSchema: uiSchema,
502
517
  registry: registry,
503
- children: id === 'root' ? children : jsxRuntime.jsx(Form__default["default"].Item, {
518
+ children: id === 'root' ? children : jsxRuntime.jsx(Form__default["default"].Item, _extends({
504
519
  colon: colon,
505
- extra: rawDescription && description,
506
520
  hasFeedback: schema.type !== 'array' && schema.type !== 'object',
507
521
  help: !!rawHelp && help || (rawErrors !== null && rawErrors !== void 0 && rawErrors.length ? errors : undefined),
508
522
  htmlFor: id,
@@ -511,9 +525,10 @@
511
525
  required: required,
512
526
  style: wrapperStyle,
513
527
  validateStatus: rawErrors !== null && rawErrors !== void 0 && rawErrors.length ? 'error' : undefined,
514
- wrapperCol: wrapperCol,
528
+ wrapperCol: wrapperCol
529
+ }, descriptionProps, {
515
530
  children: children
516
- })
531
+ }))
517
532
  });
518
533
  }
519
534
 
@@ -603,23 +618,23 @@
603
618
  id: idSchema.$id,
604
619
  children: [jsxRuntime.jsxs(Row__default["default"], {
605
620
  gutter: rowGutter,
606
- children: [(uiOptions.title || title) && jsxRuntime.jsx(Col__default["default"], {
621
+ children: [title && jsxRuntime.jsx(Col__default["default"], {
607
622
  className: labelColClassName,
608
623
  span: 24,
609
624
  children: jsxRuntime.jsx(TitleFieldTemplate, {
610
625
  id: utils.titleId(idSchema),
611
- title: uiOptions.title || title,
626
+ title: title,
612
627
  required: required,
613
628
  schema: schema,
614
629
  uiSchema: uiSchema,
615
630
  registry: registry
616
631
  })
617
- }), (uiOptions.description || description) && jsxRuntime.jsx(Col__default["default"], {
632
+ }), description && jsxRuntime.jsx(Col__default["default"], {
618
633
  span: 24,
619
634
  style: DESCRIPTION_COL_STYLE,
620
635
  children: jsxRuntime.jsx(DescriptionFieldTemplate, {
621
636
  id: utils.descriptionId(idSchema),
622
- description: uiOptions.description || description,
637
+ description: description,
623
638
  schema: schema,
624
639
  uiSchema: uiSchema,
625
640
  registry: registry
@@ -1056,14 +1071,20 @@
1056
1071
  disabled = _ref.disabled,
1057
1072
  formContext = _ref.formContext,
1058
1073
  id = _ref.id,
1074
+ label = _ref.label,
1075
+ hideLabel = _ref.hideLabel,
1059
1076
  onBlur = _ref.onBlur,
1060
1077
  onChange = _ref.onChange,
1061
1078
  onFocus = _ref.onFocus,
1062
1079
  options = _ref.options,
1063
1080
  readonly = _ref.readonly,
1081
+ registry = _ref.registry,
1082
+ schema = _ref.schema,
1083
+ uiSchema = _ref.uiSchema,
1064
1084
  value = _ref.value;
1065
1085
  var _formContext$readonly = formContext.readonlyAsDisabled,
1066
1086
  readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
1087
+ var TitleFieldTemplate = utils.getTemplate('TitleFieldTemplate', registry, options);
1067
1088
  var enumOptions = options.enumOptions,
1068
1089
  enumDisabled = options.enumDisabled,
1069
1090
  inline = options.inline,
@@ -1087,26 +1108,36 @@
1087
1108
  onFocus: !readonly ? handleFocus : undefined
1088
1109
  };
1089
1110
  var selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, true);
1090
- return Array.isArray(enumOptions) && enumOptions.length > 0 ? jsxRuntime.jsx(Checkbox__default["default"].Group, _extends({
1091
- disabled: disabled || readonlyAsDisabled && readonly,
1092
- name: id,
1093
- onChange: !readonly ? handleChange : undefined,
1094
- value: selectedIndexes
1095
- }, extraProps, {
1096
- "aria-describedby": utils.ariaDescribedByIds(id),
1097
- children: Array.isArray(enumOptions) && enumOptions.map(function (option, i) {
1098
- return jsxRuntime.jsxs("span", {
1099
- children: [jsxRuntime.jsx(Checkbox__default["default"], {
1100
- id: utils.optionId(id, i),
1101
- name: id,
1102
- autoFocus: i === 0 ? autofocus : false,
1103
- disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
1104
- value: String(i),
1105
- children: option.label
1106
- }), !inline && jsxRuntime.jsx("br", {})]
1107
- }, i);
1108
- })
1109
- })) : null;
1111
+ return Array.isArray(enumOptions) && enumOptions.length > 0 ? jsxRuntime.jsxs(jsxRuntime.Fragment, {
1112
+ children: [!hideLabel && !!label && jsxRuntime.jsx("div", {
1113
+ children: jsxRuntime.jsx(TitleFieldTemplate, {
1114
+ id: utils.titleId(id),
1115
+ title: label,
1116
+ schema: schema,
1117
+ uiSchema: uiSchema,
1118
+ registry: registry
1119
+ })
1120
+ }), jsxRuntime.jsx(Checkbox__default["default"].Group, _extends({
1121
+ disabled: disabled || readonlyAsDisabled && readonly,
1122
+ name: id,
1123
+ onChange: !readonly ? handleChange : undefined,
1124
+ value: selectedIndexes
1125
+ }, extraProps, {
1126
+ "aria-describedby": utils.ariaDescribedByIds(id),
1127
+ children: Array.isArray(enumOptions) && enumOptions.map(function (option, i) {
1128
+ return jsxRuntime.jsxs("span", {
1129
+ children: [jsxRuntime.jsx(Checkbox__default["default"], {
1130
+ id: utils.optionId(id, i),
1131
+ name: id,
1132
+ autoFocus: i === 0 ? autofocus : false,
1133
+ disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
1134
+ value: String(i),
1135
+ children: option.label
1136
+ }), !inline && jsxRuntime.jsx("br", {})]
1137
+ }, i);
1138
+ })
1139
+ }))]
1140
+ }) : null;
1110
1141
  }
1111
1142
 
1112
1143
  /** The `CheckBoxWidget` is a widget for rendering boolean properties.
@@ -1115,18 +1146,25 @@
1115
1146
  * @param props - The `WidgetProps` for this component
1116
1147
  */
1117
1148
  function CheckboxWidget(props) {
1149
+ var _options$description;
1118
1150
  var autofocus = props.autofocus,
1119
1151
  disabled = props.disabled,
1120
1152
  formContext = props.formContext,
1121
1153
  id = props.id,
1122
1154
  label = props.label,
1155
+ hideLabel = props.hideLabel,
1123
1156
  onBlur = props.onBlur,
1124
1157
  onChange = props.onChange,
1125
1158
  onFocus = props.onFocus,
1126
1159
  readonly = props.readonly,
1127
- value = props.value;
1160
+ value = props.value,
1161
+ registry = props.registry,
1162
+ options = props.options,
1163
+ schema = props.schema,
1164
+ uiSchema = props.uiSchema;
1128
1165
  var _formContext$readonly = formContext.readonlyAsDisabled,
1129
1166
  readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
1167
+ var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, options);
1130
1168
  var handleChange = function handleChange(_ref) {
1131
1169
  var target = _ref.target;
1132
1170
  return onChange(target.checked);
@@ -1145,17 +1183,28 @@
1145
1183
  onBlur: !readonly ? handleBlur : undefined,
1146
1184
  onFocus: !readonly ? handleFocus : undefined
1147
1185
  };
1148
- return jsxRuntime.jsx(Checkbox__default["default"], _extends({
1149
- autoFocus: autofocus,
1150
- checked: typeof value === 'undefined' ? false : value,
1151
- disabled: disabled || readonlyAsDisabled && readonly,
1152
- id: id,
1153
- name: id,
1154
- onChange: !readonly ? handleChange : undefined
1155
- }, extraProps, {
1156
- "aria-describedby": utils.ariaDescribedByIds(id),
1157
- children: label
1158
- }));
1186
+ var description = (_options$description = options.description) != null ? _options$description : schema.description;
1187
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
1188
+ children: [!hideLabel && !!description && jsxRuntime.jsx("div", {
1189
+ children: jsxRuntime.jsx(DescriptionFieldTemplate, {
1190
+ id: utils.descriptionId(id),
1191
+ description: description,
1192
+ schema: schema,
1193
+ uiSchema: uiSchema,
1194
+ registry: registry
1195
+ })
1196
+ }), jsxRuntime.jsx(Checkbox__default["default"], _extends({
1197
+ autoFocus: autofocus,
1198
+ checked: typeof value === 'undefined' ? false : value,
1199
+ disabled: disabled || readonlyAsDisabled && readonly,
1200
+ id: id,
1201
+ name: id,
1202
+ onChange: !readonly ? handleChange : undefined
1203
+ }, extraProps, {
1204
+ "aria-describedby": utils.ariaDescribedByIds(id),
1205
+ children: utils.labelValue(label, hideLabel, '')
1206
+ }))]
1207
+ });
1159
1208
  }
1160
1209
 
1161
1210
  var DatePicker = /*#__PURE__*/generatePicker__default["default"](dayjsGenerateConfig__default["default"]);
@@ -1425,6 +1474,8 @@
1425
1474
  _ref$formContext = _ref.formContext,
1426
1475
  formContext = _ref$formContext === void 0 ? {} : _ref$formContext,
1427
1476
  id = _ref.id,
1477
+ label = _ref.label,
1478
+ hideLabel = _ref.hideLabel,
1428
1479
  multiple = _ref.multiple,
1429
1480
  onBlur = _ref.onBlur,
1430
1481
  onChange = _ref.onChange,
@@ -1432,9 +1483,13 @@
1432
1483
  options = _ref.options,
1433
1484
  placeholder = _ref.placeholder,
1434
1485
  readonly = _ref.readonly,
1486
+ registry = _ref.registry,
1487
+ schema = _ref.schema,
1488
+ uiSchema = _ref.uiSchema,
1435
1489
  value = _ref.value;
1436
1490
  var _formContext$readonly = formContext.readonlyAsDisabled,
1437
1491
  readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
1492
+ var TitleFieldTemplate = utils.getTemplate('TitleFieldTemplate', registry, options);
1438
1493
  var enumOptions = options.enumOptions,
1439
1494
  enumDisabled = options.enumDisabled,
1440
1495
  emptyValue = options.emptyValue;
@@ -1463,31 +1518,39 @@
1463
1518
  var extraProps = {
1464
1519
  name: id
1465
1520
  };
1466
- return jsxRuntime.jsx(Select__default["default"], _extends({
1467
- autoFocus: autofocus,
1468
- disabled: disabled || readonlyAsDisabled && readonly,
1469
- getPopupContainer: getPopupContainer,
1470
- id: id,
1471
- mode: typeof multiple !== 'undefined' ? 'multiple' : undefined,
1472
- onBlur: !readonly ? handleBlur : undefined,
1473
- onChange: !readonly ? handleChange : undefined,
1474
- onFocus: !readonly ? handleFocus : undefined,
1475
- placeholder: placeholder,
1476
- style: SELECT_STYLE,
1477
- value: selectedIndexes
1478
- }, extraProps, {
1479
- filterOption: filterOption,
1480
- "aria-describedby": utils.ariaDescribedByIds(id),
1481
- children: Array.isArray(enumOptions) && enumOptions.map(function (_ref2, index) {
1482
- var optionValue = _ref2.value,
1483
- optionLabel = _ref2.label;
1484
- return jsxRuntime.jsx(Select__default["default"].Option, {
1485
- disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(optionValue) !== -1,
1486
- value: String(index),
1487
- children: optionLabel
1488
- }, String(index));
1489
- })
1490
- }));
1521
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
1522
+ children: [!hideLabel && !!label && jsxRuntime.jsx(TitleFieldTemplate, {
1523
+ id: utils.titleId(id),
1524
+ title: label,
1525
+ schema: schema,
1526
+ uiSchema: uiSchema,
1527
+ registry: registry
1528
+ }), jsxRuntime.jsx(Select__default["default"], _extends({
1529
+ autoFocus: autofocus,
1530
+ disabled: disabled || readonlyAsDisabled && readonly,
1531
+ getPopupContainer: getPopupContainer,
1532
+ id: id,
1533
+ mode: typeof multiple !== 'undefined' ? 'multiple' : undefined,
1534
+ onBlur: !readonly ? handleBlur : undefined,
1535
+ onChange: !readonly ? handleChange : undefined,
1536
+ onFocus: !readonly ? handleFocus : undefined,
1537
+ placeholder: placeholder,
1538
+ style: SELECT_STYLE,
1539
+ value: selectedIndexes
1540
+ }, extraProps, {
1541
+ filterOption: filterOption,
1542
+ "aria-describedby": utils.ariaDescribedByIds(id),
1543
+ children: Array.isArray(enumOptions) && enumOptions.map(function (_ref2, index) {
1544
+ var optionValue = _ref2.value,
1545
+ optionLabel = _ref2.label;
1546
+ return jsxRuntime.jsx(Select__default["default"].Option, {
1547
+ disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(optionValue) !== -1,
1548
+ value: String(index),
1549
+ children: optionLabel
1550
+ }, String(index));
1551
+ })
1552
+ }))]
1553
+ });
1491
1554
  }
1492
1555
 
1493
1556
  var INPUT_STYLE = {