@rjsf/antd 5.0.2 → 5.2.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.
package/dist/antd.esm.js CHANGED
@@ -3,7 +3,7 @@ import React, { useState, useEffect } from 'react';
3
3
  import Button from 'antd/es/button';
4
4
  import Col from 'antd/es/col';
5
5
  import Row from 'antd/es/row';
6
- import { getUiOptions, getTemplate, getInputProps, ariaDescribedByIds, examplesId, errorId, titleId, descriptionId, canExpand, getSubmitButtonOptions, UI_OPTIONS_KEY, ADDITIONAL_PROPERTY_FLAG, parseDateString, toDateString, pad, enumOptionsIndexForValue, optionId, enumOptionsValueForIndex, rangeSpec } from '@rjsf/utils';
6
+ import { getUiOptions, getTemplate, getInputProps, ariaDescribedByIds, examplesId, TranslatableString, errorId, titleId, descriptionId, canExpand, getSubmitButtonOptions, UI_OPTIONS_KEY, ADDITIONAL_PROPERTY_FLAG, parseDateString, toDateString, pad, enumOptionsIndexForValue, optionId, enumOptionsValueForIndex, rangeSpec } from '@rjsf/utils';
7
7
  import classNames from 'classnames';
8
8
  import { ConfigConsumer } from 'antd/es/config-provider/context';
9
9
  import Input from 'antd/es/input';
@@ -305,7 +305,9 @@ function DescriptionField(props) {
305
305
  * @param props - The `ErrorListProps` for this component
306
306
  */
307
307
  function ErrorList(_ref) {
308
- var errors = _ref.errors;
308
+ var errors = _ref.errors,
309
+ registry = _ref.registry;
310
+ var translateString = registry.translateString;
309
311
  var renderErrors = function renderErrors() {
310
312
  return /*#__PURE__*/React.createElement(List, {
311
313
  className: "list-group",
@@ -319,7 +321,7 @@ function ErrorList(_ref) {
319
321
  return /*#__PURE__*/React.createElement(Alert, {
320
322
  className: "panel panel-danger errors",
321
323
  description: renderErrors(),
322
- message: "Errors",
324
+ message: translateString(TranslatableString.ErrorsLabel),
323
325
  type: "error"
324
326
  });
325
327
  }
@@ -336,8 +338,9 @@ function IconButton(props) {
336
338
  }, otherProps));
337
339
  }
338
340
  function AddButton(props) {
341
+ var translateString = props.registry.translateString;
339
342
  return /*#__PURE__*/React.createElement(IconButton, _extends({
340
- title: "Add Item"
343
+ title: translateString(TranslatableString.AddItemButton)
341
344
  }, props, {
342
345
  block: true,
343
346
  iconType: "primary",
@@ -345,15 +348,17 @@ function AddButton(props) {
345
348
  }));
346
349
  }
347
350
  function MoveDownButton(props) {
351
+ var translateString = props.registry.translateString;
348
352
  return /*#__PURE__*/React.createElement(IconButton, _extends({
349
- title: "Move down"
353
+ title: translateString(TranslatableString.MoveDownButton)
350
354
  }, props, {
351
355
  icon: /*#__PURE__*/React.createElement(ArrowDownOutlined, null)
352
356
  }));
353
357
  }
354
358
  function MoveUpButton(props) {
359
+ var translateString = props.registry.translateString;
355
360
  return /*#__PURE__*/React.createElement(IconButton, _extends({
356
- title: "Move up"
361
+ title: translateString(TranslatableString.MoveUpButton)
357
362
  }, props, {
358
363
  icon: /*#__PURE__*/React.createElement(ArrowUpOutlined, null)
359
364
  }));
@@ -361,8 +366,9 @@ function MoveUpButton(props) {
361
366
  function RemoveButton(props) {
362
367
  // The `block` prop is not part of the `IconButtonProps` defined in the template, so get it from the uiSchema instead
363
368
  var options = getUiOptions(props.uiSchema);
369
+ var translateString = props.registry.translateString;
364
370
  return /*#__PURE__*/React.createElement(IconButton, _extends({
365
- title: "Remove"
371
+ title: translateString(TranslatableString.RemoveButton)
366
372
  }, props, {
367
373
  danger: true,
368
374
  block: !!options.block,
@@ -694,9 +700,11 @@ function WrapIfAdditionalTemplate(props) {
694
700
  _registry$formContext6 = _registry$formContext.wrapperCol,
695
701
  wrapperCol = _registry$formContext6 === void 0 ? VERTICAL_WRAPPER_COL : _registry$formContext6,
696
702
  wrapperStyle = _registry$formContext.wrapperStyle;
703
+ var templates = registry.templates,
704
+ translateString = registry.translateString;
697
705
  // Button templates are not overridden in the uiSchema
698
- var RemoveButton = registry.templates.ButtonTemplates.RemoveButton;
699
- var keyLabel = label + " Key"; // i18n ?
706
+ var RemoveButton = templates.ButtonTemplates.RemoveButton;
707
+ var keyLabel = translateString(TranslatableString.KeyLabel, [label]);
700
708
  var additional = (ADDITIONAL_PROPERTY_FLAG in schema);
701
709
  if (!additional) {
702
710
  return /*#__PURE__*/React.createElement("div", {
@@ -848,7 +856,9 @@ function AltDateWidget(props) {
848
856
  registry = props.registry,
849
857
  showTime = props.showTime,
850
858
  value = props.value;
851
- var SelectWidget = registry.widgets.SelectWidget;
859
+ var translateString = registry.translateString,
860
+ widgets = registry.widgets;
861
+ var SelectWidget = widgets.SelectWidget;
852
862
  var _formContext$rowGutte = formContext.rowGutter,
853
863
  rowGutter = _formContext$rowGutte === void 0 ? 24 : _formContext$rowGutte;
854
864
  var _useState = useState(parseDateString(value, showTime)),
@@ -935,7 +945,7 @@ function AltDateWidget(props) {
935
945
  className: "btn-now",
936
946
  onClick: handleNow,
937
947
  type: "primary"
938
- }, "Now")), !options.hideClearButton && /*#__PURE__*/React.createElement(Col, {
948
+ }, translateString(TranslatableString.NowLabel))), !options.hideClearButton && /*#__PURE__*/React.createElement(Col, {
939
949
  flex: "88px"
940
950
  }, /*#__PURE__*/React.createElement(Button, {
941
951
  block: true,
@@ -943,7 +953,7 @@ function AltDateWidget(props) {
943
953
  danger: true,
944
954
  onClick: handleClear,
945
955
  type: "primary"
946
- }, "Clear")));
956
+ }, translateString(TranslatableString.ClearLabel))));
947
957
  }
948
958
  AltDateWidget.defaultProps = {
949
959
  autofocus: false,