aefis-core-ui 2.1.14 → 2.1.16

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.
@@ -75,7 +75,7 @@ import get$1 from 'lodash/get';
75
75
  import isPlainObject from 'lodash/isPlainObject';
76
76
  import isEmpty from 'lodash/isEmpty';
77
77
  import ToggleButton$1 from '@mui/material/ToggleButton';
78
- import { parse as parse$1, format, setDate, setMonth } from 'date-fns';
78
+ import { parse as parse$1, format as format$1, setDate, setMonth } from 'date-fns';
79
79
  import { MobileDatePicker as MobileDatePicker$1 } from '@mui/x-date-pickers/MobileDatePicker';
80
80
  import { LocalizationProvider as LocalizationProvider$1 } from '@mui/x-date-pickers/LocalizationProvider';
81
81
  import 'filepond-plugin-get-file/dist/filepond-plugin-get-file.css';
@@ -1675,12 +1675,12 @@ const LegacyButtonTheme = createTheme(theme, {
1675
1675
  }
1676
1676
  });
1677
1677
 
1678
- const _excluded$j = ["name"];
1678
+ const _excluded$k = ["name"];
1679
1679
  const Button = /*#__PURE__*/forwardRef(function Button(_ref, ref) {
1680
1680
  let {
1681
1681
  name
1682
1682
  } = _ref,
1683
- props = _objectWithoutPropertiesLoose(_ref, _excluded$j);
1683
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$k);
1684
1684
  const isColorDefault = props.color === undefined || props.color === "default";
1685
1685
  const colorThemeName = isColorDefault ? "grey" : props.color;
1686
1686
  const theme = useTheme$1();
@@ -1773,7 +1773,7 @@ AnimatedExpandMoreIcon.propTypes = {
1773
1773
  sx: PropTypes.any
1774
1774
  };
1775
1775
 
1776
- const _excluded$i = ["name", "icon", "menuConfiguration", "color", "displayType", "variant", "onClick", "link"];
1776
+ const _excluded$j = ["name", "icon", "menuConfiguration", "color", "displayType", "variant", "onClick", "link"];
1777
1777
  const AefisButton = withStyles$1({
1778
1778
  root: {
1779
1779
  "&:focus": {
@@ -1795,7 +1795,7 @@ const MenuButton = /*#__PURE__*/forwardRef(function MenuButton(_ref, ref) {
1795
1795
  onClick,
1796
1796
  link
1797
1797
  } = _ref,
1798
- props = _objectWithoutPropertiesLoose(_ref, _excluded$i);
1798
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$j);
1799
1799
  const [anchorEl, setAnchorEl] = useState(null);
1800
1800
  const handleClick = (event, link, buttonId) => {
1801
1801
  setAnchorEl(event.currentTarget);
@@ -3422,7 +3422,7 @@ CardSectionTitle$1.propTypes = {
3422
3422
  title: PropTypes.string
3423
3423
  };
3424
3424
 
3425
- const _excluded$h = ["title", "children", "height", "titleComponent"];
3425
+ const _excluded$i = ["title", "children", "height", "titleComponent"];
3426
3426
  const CardSection$1 = _ref => {
3427
3427
  let {
3428
3428
  title,
@@ -3430,7 +3430,7 @@ const CardSection$1 = _ref => {
3430
3430
  height,
3431
3431
  titleComponent
3432
3432
  } = _ref,
3433
- props = _objectWithoutPropertiesLoose(_ref, _excluded$h);
3433
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$i);
3434
3434
  return /*#__PURE__*/jsxs(Box$1, _extends({
3435
3435
  sx: {
3436
3436
  height: height || "inherit"
@@ -3530,7 +3530,7 @@ SvgImage.propTypes = {
3530
3530
  width: PropTypes.any
3531
3531
  };
3532
3532
 
3533
- const _excluded$g = ["source", "description", "width", "height", "decorative", "showSkeleton", "fallbackImage"],
3533
+ const _excluded$h = ["source", "description", "width", "height", "decorative", "showSkeleton", "fallbackImage"],
3534
3534
  _excluded2$1 = ["src", "extension"];
3535
3535
  const RenderImage = _ref => {
3536
3536
  let {
@@ -3542,7 +3542,7 @@ const RenderImage = _ref => {
3542
3542
  showSkeleton,
3543
3543
  fallbackImage
3544
3544
  } = _ref,
3545
- other = _objectWithoutPropertiesLoose(_ref, _excluded$g);
3545
+ other = _objectWithoutPropertiesLoose(_ref, _excluded$h);
3546
3546
  const altText = decorative ? "" : description;
3547
3547
  const role = decorative ? "presentation" : "img";
3548
3548
  const hidden = !!decorative;
@@ -3620,7 +3620,7 @@ Image.propTypes = {
3620
3620
  extension: PropTypes.string
3621
3621
  };
3622
3622
 
3623
- const _excluded$f = ["type"];
3623
+ const _excluded$g = ["type"];
3624
3624
  const imageProps = {
3625
3625
  award: Award,
3626
3626
  building: Building,
@@ -3646,7 +3646,7 @@ const IsometricImage = _ref => {
3646
3646
  let {
3647
3647
  type
3648
3648
  } = _ref,
3649
- other = _objectWithoutPropertiesLoose(_ref, _excluded$f);
3649
+ other = _objectWithoutPropertiesLoose(_ref, _excluded$g);
3650
3650
  const image = getIsometricImage(type);
3651
3651
  return /*#__PURE__*/jsx(Image, _extends({
3652
3652
  src: image
@@ -4410,13 +4410,13 @@ BusinessObjectCard.propTypes = {
4410
4410
  autoTruncateDescription: PropTypes.bool
4411
4411
  };
4412
4412
 
4413
- const _excluded$e = ["enableScrollTop", "containerProps"];
4413
+ const _excluded$f = ["enableScrollTop", "containerProps"];
4414
4414
  const SwipeableViews = _ref => {
4415
4415
  let {
4416
4416
  enableScrollTop = true,
4417
4417
  containerProps = {}
4418
4418
  } = _ref,
4419
- props = _objectWithoutPropertiesLoose(_ref, _excluded$e);
4419
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$f);
4420
4420
  const containerRef = containerProps.ref || useRef();
4421
4421
  useEffect(() => {
4422
4422
  if (enableScrollTop) {
@@ -5054,7 +5054,7 @@ SectionTitle.propTypes = {
5054
5054
  component: PropTypes.string
5055
5055
  };
5056
5056
 
5057
- const _excluded$d = ["title", "subtitle", "children", "display", "format", "renderList", "titleComponent"];
5057
+ const _excluded$e = ["title", "subtitle", "children", "display", "format", "renderList", "titleComponent"];
5058
5058
  const Section = _ref => {
5059
5059
  let {
5060
5060
  title,
@@ -5065,7 +5065,7 @@ const Section = _ref => {
5065
5065
  renderList,
5066
5066
  titleComponent
5067
5067
  } = _ref,
5068
- props = _objectWithoutPropertiesLoose(_ref, _excluded$d);
5068
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$e);
5069
5069
  const containerStyle = {
5070
5070
  boxSizing: "border-box",
5071
5071
  width: "100%",
@@ -5701,7 +5701,7 @@ FullPageViewer.propTypes = {
5701
5701
  onMessage: PropTypes.func
5702
5702
  };
5703
5703
 
5704
- const _excluded$c = ["height", "children", "onScroll", "showTopFade", "showBottomFade", "component", "onScrollReachStart", "onScrollReachEnd"];
5704
+ const _excluded$d = ["height", "children", "onScroll", "showTopFade", "showBottomFade", "component", "onScrollReachStart", "onScrollReachEnd"];
5705
5705
  const useStyles$w = makeStyles(() => ({
5706
5706
  scroller: {
5707
5707
  position: "relative",
@@ -5774,7 +5774,7 @@ const ScrollingContainer = _ref => {
5774
5774
  onScrollReachStart,
5775
5775
  onScrollReachEnd
5776
5776
  } = _ref,
5777
- props = _objectWithoutPropertiesLoose(_ref, _excluded$c);
5777
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$d);
5778
5778
  const classes = useStyles$w();
5779
5779
  const [scrolled, setScrolled] = useState(false);
5780
5780
  const rootStyle = {
@@ -7530,7 +7530,7 @@ var dataSourceManager = {
7530
7530
  getDataSourceUrl: getDataSourceUrl
7531
7531
  };
7532
7532
 
7533
- const _excluded$b = ["clearOnChange", "minimumLength"];
7533
+ const _excluded$c = ["clearOnChange", "minimumLength"];
7534
7534
  const WAIT_INTERVAL = 1000;
7535
7535
  const ENTER_KEY = 13;
7536
7536
  const TextSearch$1 = _ref => {
@@ -7538,7 +7538,7 @@ const TextSearch$1 = _ref => {
7538
7538
  clearOnChange,
7539
7539
  minimumLength
7540
7540
  } = _ref,
7541
- props = _objectWithoutPropertiesLoose(_ref, _excluded$b);
7541
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$c);
7542
7542
  const [value, setValue] = useState("");
7543
7543
  const [timer, setTimer] = useState(null);
7544
7544
  const handleChange = e => {
@@ -7730,7 +7730,7 @@ const mapFilters = newFilters => {
7730
7730
  return mappedFilters;
7731
7731
  };
7732
7732
 
7733
- const _excluded$a = ["parentMenuOpen", "label", "rightIcon", "leftIcon", "children", "className", "tabIndex", "ContainerProps"];
7733
+ const _excluded$b = ["parentMenuOpen", "label", "rightIcon", "leftIcon", "children", "className", "tabIndex", "ContainerProps"];
7734
7734
  const useMenuItemStyles = makeStyles(theme => ({
7735
7735
  root: props => ({
7736
7736
  backgroundColor: props.open ? theme.palette.action.hover : "rgba(0,0,0,0)"
@@ -7751,7 +7751,7 @@ const NestedMenuItem = /*#__PURE__*/React.forwardRef(function NestedMenuItem(pro
7751
7751
  tabIndex: tabIndexProp,
7752
7752
  ContainerProps: ContainerPropsProp = {}
7753
7753
  } = props,
7754
- MenuItemProps = _objectWithoutPropertiesLoose(props, _excluded$a);
7754
+ MenuItemProps = _objectWithoutPropertiesLoose(props, _excluded$b);
7755
7755
  const {
7756
7756
  ref: containerRefProp
7757
7757
  } = ContainerPropsProp,
@@ -9027,12 +9027,12 @@ Actions.propTypes = {
9027
9027
  onAction: PropTypes.func
9028
9028
  };
9029
9029
 
9030
- const _excluded$9 = ["hasFilters"];
9030
+ const _excluded$a = ["hasFilters"];
9031
9031
  const RenderFilterButton = /*#__PURE__*/React.forwardRef(function RenderFilterButton(_ref, ref) {
9032
9032
  let {
9033
9033
  hasFilters
9034
9034
  } = _ref,
9035
- props = _objectWithoutPropertiesLoose(_ref, _excluded$9);
9035
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$a);
9036
9036
  return /*#__PURE__*/jsx(IconButton$1, _extends({}, props, {
9037
9037
  ref: ref,
9038
9038
  children: /*#__PURE__*/jsx(Badge, {
@@ -9125,7 +9125,7 @@ DefaultIconButton.propTypes = {
9125
9125
  onClick: PropTypes.func
9126
9126
  };
9127
9127
 
9128
- const _excluded$8 = ["filterSet", "onClick", "disableSetDefault", "index"];
9128
+ const _excluded$9 = ["filterSet", "onClick", "disableSetDefault", "index"];
9129
9129
  const useStyles$m = makeStyles(theme => ({
9130
9130
  operations: {
9131
9131
  display: "flex",
@@ -9197,7 +9197,7 @@ const Item$1 = /*#__PURE__*/React.forwardRef((_ref, ref) => {
9197
9197
  disableSetDefault,
9198
9198
  index
9199
9199
  } = _ref,
9200
- props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
9200
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$9);
9201
9201
  const {
9202
9202
  id,
9203
9203
  disabled,
@@ -9253,7 +9253,7 @@ const renderUserDefinedFilters = ({
9253
9253
  index: index
9254
9254
  }, `user-defined-filters-${index}`));
9255
9255
 
9256
- const _excluded$7 = ["filterSet", "onClick", "disableSetDefault", "index"];
9256
+ const _excluded$8 = ["filterSet", "onClick", "disableSetDefault", "index"];
9257
9257
  const useStyles$l = makeStyles(() => ({
9258
9258
  operations: {
9259
9259
  display: "flex",
@@ -9295,7 +9295,7 @@ const Item = /*#__PURE__*/React.forwardRef((_ref, ref) => {
9295
9295
  disableSetDefault,
9296
9296
  index
9297
9297
  } = _ref,
9298
- props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
9298
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
9299
9299
  const {
9300
9300
  id,
9301
9301
  disabled,
@@ -10447,7 +10447,7 @@ const getInfoTextByFilterAndSortingCount = (filterCount, sortCount) => {
10447
10447
  return `${appliedText} applied to the data`;
10448
10448
  };
10449
10449
 
10450
- const _excluded$6 = ["status", "data", "isFetching", "fetchNextPage", "hasNextPage", "refetch"];
10450
+ const _excluded$7 = ["status", "data", "isFetching", "fetchNextPage", "hasNextPage", "refetch"];
10451
10451
  const useDidMount = () => {
10452
10452
  const didMountRef = useRef(false);
10453
10453
  useEffect(() => {
@@ -10562,7 +10562,7 @@ const RichDataTable = /*#__PURE__*/forwardRef(function RichDatatable(props, ref)
10562
10562
  hasNextPage,
10563
10563
  refetch
10564
10564
  } = _useDataSourceInfinit;
10565
- _objectWithoutPropertiesLoose(_useDataSourceInfinit, _excluded$6);
10565
+ _objectWithoutPropertiesLoose(_useDataSourceInfinit, _excluded$7);
10566
10566
  const isError = useIsError(status);
10567
10567
  const renderReTryButton = useCallback(status => /*#__PURE__*/jsx(Button, {
10568
10568
  onClick: () => refetch(),
@@ -10935,7 +10935,7 @@ const {
10935
10935
  withEvent: withBOPEvent
10936
10936
  } = createComponentEvent();
10937
10937
 
10938
- const _excluded$5 = ["onSubmit", "value", "columns", "filterPanelConfig", "multiple", "dataSource", "confirmButtonText"];
10938
+ const _excluded$6 = ["onSubmit", "value", "columns", "filterPanelConfig", "multiple", "dataSource", "confirmButtonText"];
10939
10939
  const useDialogOpenEventListener$1 = cb => useBOPEventlistener(event => {
10940
10940
  if (event.name === events.OPEN_ENHANCED_SEARCH_DIALOG) cb(event.payload);
10941
10941
  });
@@ -10949,7 +10949,7 @@ const EnhancedSearchDialog = _ref => {
10949
10949
  dataSource,
10950
10950
  confirmButtonText
10951
10951
  } = _ref,
10952
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
10952
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
10953
10953
  const [selection, setSelection] = useState([]);
10954
10954
  const [open, setOpen] = useState(false);
10955
10955
  useDialogOpenEventListener$1(isOpen => setOpen(isOpen));
@@ -11066,7 +11066,7 @@ const useDependencyChange = (callback, currentState) => {
11066
11066
  }
11067
11067
  };
11068
11068
 
11069
- const _excluded$4 = ["visibleValues", "multiple", "dataSource", "optionTemplate", "getOptionLabel", "renderTags", "renderOption", "freeSolo", "newItemTemplate", "loadOnOpen", "openOnFocus", "enhancedSearch", "disableCloseOnSelect", "listSelect", "onAdd", "pageSize", "groupName", "idTemplate", "group", "shouldResetOnParametersChange", "queryParamNames", "enableInfinteScroll", "renderAddItemForm", "AddItemFormModalComponent", "autoCompleteProps"];
11069
+ const _excluded$5 = ["visibleValues", "multiple", "dataSource", "optionTemplate", "getOptionLabel", "renderTags", "renderOption", "freeSolo", "newItemTemplate", "loadOnOpen", "openOnFocus", "enhancedSearch", "disableCloseOnSelect", "listSelect", "onAdd", "pageSize", "groupName", "idTemplate", "group", "shouldResetOnParametersChange", "queryParamNames", "enableInfinteScroll", "renderAddItemForm", "AddItemFormModalComponent", "autoCompleteProps"];
11070
11070
  const useStyles$f = makeStyles(theme => ({
11071
11071
  menu: {
11072
11072
  textDecoration: "none",
@@ -11129,7 +11129,7 @@ const BusinessObjectPicker = _ref => {
11129
11129
  AddItemFormModalComponent,
11130
11130
  autoCompleteProps = {}
11131
11131
  } = _ref,
11132
- props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
11132
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
11133
11133
  const classes = useStyles$f();
11134
11134
  // TODO: implement controlled behaviour
11135
11135
  const [value, setValue] = useAutoCompleteValue(props.value, multiple);
@@ -12515,7 +12515,7 @@ CurriculumChart.propTypes = {
12515
12515
  onLoad: PropTypes.func
12516
12516
  };
12517
12517
 
12518
- const _excluded$3 = ["error", "inputFormat", "value", "isControlled", "onChange", "clearable", "disabled", "required", "showButton", "minimumDate", "maximumDate", "inputEndAdornmentText"];
12518
+ const _excluded$4 = ["error", "inputFormat", "value", "isControlled", "onChange", "clearable", "disabled", "required", "showButton", "minimumDate", "maximumDate", "inputEndAdornmentText"];
12519
12519
  const MuiDatePicker = props => {
12520
12520
  const isMobile = useMediaQuery$1(theme => theme.breakpoints.down("md"));
12521
12521
  if (props.type) {
@@ -12555,7 +12555,7 @@ const DatePickerBase = _ref => {
12555
12555
  maximumDate,
12556
12556
  inputEndAdornmentText
12557
12557
  } = _ref,
12558
- props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
12558
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
12559
12559
  const [value, setValue] = useFormItemState(propsValue, isControlled);
12560
12560
  const handleChange = newValue => {
12561
12561
  !isControlled && setValue(newValue);
@@ -15795,8 +15795,8 @@ ToggleButtonWidget.propTypes = {
15795
15795
  label: PropTypes.any
15796
15796
  };
15797
15797
  ToggleButtonWidget.defaultProps = {};
15798
- const HOCs$d = [...commonWidgetHOCs];
15799
- var ToggleButtonWidget$1 = compose(HOCs$d)(ToggleButtonWidget);
15798
+ const HOCs$e = [...commonWidgetHOCs];
15799
+ var ToggleButtonWidget$1 = compose(HOCs$e)(ToggleButtonWidget);
15800
15800
 
15801
15801
  const DefaultReadOnly = props => {
15802
15802
  return /*#__PURE__*/jsxs(Fragment, {
@@ -15848,7 +15848,7 @@ const withReadyOnly = (ReadOnlyComponent = DefaultReadOnly, options = {
15848
15848
  };
15849
15849
  };
15850
15850
 
15851
- const _excluded$2 = ["value", "inputValue", "onChange", "options", "defaultValue", "onCreateOption", "onDebouncedInputChange", "loading", "status", "optionKey", "createOptionItem", "loadingCreateOption", "onOpen", "createOptionStatus", "disableArrowIcon", "searchCharacterLimit"];
15851
+ const _excluded$3 = ["value", "inputValue", "onChange", "options", "defaultValue", "onCreateOption", "onDebouncedInputChange", "loading", "status", "optionKey", "createOptionItem", "loadingCreateOption", "onOpen", "createOptionStatus", "disableArrowIcon", "searchCharacterLimit"];
15852
15852
  const useStyles$2 = makeStyles(theme => ({
15853
15853
  expand: {
15854
15854
  transform: "rotate(180deg)",
@@ -15908,7 +15908,7 @@ const AutoCompleteBase = /*#__PURE__*/forwardRef(function AutoCompleteBase(props
15908
15908
  disableArrowIcon,
15909
15909
  searchCharacterLimit = 0
15910
15910
  } = props,
15911
- restOfProps = _objectWithoutPropertiesLoose(props, _excluded$2);
15911
+ restOfProps = _objectWithoutPropertiesLoose(props, _excluded$3);
15912
15912
  const classes = useStyles$2();
15913
15913
  const [value, setValue] = useState(defaultValue || valueProp || []);
15914
15914
  const [inputValue, setInputValue] = useState(inputValueProp);
@@ -16354,8 +16354,8 @@ BadgeKeywordField.propTypes = {
16354
16354
  isReadOnly: PropTypes.bool,
16355
16355
  disabled: PropTypes.bool
16356
16356
  };
16357
- const HOCs$c = [...commonFieldHOCs, withReadyOnly(BadgeKeywordFieldReadOnly)];
16358
- var BadgeKeywordField$1 = compose(HOCs$c)(BadgeKeywordField);
16357
+ const HOCs$d = [...commonFieldHOCs, withReadyOnly(BadgeKeywordFieldReadOnly)];
16358
+ var BadgeKeywordField$1 = compose(HOCs$d)(BadgeKeywordField);
16359
16359
 
16360
16360
  const ReadOnlyView = ({
16361
16361
  label,
@@ -16390,7 +16390,12 @@ const ReadOnlyView = ({
16390
16390
  sx: {
16391
16391
  fontStyle: "italic"
16392
16392
  },
16393
- description: _emptyViewText,
16393
+ description: /*#__PURE__*/jsx(Box$2, {
16394
+ sx: {
16395
+ paddingRight: 1
16396
+ },
16397
+ children: _emptyViewText
16398
+ }),
16394
16399
  showIcon: false
16395
16400
  });
16396
16401
  }
@@ -16555,10 +16560,10 @@ BusinessObjectPickerField.propTypes = {
16555
16560
  onChange: PropTypes.func
16556
16561
  };
16557
16562
  BusinessObjectPickerField.defaultProps = {};
16558
- const HOCs$b = [...commonFieldHOCs, withReadyOnly(BusinessObjectPickerFieldReadOnly)];
16559
- var BusinessObjectPickerField$1 = compose(HOCs$b)(BusinessObjectPickerField);
16563
+ const HOCs$c = [...commonFieldHOCs, withReadyOnly(BusinessObjectPickerFieldReadOnly)];
16564
+ var BusinessObjectPickerField$1 = compose(HOCs$c)(BusinessObjectPickerField);
16560
16565
 
16561
- const _excluded$1 = ["minimumDate", "maximumDate"],
16566
+ const _excluded$2 = ["minimumDate", "maximumDate"],
16562
16567
  _excluded2 = ["minimumDate", "maximumDate"];
16563
16568
  const getDate$1 = dateStr => {
16564
16569
  try {
@@ -16654,7 +16659,7 @@ const DateRangeField = ({
16654
16659
  minimumDate: startDateMinDate,
16655
16660
  maximumDate: startDateMaxDate
16656
16661
  } = _ref,
16657
- startDateProps = _objectWithoutPropertiesLoose(_ref, _excluded$1);
16662
+ startDateProps = _objectWithoutPropertiesLoose(_ref, _excluded$2);
16658
16663
  const _ref2 = (uiSchema == null ? void 0 : uiSchema["ui:endDateProps"]) || {},
16659
16664
  {
16660
16665
  minimumDate: endDateMinDate,
@@ -16704,8 +16709,8 @@ DateRangeField.propTypes = {
16704
16709
  required: PropTypes.bool,
16705
16710
  value: PropTypes.any
16706
16711
  };
16707
- const HOCs$a = [...commonFieldHOCs, withReadyOnly(DateSelectReadOnly$2)];
16708
- var DateRangeField$1 = compose(HOCs$a)(DateRangeField);
16712
+ const HOCs$b = [...commonFieldHOCs, withReadyOnly(DateSelectReadOnly$2)];
16713
+ var DateRangeField$1 = compose(HOCs$b)(DateRangeField);
16709
16714
 
16710
16715
  const useReadOnly = uiSchema => {
16711
16716
  const code = uiSchema == null ? void 0 : uiSchema["eval:readonly"];
@@ -16828,9 +16833,9 @@ const DateSelect = props => {
16828
16833
  if (newDateType != null) {
16829
16834
  setDateType(newDateType);
16830
16835
  if (typeof selectedDate !== "undefined" && selectedDate != null) {
16831
- format(selectedDate, serverSideDateFormat);
16836
+ format$1(selectedDate, serverSideDateFormat);
16832
16837
  onChange({
16833
- date: format(selectedDate, serverSideDateFormat),
16838
+ date: format$1(selectedDate, serverSideDateFormat),
16834
16839
  type: newDateType.type
16835
16840
  });
16836
16841
  }
@@ -16846,7 +16851,7 @@ const DateSelect = props => {
16846
16851
  }
16847
16852
  setSelectedDate(newDate);
16848
16853
  onChange({
16849
- date: format(newDate, serverSideDateFormat),
16854
+ date: format$1(newDate, serverSideDateFormat),
16850
16855
  type: dateType.type
16851
16856
  });
16852
16857
  } else {
@@ -17167,8 +17172,8 @@ Upload.propTypes = {
17167
17172
  acceptedFileTypes: PropTypes.array
17168
17173
  };
17169
17174
 
17170
- const HOCs$9 = [...commonFieldHOCs];
17171
- var UploadField = compose(HOCs$9)(Upload);
17175
+ const HOCs$a = [...commonFieldHOCs];
17176
+ var UploadField = compose(HOCs$a)(Upload);
17172
17177
 
17173
17178
  const renderUserIcon = userType => {
17174
17179
  let iconButton;
@@ -17524,8 +17529,8 @@ const LinkUserFieldReadOnly = props => {
17524
17529
  })]
17525
17530
  });
17526
17531
  };
17527
- const HOCs$8 = [...commonFieldHOCs, withReadyOnly(LinkUserFieldReadOnly)];
17528
- var LinkUserField$1 = compose(HOCs$8)(LinkUserField);
17532
+ const HOCs$9 = [...commonFieldHOCs, withReadyOnly(LinkUserFieldReadOnly)];
17533
+ var LinkUserField$1 = compose(HOCs$9)(LinkUserField);
17529
17534
 
17530
17535
  const withEvalDisable = () => Component => {
17531
17536
  const MemoizedComponent = /*#__PURE__*/React.memo(Component);
@@ -17844,8 +17849,8 @@ SelectField.propTypes = {
17844
17849
  value: PropTypes.any,
17845
17850
  disabled: PropTypes.any
17846
17851
  };
17847
- const HOCs$7 = [...commonWidgetHOCs, withEvalDisable()];
17848
- var SelectField$1 = compose(HOCs$7)(SelectField);
17852
+ const HOCs$8 = [...commonWidgetHOCs, withEvalDisable()];
17853
+ var SelectField$1 = compose(HOCs$8)(SelectField);
17849
17854
 
17850
17855
  // TODO: refactor usage of readonly
17851
17856
  // use the similar usage on each implementation
@@ -18066,8 +18071,8 @@ ArrayTemplateWithReadOnly.propTypes = {
18066
18071
  items: PropTypes.any,
18067
18072
  schema: PropTypes.any
18068
18073
  };
18069
- const HOCs$6 = [withReadyOnly(ArrayTemplateWithReadOnly)];
18070
- var ArrayFieldTemplate$1 = compose(HOCs$6)(ArrayFieldTemplate);
18074
+ const HOCs$7 = [withReadyOnly(ArrayTemplateWithReadOnly)];
18075
+ var ArrayFieldTemplate$1 = compose(HOCs$7)(ArrayFieldTemplate);
18071
18076
 
18072
18077
  // export default withReadyOnly(ArrayFieldTemplate, ArrayTemplateWithReadOnly);
18073
18078
 
@@ -18237,8 +18242,8 @@ DateWidgetRaw.propTypes = {
18237
18242
  required: PropTypes.bool,
18238
18243
  value: PropTypes.any
18239
18244
  };
18240
- const HOCs$5 = [...commonWidgetHOCs, withReadyOnly(DateSelectReadOnly)];
18241
- const DateWidget = compose(HOCs$5)(DateWidgetRaw);
18245
+ const HOCs$6 = [...commonWidgetHOCs, withReadyOnly(DateSelectReadOnly)];
18246
+ const DateWidget = compose(HOCs$6)(DateWidgetRaw);
18242
18247
 
18243
18248
  const getError$1 = errors => {
18244
18249
  if (errors) {
@@ -18255,9 +18260,9 @@ const getError$1 = errors => {
18255
18260
  return null;
18256
18261
  };
18257
18262
 
18258
- const _excluded = ["inputRef"];
18263
+ const _excluded$1 = ["inputRef"];
18259
18264
  const TextMaskCustom = /*#__PURE__*/forwardRef((props, ref) => {
18260
- const other = _objectWithoutPropertiesLoose(props, _excluded);
18265
+ const other = _objectWithoutPropertiesLoose(props, _excluded$1);
18261
18266
  const placeholderChar = "\u2000";
18262
18267
  const pipe = (conformedValue, config) => {
18263
18268
  var indexes = [1, 2, 3, 6, 7, 8, 10, 11, 12, 13];
@@ -18362,8 +18367,1198 @@ const PhoneWidgetReadOnly = props => {
18362
18367
  })]
18363
18368
  });
18364
18369
  };
18365
- const HOCs$4 = [...commonWidgetHOCs, withReadyOnly(PhoneWidgetReadOnly)];
18366
- var PhoneWidget$1 = compose(HOCs$4)(PhoneWidget);
18370
+ const HOCs$5 = [...commonWidgetHOCs, withReadyOnly(PhoneWidgetReadOnly)];
18371
+ var PhoneWidget$1 = compose(HOCs$5)(PhoneWidget);
18372
+
18373
+ /**
18374
+ * react-number-format - 5.1.3
18375
+ * Author : Sudhanshu Yadav
18376
+ * Copyright (c) 2016, 2023 to Sudhanshu Yadav, released under the MIT license.
18377
+ * https://github.com/s-yadav/react-number-format
18378
+ */
18379
+
18380
+ /******************************************************************************
18381
+ Copyright (c) Microsoft Corporation.
18382
+
18383
+ Permission to use, copy, modify, and/or distribute this software for any
18384
+ purpose with or without fee is hereby granted.
18385
+
18386
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
18387
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18388
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
18389
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18390
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18391
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18392
+ PERFORMANCE OF THIS SOFTWARE.
18393
+ ***************************************************************************** */
18394
+
18395
+ function __rest(s, e) {
18396
+ var t = {};
18397
+ for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
18398
+ { t[p] = s[p]; } }
18399
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18400
+ { for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18401
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18402
+ { t[p[i]] = s[p[i]]; }
18403
+ } }
18404
+ return t;
18405
+ }
18406
+
18407
+ var SourceType;
18408
+ (function (SourceType) {
18409
+ SourceType["event"] = "event";
18410
+ SourceType["props"] = "prop";
18411
+ })(SourceType || (SourceType = {}));
18412
+
18413
+ // basic noop function
18414
+ function noop() { }
18415
+ function charIsNumber(char) {
18416
+ return !!(char || '').match(/\d/);
18417
+ }
18418
+ function isNil(val) {
18419
+ return val === null || val === undefined;
18420
+ }
18421
+ function isNanValue(val) {
18422
+ return typeof val === 'number' && isNaN(val);
18423
+ }
18424
+ function escapeRegExp(str) {
18425
+ return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
18426
+ }
18427
+ function getThousandsGroupRegex(thousandsGroupStyle) {
18428
+ switch (thousandsGroupStyle) {
18429
+ case 'lakh':
18430
+ return /(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/g;
18431
+ case 'wan':
18432
+ return /(\d)(?=(\d{4})+(?!\d))/g;
18433
+ case 'thousand':
18434
+ default:
18435
+ return /(\d)(?=(\d{3})+(?!\d))/g;
18436
+ }
18437
+ }
18438
+ function applyThousandSeparator(str, thousandSeparator, thousandsGroupStyle) {
18439
+ var thousandsGroupRegex = getThousandsGroupRegex(thousandsGroupStyle);
18440
+ var index = str.search(/[1-9]/);
18441
+ index = index === -1 ? str.length : index;
18442
+ return (str.substring(0, index) +
18443
+ str.substring(index, str.length).replace(thousandsGroupRegex, '$1' + thousandSeparator));
18444
+ }
18445
+ function usePersistentCallback(cb) {
18446
+ var callbackRef = useRef(cb);
18447
+ // keep the callback ref upto date
18448
+ callbackRef.current = cb;
18449
+ /**
18450
+ * initialize a persistent callback which never changes
18451
+ * through out the component lifecycle
18452
+ */
18453
+ var persistentCbRef = useRef(function () {
18454
+ var args = [], len = arguments.length;
18455
+ while ( len-- ) args[ len ] = arguments[ len ];
18456
+
18457
+ return callbackRef.current.apply(callbackRef, args);
18458
+ });
18459
+ return persistentCbRef.current;
18460
+ }
18461
+ //spilt a float number into different parts beforeDecimal, afterDecimal, and negation
18462
+ function splitDecimal(numStr, allowNegative) {
18463
+ if ( allowNegative === void 0 ) allowNegative = true;
18464
+
18465
+ var hasNegation = numStr[0] === '-';
18466
+ var addNegation = hasNegation && allowNegative;
18467
+ numStr = numStr.replace('-', '');
18468
+ var parts = numStr.split('.');
18469
+ var beforeDecimal = parts[0];
18470
+ var afterDecimal = parts[1] || '';
18471
+ return {
18472
+ beforeDecimal: beforeDecimal,
18473
+ afterDecimal: afterDecimal,
18474
+ hasNegation: hasNegation,
18475
+ addNegation: addNegation,
18476
+ };
18477
+ }
18478
+ function fixLeadingZero(numStr) {
18479
+ if (!numStr)
18480
+ { return numStr; }
18481
+ var isNegative = numStr[0] === '-';
18482
+ if (isNegative)
18483
+ { numStr = numStr.substring(1, numStr.length); }
18484
+ var parts = numStr.split('.');
18485
+ var beforeDecimal = parts[0].replace(/^0+/, '') || '0';
18486
+ var afterDecimal = parts[1] || '';
18487
+ return ("" + (isNegative ? '-' : '') + beforeDecimal + (afterDecimal ? ("." + afterDecimal) : ''));
18488
+ }
18489
+ /**
18490
+ * limit decimal numbers to given scale
18491
+ * Not used .fixedTo because that will break with big numbers
18492
+ */
18493
+ function limitToScale(numStr, scale, fixedDecimalScale) {
18494
+ var str = '';
18495
+ var filler = fixedDecimalScale ? '0' : '';
18496
+ for (var i = 0; i <= scale - 1; i++) {
18497
+ str += numStr[i] || filler;
18498
+ }
18499
+ return str;
18500
+ }
18501
+ function repeat(str, count) {
18502
+ return Array(count + 1).join(str);
18503
+ }
18504
+ function toNumericString(num) {
18505
+ var _num = num + ''; // typecast number to string
18506
+ // store the sign and remove it from the number.
18507
+ var sign = _num[0] === '-' ? '-' : '';
18508
+ if (sign)
18509
+ { _num = _num.substring(1); }
18510
+ // split the number into cofficient and exponent
18511
+ var ref = _num.split(/[eE]/g);
18512
+ var coefficient = ref[0];
18513
+ var exponent = ref[1];
18514
+ // covert exponent to number;
18515
+ exponent = Number(exponent);
18516
+ // if there is no exponent part or its 0, return the coffiecient with sign
18517
+ if (!exponent)
18518
+ { return sign + coefficient; }
18519
+ coefficient = coefficient.replace('.', '');
18520
+ /**
18521
+ * for scientific notation the current decimal index will be after first number (index 0)
18522
+ * So effective decimal index will always be 1 + exponent value
18523
+ */
18524
+ var decimalIndex = 1 + exponent;
18525
+ var coffiecientLn = coefficient.length;
18526
+ if (decimalIndex < 0) {
18527
+ // if decimal index is less then 0 add preceding 0s
18528
+ // add 1 as join will have
18529
+ coefficient = '0.' + repeat('0', Math.abs(decimalIndex)) + coefficient;
18530
+ }
18531
+ else if (decimalIndex >= coffiecientLn) {
18532
+ // if decimal index is less then 0 add leading 0s
18533
+ coefficient = coefficient + repeat('0', decimalIndex - coffiecientLn);
18534
+ }
18535
+ else {
18536
+ // else add decimal point at proper index
18537
+ coefficient =
18538
+ (coefficient.substring(0, decimalIndex) || '0') + '.' + coefficient.substring(decimalIndex);
18539
+ }
18540
+ return sign + coefficient;
18541
+ }
18542
+ /**
18543
+ * This method is required to round prop value to given scale.
18544
+ * Not used .round or .fixedTo because that will break with big numbers
18545
+ */
18546
+ function roundToPrecision(numStr, scale, fixedDecimalScale) {
18547
+ //if number is empty don't do anything return empty string
18548
+ if (['', '-'].indexOf(numStr) !== -1)
18549
+ { return numStr; }
18550
+ var shouldHaveDecimalSeparator = (numStr.indexOf('.') !== -1 || fixedDecimalScale) && scale;
18551
+ var ref = splitDecimal(numStr);
18552
+ var beforeDecimal = ref.beforeDecimal;
18553
+ var afterDecimal = ref.afterDecimal;
18554
+ var hasNegation = ref.hasNegation;
18555
+ var floatValue = parseFloat(("0." + (afterDecimal || '0')));
18556
+ var floatValueStr = afterDecimal.length <= scale ? ("0." + afterDecimal) : floatValue.toFixed(scale);
18557
+ var roundedDecimalParts = floatValueStr.split('.');
18558
+ var intPart = beforeDecimal
18559
+ .split('')
18560
+ .reverse()
18561
+ .reduce(function (roundedStr, current, idx) {
18562
+ if (roundedStr.length > idx) {
18563
+ return ((Number(roundedStr[0]) + Number(current)).toString() +
18564
+ roundedStr.substring(1, roundedStr.length));
18565
+ }
18566
+ return current + roundedStr;
18567
+ }, roundedDecimalParts[0]);
18568
+ var decimalPart = limitToScale(roundedDecimalParts[1] || '', scale, fixedDecimalScale);
18569
+ var negation = hasNegation ? '-' : '';
18570
+ var decimalSeparator = shouldHaveDecimalSeparator ? '.' : '';
18571
+ return ("" + negation + intPart + decimalSeparator + decimalPart);
18572
+ }
18573
+ /** set the caret positon in an input field **/
18574
+ function setCaretPosition(el, caretPos) {
18575
+ el.value = el.value;
18576
+ // ^ this is used to not only get 'focus', but
18577
+ // to make sure we don't have it everything -selected-
18578
+ // (it causes an issue in chrome, and having it doesn't hurt any other browser)
18579
+ if (el !== null) {
18580
+ /* @ts-ignore */
18581
+ if (el.createTextRange) {
18582
+ /* @ts-ignore */
18583
+ var range = el.createTextRange();
18584
+ range.move('character', caretPos);
18585
+ range.select();
18586
+ return true;
18587
+ }
18588
+ // (el.selectionStart === 0 added for Firefox bug)
18589
+ if (el.selectionStart || el.selectionStart === 0) {
18590
+ el.focus();
18591
+ el.setSelectionRange(caretPos, caretPos);
18592
+ return true;
18593
+ }
18594
+ // fail city, fortunately this never happens (as far as I've tested) :)
18595
+ el.focus();
18596
+ return false;
18597
+ }
18598
+ }
18599
+ function findChangeRange(prevValue, newValue) {
18600
+ var i = 0, j = 0;
18601
+ var prevLength = prevValue.length;
18602
+ var newLength = newValue.length;
18603
+ while (prevValue[i] === newValue[i] && i < prevLength)
18604
+ { i++; }
18605
+ //check what has been changed from last
18606
+ while (prevValue[prevLength - 1 - j] === newValue[newLength - 1 - j] &&
18607
+ newLength - j > i &&
18608
+ prevLength - j > i) {
18609
+ j++;
18610
+ }
18611
+ return {
18612
+ from: { start: i, end: prevLength - j },
18613
+ to: { start: i, end: newLength - j },
18614
+ };
18615
+ }
18616
+ /*
18617
+ Returns a number whose value is limited to the given range
18618
+ */
18619
+ function clamp(num, min, max) {
18620
+ return Math.min(Math.max(num, min), max);
18621
+ }
18622
+ function geInputCaretPosition(el) {
18623
+ /*Max of selectionStart and selectionEnd is taken for the patch of pixel and other mobile device caret bug*/
18624
+ return Math.max(el.selectionStart, el.selectionEnd);
18625
+ }
18626
+ function addInputMode() {
18627
+ return (typeof navigator !== 'undefined' &&
18628
+ !(navigator.platform && /iPhone|iPod/.test(navigator.platform)));
18629
+ }
18630
+ function getDefaultChangeMeta(value) {
18631
+ return {
18632
+ from: {
18633
+ start: 0,
18634
+ end: 0,
18635
+ },
18636
+ to: {
18637
+ start: 0,
18638
+ end: value.length,
18639
+ },
18640
+ lastValue: '',
18641
+ };
18642
+ }
18643
+ function getCaretPosition(newFormattedValue, lastFormattedValue, curValue, curCaretPos, boundary, isValidInputCharacter) {
18644
+ /**
18645
+ * if something got inserted on empty value, add the formatted character before the current value,
18646
+ * This is to avoid the case where typed character is present on format characters
18647
+ */
18648
+ var firstAllowedPosition = boundary.findIndex(function (b) { return b; });
18649
+ var prefixFormat = newFormattedValue.slice(0, firstAllowedPosition);
18650
+ if (!lastFormattedValue && !curValue.startsWith(prefixFormat)) {
18651
+ curValue = prefixFormat + curValue;
18652
+ curCaretPos = curCaretPos + prefixFormat.length;
18653
+ }
18654
+ var curValLn = curValue.length;
18655
+ var formattedValueLn = newFormattedValue.length;
18656
+ // create index map
18657
+ var addedIndexMap = {};
18658
+ var indexMap = new Array(curValLn);
18659
+ for (var i = 0; i < curValLn; i++) {
18660
+ indexMap[i] = -1;
18661
+ for (var j = 0, jLn = formattedValueLn; j < jLn; j++) {
18662
+ if (curValue[i] === newFormattedValue[j] && addedIndexMap[j] !== true) {
18663
+ indexMap[i] = j;
18664
+ addedIndexMap[j] = true;
18665
+ break;
18666
+ }
18667
+ }
18668
+ }
18669
+ /**
18670
+ * For current caret position find closest characters (left and right side)
18671
+ * which are properly mapped to formatted value.
18672
+ * The idea is that the new caret position will exist always in the boundary of
18673
+ * that mapped index
18674
+ */
18675
+ var pos = curCaretPos;
18676
+ while (pos < curValLn && (indexMap[pos] === -1 || !isValidInputCharacter(curValue[pos]))) {
18677
+ pos++;
18678
+ }
18679
+ // if the caret position is on last keep the endIndex as last for formatted value
18680
+ var endIndex = pos === curValLn || indexMap[pos] === -1 ? formattedValueLn : indexMap[pos];
18681
+ pos = curCaretPos - 1;
18682
+ while (pos > 0 && indexMap[pos] === -1)
18683
+ { pos--; }
18684
+ var startIndex = pos === -1 || indexMap[pos] === -1 ? 0 : indexMap[pos] + 1;
18685
+ /**
18686
+ * case where a char is added on suffix and removed from middle, example 2sq345 becoming $2,345 sq
18687
+ * there is still a mapping but the order of start index and end index is changed
18688
+ */
18689
+ if (startIndex > endIndex)
18690
+ { return endIndex; }
18691
+ /**
18692
+ * given the current caret position if it closer to startIndex
18693
+ * keep the new caret position on start index or keep it closer to endIndex
18694
+ */
18695
+ return curCaretPos - startIndex < endIndex - curCaretPos ? startIndex : endIndex;
18696
+ }
18697
+ /* This keeps the caret within typing area so people can't type in between prefix or suffix or format characters */
18698
+ function getCaretPosInBoundary(value, caretPos, boundary, direction) {
18699
+ var valLn = value.length;
18700
+ // clamp caret position to [0, value.length]
18701
+ caretPos = clamp(caretPos, 0, valLn);
18702
+ if (direction === 'left') {
18703
+ while (caretPos >= 0 && !boundary[caretPos])
18704
+ { caretPos--; }
18705
+ // if we don't find any suitable caret position on left, set it on first allowed position
18706
+ if (caretPos === -1)
18707
+ { caretPos = boundary.indexOf(true); }
18708
+ }
18709
+ else {
18710
+ while (caretPos <= valLn && !boundary[caretPos])
18711
+ { caretPos++; }
18712
+ // if we don't find any suitable caret position on right, set it on last allowed position
18713
+ if (caretPos > valLn)
18714
+ { caretPos = boundary.lastIndexOf(true); }
18715
+ }
18716
+ // if we still don't find caret position, set it at the end of value
18717
+ if (caretPos === -1)
18718
+ { caretPos = valLn; }
18719
+ return caretPos;
18720
+ }
18721
+ function caretUnknownFormatBoundary(formattedValue) {
18722
+ var boundaryAry = Array.from({ length: formattedValue.length + 1 }).map(function () { return true; });
18723
+ for (var i = 0, ln = boundaryAry.length; i < ln; i++) {
18724
+ // consider caret to be in boundary if it is before or after numeric value
18725
+ boundaryAry[i] = Boolean(charIsNumber(formattedValue[i]) || charIsNumber(formattedValue[i - 1]));
18726
+ }
18727
+ return boundaryAry;
18728
+ }
18729
+ function useInternalValues(value, defaultValue, valueIsNumericString, format, removeFormatting, onValueChange) {
18730
+ if ( onValueChange === void 0 ) onValueChange = noop;
18731
+
18732
+ var propValues = useRef();
18733
+ var getValues = usePersistentCallback(function (value) {
18734
+ var formattedValue, numAsString;
18735
+ if (isNil(value) || isNanValue(value)) {
18736
+ numAsString = '';
18737
+ formattedValue = '';
18738
+ }
18739
+ else if (typeof value === 'number' || valueIsNumericString) {
18740
+ numAsString = typeof value === 'number' ? toNumericString(value) : value;
18741
+ formattedValue = format(numAsString);
18742
+ }
18743
+ else {
18744
+ numAsString = removeFormatting(value, undefined);
18745
+ formattedValue = value;
18746
+ }
18747
+ return { formattedValue: formattedValue, numAsString: numAsString };
18748
+ });
18749
+ var ref = useState(function () {
18750
+ return getValues(defaultValue);
18751
+ });
18752
+ var values = ref[0];
18753
+ var setValues = ref[1];
18754
+ var _onValueChange = function (values, sourceInfo) {
18755
+ setValues({
18756
+ formattedValue: values.formattedValue,
18757
+ numAsString: values.value,
18758
+ });
18759
+ onValueChange(values, sourceInfo);
18760
+ };
18761
+ useMemo(function () {
18762
+ //if element is moved to uncontrolled mode, don't reset the value
18763
+ if (!isNil(value)) {
18764
+ propValues.current = getValues(value);
18765
+ setValues(propValues.current);
18766
+ }
18767
+ else {
18768
+ propValues.current = undefined;
18769
+ }
18770
+ }, [value, getValues]);
18771
+ return [values, _onValueChange];
18772
+ }
18773
+
18774
+ function defaultRemoveFormatting(value) {
18775
+ return value.replace(/[^0-9]/g, '');
18776
+ }
18777
+ function defaultFormat(value) {
18778
+ return value;
18779
+ }
18780
+ function NumberFormatBase(props) {
18781
+ var type = props.type; if ( type === void 0 ) type = 'text';
18782
+ var displayType = props.displayType; if ( displayType === void 0 ) displayType = 'input';
18783
+ var customInput = props.customInput;
18784
+ var renderText = props.renderText;
18785
+ var getInputRef = props.getInputRef;
18786
+ var format = props.format; if ( format === void 0 ) format = defaultFormat;
18787
+ var removeFormatting = props.removeFormatting; if ( removeFormatting === void 0 ) removeFormatting = defaultRemoveFormatting;
18788
+ var defaultValue = props.defaultValue;
18789
+ var valueIsNumericString = props.valueIsNumericString;
18790
+ var onValueChange = props.onValueChange;
18791
+ var isAllowed = props.isAllowed;
18792
+ var onChange = props.onChange; if ( onChange === void 0 ) onChange = noop;
18793
+ var onKeyDown = props.onKeyDown; if ( onKeyDown === void 0 ) onKeyDown = noop;
18794
+ var onMouseUp = props.onMouseUp; if ( onMouseUp === void 0 ) onMouseUp = noop;
18795
+ var onFocus = props.onFocus; if ( onFocus === void 0 ) onFocus = noop;
18796
+ var onBlur = props.onBlur; if ( onBlur === void 0 ) onBlur = noop;
18797
+ var propValue = props.value;
18798
+ var getCaretBoundary = props.getCaretBoundary; if ( getCaretBoundary === void 0 ) getCaretBoundary = caretUnknownFormatBoundary;
18799
+ var isValidInputCharacter = props.isValidInputCharacter; if ( isValidInputCharacter === void 0 ) isValidInputCharacter = charIsNumber;
18800
+ var otherProps = __rest(props, ["type", "displayType", "customInput", "renderText", "getInputRef", "format", "removeFormatting", "defaultValue", "valueIsNumericString", "onValueChange", "isAllowed", "onChange", "onKeyDown", "onMouseUp", "onFocus", "onBlur", "value", "getCaretBoundary", "isValidInputCharacter"]);
18801
+ var ref = useInternalValues(propValue, defaultValue, Boolean(valueIsNumericString), format, removeFormatting, onValueChange);
18802
+ var ref_0 = ref[0];
18803
+ var formattedValue = ref_0.formattedValue;
18804
+ var numAsString = ref_0.numAsString;
18805
+ var onFormattedValueChange = ref[1];
18806
+ var lastUpdatedValue = useRef();
18807
+ var _onValueChange = function (values, source) {
18808
+ lastUpdatedValue.current = values.formattedValue;
18809
+ onFormattedValueChange(values, source);
18810
+ };
18811
+ // check if there is any change in the value due to props change
18812
+ useEffect(function () {
18813
+ var newFormattedValue = format(numAsString);
18814
+ // if the formatted value is not synced to parent, or if the formatted value is different
18815
+ if (lastUpdatedValue.current === undefined || newFormattedValue !== lastUpdatedValue.current) {
18816
+ var input = focusedElm.current;
18817
+ // formatting can remove some of the number chars, so we need to fine number string again
18818
+ var _numAsString = removeFormatting(newFormattedValue, undefined);
18819
+ updateValue({
18820
+ formattedValue: newFormattedValue,
18821
+ numAsString: _numAsString,
18822
+ input: input,
18823
+ setCaretPosition: true,
18824
+ source: SourceType.props,
18825
+ event: undefined,
18826
+ });
18827
+ }
18828
+ });
18829
+ var ref$1 = useState(false);
18830
+ var mounted = ref$1[0];
18831
+ var setMounted = ref$1[1];
18832
+ var focusedElm = useRef(null);
18833
+ var timeout = useRef({
18834
+ setCaretTimeout: null,
18835
+ focusTimeout: null,
18836
+ });
18837
+ useEffect(function () {
18838
+ setMounted(true);
18839
+ return function () {
18840
+ clearTimeout(timeout.current.setCaretTimeout);
18841
+ clearTimeout(timeout.current.focusTimeout);
18842
+ };
18843
+ }, []);
18844
+ var _format = format;
18845
+ var getValueObject = function (formattedValue, numAsString) {
18846
+ var floatValue = parseFloat(numAsString);
18847
+ return {
18848
+ formattedValue: formattedValue,
18849
+ value: numAsString,
18850
+ floatValue: isNaN(floatValue) ? undefined : floatValue,
18851
+ };
18852
+ };
18853
+ var setPatchedCaretPosition = function (el, caretPos, currentValue) {
18854
+ /* setting caret position within timeout of 0ms is required for mobile chrome,
18855
+ otherwise browser resets the caret position after we set it
18856
+ We are also setting it without timeout so that in normal browser we don't see the flickering */
18857
+ setCaretPosition(el, caretPos);
18858
+ timeout.current.setCaretTimeout = setTimeout(function () {
18859
+ if (el.value === currentValue)
18860
+ { setCaretPosition(el, caretPos); }
18861
+ }, 0);
18862
+ };
18863
+ /* This keeps the caret within typing area so people can't type in between prefix or suffix */
18864
+ var correctCaretPosition = function (value, caretPos, direction) {
18865
+ return getCaretPosInBoundary(value, caretPos, getCaretBoundary(value), direction);
18866
+ };
18867
+ var getNewCaretPosition = function (inputValue, newFormattedValue, caretPos) {
18868
+ var caretBoundary = getCaretBoundary(newFormattedValue);
18869
+ var updatedCaretPos = getCaretPosition(newFormattedValue, formattedValue, inputValue, caretPos, caretBoundary, isValidInputCharacter);
18870
+ //correct caret position if its outside of editable area
18871
+ updatedCaretPos = getCaretPosInBoundary(newFormattedValue, updatedCaretPos, caretBoundary);
18872
+ return updatedCaretPos;
18873
+ };
18874
+ var updateValue = function (params) {
18875
+ var newFormattedValue = params.formattedValue; if ( newFormattedValue === void 0 ) newFormattedValue = '';
18876
+ var input = params.input;
18877
+ var setCaretPosition = params.setCaretPosition; if ( setCaretPosition === void 0 ) setCaretPosition = true;
18878
+ var source = params.source;
18879
+ var event = params.event;
18880
+ var numAsString = params.numAsString;
18881
+ var caretPos = params.caretPos;
18882
+ if (input) {
18883
+ //calculate caret position if not defined
18884
+ if (caretPos === undefined && setCaretPosition) {
18885
+ var inputValue = params.inputValue || input.value;
18886
+ var currentCaretPosition = geInputCaretPosition(input);
18887
+ /**
18888
+ * set the value imperatively, this is required for IE fix
18889
+ * This is also required as if new caret position is beyond the previous value.
18890
+ * Caret position will not be set correctly
18891
+ */
18892
+ input.value = newFormattedValue;
18893
+ //get the caret position
18894
+ caretPos = getNewCaretPosition(inputValue, newFormattedValue, currentCaretPosition);
18895
+ }
18896
+ /**
18897
+ * set the value imperatively, as we set the caret position as well imperatively.
18898
+ * This is to keep value and caret position in sync
18899
+ */
18900
+ input.value = newFormattedValue;
18901
+ //set caret position, and value imperatively when element is provided
18902
+ if (setCaretPosition && caretPos !== undefined) {
18903
+ //set caret position
18904
+ setPatchedCaretPosition(input, caretPos, newFormattedValue);
18905
+ }
18906
+ }
18907
+ if (newFormattedValue !== formattedValue) {
18908
+ // trigger onValueChange synchronously, so parent is updated along with the number format. Fix for #277, #287
18909
+ _onValueChange(getValueObject(newFormattedValue, numAsString), { event: event, source: source });
18910
+ }
18911
+ };
18912
+ var formatInputValue = function (inputValue, event, source) {
18913
+ var changeRange = findChangeRange(formattedValue, inputValue);
18914
+ var changeMeta = Object.assign(Object.assign({}, changeRange), { lastValue: formattedValue });
18915
+ var _numAsString = removeFormatting(inputValue, changeMeta);
18916
+ var _formattedValue = _format(_numAsString);
18917
+ // formatting can remove some of the number chars, so we need to fine number string again
18918
+ _numAsString = removeFormatting(_formattedValue, undefined);
18919
+ if (isAllowed && !isAllowed(getValueObject(_formattedValue, _numAsString))) {
18920
+ //reset the caret position
18921
+ var input = event.target;
18922
+ var currentCaretPosition = geInputCaretPosition(input);
18923
+ var caretPos = getNewCaretPosition(inputValue, formattedValue, currentCaretPosition);
18924
+ setPatchedCaretPosition(input, caretPos, formattedValue);
18925
+ return false;
18926
+ }
18927
+ updateValue({
18928
+ formattedValue: _formattedValue,
18929
+ numAsString: _numAsString,
18930
+ inputValue: inputValue,
18931
+ event: event,
18932
+ source: source,
18933
+ setCaretPosition: true,
18934
+ input: event.target,
18935
+ });
18936
+ return true;
18937
+ };
18938
+ var _onChange = function (e) {
18939
+ var el = e.target;
18940
+ var inputValue = el.value;
18941
+ var changed = formatInputValue(inputValue, e, SourceType.event);
18942
+ if (changed)
18943
+ { onChange(e); }
18944
+ };
18945
+ var _onKeyDown = function (e) {
18946
+ var el = e.target;
18947
+ var key = e.key;
18948
+ var selectionStart = el.selectionStart;
18949
+ var selectionEnd = el.selectionEnd;
18950
+ var value = el.value; if ( value === void 0 ) value = '';
18951
+ var expectedCaretPosition;
18952
+ //Handle backspace and delete against non numerical/decimal characters or arrow keys
18953
+ if (key === 'ArrowLeft' || key === 'Backspace') {
18954
+ expectedCaretPosition = Math.max(selectionStart - 1, 0);
18955
+ }
18956
+ else if (key === 'ArrowRight') {
18957
+ expectedCaretPosition = Math.min(selectionStart + 1, value.length);
18958
+ }
18959
+ else if (key === 'Delete') {
18960
+ expectedCaretPosition = selectionStart;
18961
+ }
18962
+ //if expectedCaretPosition is not set it means we don't want to Handle keyDown
18963
+ // also if multiple characters are selected don't handle
18964
+ if (expectedCaretPosition === undefined || selectionStart !== selectionEnd) {
18965
+ onKeyDown(e);
18966
+ return;
18967
+ }
18968
+ var newCaretPosition = expectedCaretPosition;
18969
+ if (key === 'ArrowLeft' || key === 'ArrowRight') {
18970
+ var direction = key === 'ArrowLeft' ? 'left' : 'right';
18971
+ newCaretPosition = correctCaretPosition(value, expectedCaretPosition, direction);
18972
+ }
18973
+ else if (key === 'Delete' && !isValidInputCharacter(value[expectedCaretPosition])) {
18974
+ // in case of delete go to closest caret boundary on the right side
18975
+ newCaretPosition = correctCaretPosition(value, expectedCaretPosition, 'right');
18976
+ }
18977
+ else if (key === 'Backspace' && !isValidInputCharacter(value[expectedCaretPosition])) {
18978
+ // in case of backspace go to closest caret boundary on the left side
18979
+ newCaretPosition = correctCaretPosition(value, expectedCaretPosition, 'left');
18980
+ }
18981
+ if (newCaretPosition !== expectedCaretPosition) {
18982
+ setPatchedCaretPosition(el, newCaretPosition, value);
18983
+ }
18984
+ /* NOTE: this is just required for unit test as we need to get the newCaretPosition,
18985
+ Remove this when you find different solution */
18986
+ /* @ts-ignore */
18987
+ if (e.isUnitTestRun) {
18988
+ setPatchedCaretPosition(el, newCaretPosition, value);
18989
+ }
18990
+ onKeyDown(e);
18991
+ };
18992
+ /** required to handle the caret position when click anywhere within the input **/
18993
+ var _onMouseUp = function (e) {
18994
+ var el = e.target;
18995
+ /**
18996
+ * NOTE: we have to give default value for value as in case when custom input is provided
18997
+ * value can come as undefined when nothing is provided on value prop.
18998
+ */
18999
+ var selectionStart = el.selectionStart;
19000
+ var selectionEnd = el.selectionEnd;
19001
+ var value = el.value; if ( value === void 0 ) value = '';
19002
+ if (selectionStart === selectionEnd) {
19003
+ var caretPosition = correctCaretPosition(value, selectionStart);
19004
+ if (caretPosition !== selectionStart) {
19005
+ setPatchedCaretPosition(el, caretPosition, value);
19006
+ }
19007
+ }
19008
+ onMouseUp(e);
19009
+ };
19010
+ var _onFocus = function (e) {
19011
+ // Workaround Chrome and Safari bug https://bugs.chromium.org/p/chromium/issues/detail?id=779328
19012
+ // (onFocus event target selectionStart is always 0 before setTimeout)
19013
+ if (e.persist)
19014
+ { e.persist(); }
19015
+ var el = e.target;
19016
+ focusedElm.current = el;
19017
+ timeout.current.focusTimeout = setTimeout(function () {
19018
+ var selectionStart = el.selectionStart;
19019
+ var selectionEnd = el.selectionEnd;
19020
+ var value = el.value; if ( value === void 0 ) value = '';
19021
+ var caretPosition = correctCaretPosition(value, selectionStart);
19022
+ //setPatchedCaretPosition only when everything is not selected on focus (while tabbing into the field)
19023
+ if (caretPosition !== selectionStart &&
19024
+ !(selectionStart === 0 && selectionEnd === value.length)) {
19025
+ setPatchedCaretPosition(el, caretPosition, value);
19026
+ }
19027
+ onFocus(e);
19028
+ }, 0);
19029
+ };
19030
+ var _onBlur = function (e) {
19031
+ focusedElm.current = null;
19032
+ clearTimeout(timeout.current.focusTimeout);
19033
+ clearTimeout(timeout.current.setCaretTimeout);
19034
+ onBlur(e);
19035
+ };
19036
+ // add input mode on element based on format prop and device once the component is mounted
19037
+ var inputMode = mounted && addInputMode() ? 'numeric' : undefined;
19038
+ var inputProps = Object.assign({ inputMode: inputMode }, otherProps, {
19039
+ type: type,
19040
+ value: formattedValue,
19041
+ onChange: _onChange,
19042
+ onKeyDown: _onKeyDown,
19043
+ onMouseUp: _onMouseUp,
19044
+ onFocus: _onFocus,
19045
+ onBlur: _onBlur,
19046
+ });
19047
+ if (displayType === 'text') {
19048
+ return renderText ? (React.createElement(React.Fragment, null, renderText(formattedValue, otherProps) || null)) : (React.createElement("span", Object.assign({}, otherProps, { ref: getInputRef }), formattedValue));
19049
+ }
19050
+ else if (customInput) {
19051
+ var CustomInput = customInput;
19052
+ /* @ts-ignore */
19053
+ return React.createElement(CustomInput, Object.assign({}, inputProps, { ref: getInputRef }));
19054
+ }
19055
+ return React.createElement("input", Object.assign({}, inputProps, { ref: getInputRef }));
19056
+ }
19057
+
19058
+ function format(numStr, props) {
19059
+ var decimalScale = props.decimalScale;
19060
+ var fixedDecimalScale = props.fixedDecimalScale;
19061
+ var prefix = props.prefix; if ( prefix === void 0 ) prefix = '';
19062
+ var suffix = props.suffix; if ( suffix === void 0 ) suffix = '';
19063
+ var allowNegative = props.allowNegative; if ( allowNegative === void 0 ) allowNegative = true;
19064
+ var thousandsGroupStyle = props.thousandsGroupStyle; if ( thousandsGroupStyle === void 0 ) thousandsGroupStyle = 'thousand';
19065
+ // don't apply formatting on empty string or '-'
19066
+ if (numStr === '' || numStr === '-') {
19067
+ return numStr;
19068
+ }
19069
+ var ref = getSeparators(props);
19070
+ var thousandSeparator = ref.thousandSeparator;
19071
+ var decimalSeparator = ref.decimalSeparator;
19072
+ /**
19073
+ * Keep the decimal separator
19074
+ * when decimalScale is not defined or non zero and the numStr has decimal in it
19075
+ * Or if decimalScale is > 0 and fixeDecimalScale is true (even if numStr has no decimal)
19076
+ */
19077
+ var hasDecimalSeparator = (decimalScale !== 0 && numStr.indexOf('.') !== -1) || (decimalScale && fixedDecimalScale);
19078
+ var ref$1 = splitDecimal(numStr, allowNegative);
19079
+ var beforeDecimal = ref$1.beforeDecimal;
19080
+ var afterDecimal = ref$1.afterDecimal;
19081
+ var addNegation = ref$1.addNegation; // eslint-disable-line prefer-const
19082
+ //apply decimal precision if its defined
19083
+ if (decimalScale !== undefined) {
19084
+ afterDecimal = limitToScale(afterDecimal, decimalScale, !!fixedDecimalScale);
19085
+ }
19086
+ if (thousandSeparator) {
19087
+ beforeDecimal = applyThousandSeparator(beforeDecimal, thousandSeparator, thousandsGroupStyle);
19088
+ }
19089
+ //add prefix and suffix when there is a number present
19090
+ if (prefix)
19091
+ { beforeDecimal = prefix + beforeDecimal; }
19092
+ if (suffix)
19093
+ { afterDecimal = afterDecimal + suffix; }
19094
+ //restore negation sign
19095
+ if (addNegation)
19096
+ { beforeDecimal = '-' + beforeDecimal; }
19097
+ numStr = beforeDecimal + ((hasDecimalSeparator && decimalSeparator) || '') + afterDecimal;
19098
+ return numStr;
19099
+ }
19100
+ function getSeparators(props) {
19101
+ var decimalSeparator = props.decimalSeparator; if ( decimalSeparator === void 0 ) decimalSeparator = '.';
19102
+ var thousandSeparator = props.thousandSeparator;
19103
+ var allowedDecimalSeparators = props.allowedDecimalSeparators;
19104
+ if (thousandSeparator === true) {
19105
+ thousandSeparator = ',';
19106
+ }
19107
+ if (!allowedDecimalSeparators) {
19108
+ allowedDecimalSeparators = [decimalSeparator, '.'];
19109
+ }
19110
+ return {
19111
+ decimalSeparator: decimalSeparator,
19112
+ thousandSeparator: thousandSeparator,
19113
+ allowedDecimalSeparators: allowedDecimalSeparators,
19114
+ };
19115
+ }
19116
+ function handleNegation(value, allowNegative) {
19117
+ if ( value === void 0 ) value = '';
19118
+
19119
+ var negationRegex = new RegExp('(-)');
19120
+ var doubleNegationRegex = new RegExp('(-)(.)*(-)');
19121
+ // Check number has '-' value
19122
+ var hasNegation = negationRegex.test(value);
19123
+ // Check number has 2 or more '-' values
19124
+ var removeNegation = doubleNegationRegex.test(value);
19125
+ //remove negation
19126
+ value = value.replace(/-/g, '');
19127
+ if (hasNegation && !removeNegation && allowNegative) {
19128
+ value = '-' + value;
19129
+ }
19130
+ return value;
19131
+ }
19132
+ function getNumberRegex(decimalSeparator, global) {
19133
+ return new RegExp(("(^-)|[0-9]|" + (escapeRegExp(decimalSeparator))), global ? 'g' : undefined);
19134
+ }
19135
+ function removeFormatting(value, changeMeta, props) {
19136
+ if ( changeMeta === void 0 ) changeMeta = getDefaultChangeMeta(value);
19137
+
19138
+ var allowNegative = props.allowNegative; if ( allowNegative === void 0 ) allowNegative = true;
19139
+ var prefix = props.prefix; if ( prefix === void 0 ) prefix = '';
19140
+ var suffix = props.suffix; if ( suffix === void 0 ) suffix = '';
19141
+ var decimalScale = props.decimalScale;
19142
+ var from = changeMeta.from;
19143
+ var to = changeMeta.to;
19144
+ var start = to.start;
19145
+ var end = to.end;
19146
+ var ref = getSeparators(props);
19147
+ var allowedDecimalSeparators = ref.allowedDecimalSeparators;
19148
+ var decimalSeparator = ref.decimalSeparator;
19149
+ var isBeforeDecimalSeparator = value[end] === decimalSeparator;
19150
+ /** Check for any allowed decimal separator is added in the numeric format and replace it with decimal separator */
19151
+ if (end - start === 1 && allowedDecimalSeparators.indexOf(value[start]) !== -1) {
19152
+ var separator = decimalScale === 0 ? '' : decimalSeparator;
19153
+ value = value.substring(0, start) + separator + value.substring(start + 1, value.length);
19154
+ }
19155
+ var hasNegation = false;
19156
+ /**
19157
+ * if prefix starts with - the number hast to have two - at the start
19158
+ * if suffix starts with - and the value length is same as suffix length, then the - sign is from the suffix
19159
+ * In other cases, if the value starts with - then it is a negation
19160
+ */
19161
+ if (prefix.startsWith('-'))
19162
+ { hasNegation = value.startsWith('--'); }
19163
+ else if (suffix.startsWith('-') && value.length === suffix.length)
19164
+ { hasNegation = false; }
19165
+ else if (value[0] === '-')
19166
+ { hasNegation = true; }
19167
+ // remove negation from start to simplify prefix logic as negation comes before prefix
19168
+ if (hasNegation) {
19169
+ value = value.substring(1);
19170
+ // account for the removal of the negation for start and end index
19171
+ start -= 1;
19172
+ end -= 1;
19173
+ }
19174
+ /**
19175
+ * remove prefix
19176
+ * Remove whole prefix part if its present on the value
19177
+ * If the prefix is partially deleted (in which case change start index will be less the prefix length)
19178
+ * Remove only partial part of prefix.
19179
+ */
19180
+ var startIndex = 0;
19181
+ if (value.startsWith(prefix))
19182
+ { startIndex += prefix.length; }
19183
+ else if (start < prefix.length)
19184
+ { startIndex = start; }
19185
+ value = value.substring(startIndex);
19186
+ // account for deleted prefix for end index
19187
+ end -= startIndex;
19188
+ /**
19189
+ * Remove suffix
19190
+ * Remove whole suffix part if its present on the value
19191
+ * If the suffix is partially deleted (in which case change end index will be greater than the suffixStartIndex)
19192
+ * remove the partial part of suffix
19193
+ */
19194
+ var endIndex = value.length;
19195
+ var suffixStartIndex = value.length - suffix.length;
19196
+ if (value.endsWith(suffix))
19197
+ { endIndex = suffixStartIndex; }
19198
+ else if (end > value.length - suffix.length)
19199
+ { endIndex = end; }
19200
+ value = value.substring(0, endIndex);
19201
+ // add the negation back and handle for double negation
19202
+ value = handleNegation(hasNegation ? ("-" + value) : value, allowNegative);
19203
+ // remove non numeric characters
19204
+ value = (value.match(getNumberRegex(decimalSeparator, true)) || []).join('');
19205
+ // replace the decimalSeparator with ., and only keep the first separator, ignore following ones
19206
+ var firstIndex = value.indexOf(decimalSeparator);
19207
+ value = value.replace(new RegExp(escapeRegExp(decimalSeparator), 'g'), function (match, index) {
19208
+ return index === firstIndex ? '.' : '';
19209
+ });
19210
+ //check if beforeDecimal got deleted and there is nothing after decimal,
19211
+ //clear all numbers in such case while keeping the - sign
19212
+ var ref$1 = splitDecimal(value, allowNegative);
19213
+ var beforeDecimal = ref$1.beforeDecimal;
19214
+ var afterDecimal = ref$1.afterDecimal;
19215
+ var addNegation = ref$1.addNegation; // eslint-disable-line prefer-const
19216
+ //clear only if something got deleted before decimal (cursor is before decimal)
19217
+ if (to.end - to.start < from.end - from.start &&
19218
+ beforeDecimal === '' &&
19219
+ isBeforeDecimalSeparator &&
19220
+ !parseFloat(afterDecimal)) {
19221
+ value = addNegation ? '-' : '';
19222
+ }
19223
+ return value;
19224
+ }
19225
+ function getCaretBoundary(formattedValue, props) {
19226
+ var prefix = props.prefix; if ( prefix === void 0 ) prefix = '';
19227
+ var suffix = props.suffix; if ( suffix === void 0 ) suffix = '';
19228
+ var boundaryAry = Array.from({ length: formattedValue.length + 1 }).map(function () { return true; });
19229
+ var hasNegation = formattedValue[0] === '-';
19230
+ // fill for prefix and negation
19231
+ boundaryAry.fill(false, 0, prefix.length + (hasNegation ? 1 : 0));
19232
+ // fill for suffix
19233
+ var valLn = formattedValue.length;
19234
+ boundaryAry.fill(false, valLn - suffix.length + 1, valLn + 1);
19235
+ return boundaryAry;
19236
+ }
19237
+ function validateProps(props) {
19238
+ var ref = getSeparators(props);
19239
+ var thousandSeparator = ref.thousandSeparator;
19240
+ var decimalSeparator = ref.decimalSeparator;
19241
+ if (thousandSeparator === decimalSeparator) {
19242
+ throw new Error(("\n Decimal separator can't be same as thousand separator.\n thousandSeparator: " + thousandSeparator + " (thousandSeparator = {true} is same as thousandSeparator = \",\")\n decimalSeparator: " + decimalSeparator + " (default value for decimalSeparator is .)\n "));
19243
+ }
19244
+ }
19245
+ function useNumericFormat(props) {
19246
+ var decimalSeparator = props.decimalSeparator; if ( decimalSeparator === void 0 ) decimalSeparator = '.';
19247
+ var allowLeadingZeros = props.allowLeadingZeros;
19248
+ var onKeyDown = props.onKeyDown; if ( onKeyDown === void 0 ) onKeyDown = noop;
19249
+ var onBlur = props.onBlur; if ( onBlur === void 0 ) onBlur = noop;
19250
+ var thousandSeparator = props.thousandSeparator;
19251
+ var decimalScale = props.decimalScale;
19252
+ var fixedDecimalScale = props.fixedDecimalScale;
19253
+ var prefix = props.prefix; if ( prefix === void 0 ) prefix = '';
19254
+ var defaultValue = props.defaultValue;
19255
+ var value = props.value;
19256
+ var valueIsNumericString = props.valueIsNumericString;
19257
+ var onValueChange = props.onValueChange;
19258
+ var restProps = __rest(props, ["decimalSeparator", "allowedDecimalSeparators", "thousandsGroupStyle", "suffix", "allowNegative", "allowLeadingZeros", "onKeyDown", "onBlur", "thousandSeparator", "decimalScale", "fixedDecimalScale", "prefix", "defaultValue", "value", "valueIsNumericString", "onValueChange"]);
19259
+ // validate props
19260
+ validateProps(props);
19261
+ var _format = function (numStr) { return format(numStr, props); };
19262
+ var _removeFormatting = function (inputValue, changeMeta) { return removeFormatting(inputValue, changeMeta, props); };
19263
+ var _valueIsNumericString = valueIsNumericString;
19264
+ if (!isNil(value)) {
19265
+ _valueIsNumericString = valueIsNumericString !== null && valueIsNumericString !== void 0 ? valueIsNumericString : typeof value === 'number';
19266
+ }
19267
+ else if (!isNil(defaultValue)) {
19268
+ _valueIsNumericString = valueIsNumericString !== null && valueIsNumericString !== void 0 ? valueIsNumericString : typeof defaultValue === 'number';
19269
+ }
19270
+ var roundIncomingValueToPrecision = function (value) {
19271
+ if (isNil(value) || isNanValue(value))
19272
+ { return value; }
19273
+ if (typeof value === 'number') {
19274
+ value = toNumericString(value);
19275
+ }
19276
+ /**
19277
+ * only round numeric or float string values coming through props,
19278
+ * we don't need to do it for onChange events, as we want to prevent typing there
19279
+ */
19280
+ if (_valueIsNumericString && typeof decimalScale === 'number') {
19281
+ return roundToPrecision(value, decimalScale, Boolean(fixedDecimalScale));
19282
+ }
19283
+ return value;
19284
+ };
19285
+ var ref = useInternalValues(roundIncomingValueToPrecision(value), roundIncomingValueToPrecision(defaultValue), Boolean(_valueIsNumericString), _format, _removeFormatting, onValueChange);
19286
+ var ref_0 = ref[0];
19287
+ var numAsString = ref_0.numAsString;
19288
+ var formattedValue = ref_0.formattedValue;
19289
+ var _onValueChange = ref[1];
19290
+ var _onKeyDown = function (e) {
19291
+ var el = e.target;
19292
+ var key = e.key;
19293
+ var selectionStart = el.selectionStart;
19294
+ var selectionEnd = el.selectionEnd;
19295
+ var value = el.value; if ( value === void 0 ) value = '';
19296
+ // if multiple characters are selected and user hits backspace, no need to handle anything manually
19297
+ if (selectionStart !== selectionEnd) {
19298
+ onKeyDown(e);
19299
+ return;
19300
+ }
19301
+ // if user hits backspace, while the cursor is before prefix, and the input has negation, remove the negation
19302
+ if (key === 'Backspace' && value[0] === '-' && selectionStart === prefix.length + 1) {
19303
+ // bring the cursor to after negation
19304
+ setCaretPosition(el, 1);
19305
+ }
19306
+ // don't allow user to delete decimal separator when decimalScale and fixedDecimalScale is set
19307
+ var ref = getSeparators(props);
19308
+ var decimalSeparator = ref.decimalSeparator;
19309
+ var allowedDecimalSeparators = ref.allowedDecimalSeparators;
19310
+ if (key === 'Backspace' &&
19311
+ value[selectionStart - 1] === decimalSeparator &&
19312
+ decimalScale &&
19313
+ fixedDecimalScale) {
19314
+ setCaretPosition(el, selectionStart - 1);
19315
+ e.preventDefault();
19316
+ }
19317
+ // if user presses the allowed decimal separator before the separator, move the cursor after the separator
19318
+ if ((allowedDecimalSeparators === null || allowedDecimalSeparators === void 0 ? void 0 : allowedDecimalSeparators.includes(key)) && value[selectionStart] === decimalSeparator) {
19319
+ setCaretPosition(el, selectionStart + 1);
19320
+ }
19321
+ var _thousandSeparator = thousandSeparator === true ? ',' : thousandSeparator;
19322
+ // move cursor when delete or backspace is pressed before/after thousand separator
19323
+ if (key === 'Backspace' && value[selectionStart - 1] === _thousandSeparator) {
19324
+ setCaretPosition(el, selectionStart - 1);
19325
+ }
19326
+ if (key === 'Delete' && value[selectionStart] === _thousandSeparator) {
19327
+ setCaretPosition(el, selectionStart + 1);
19328
+ }
19329
+ onKeyDown(e);
19330
+ };
19331
+ var _onBlur = function (e) {
19332
+ var _value = numAsString;
19333
+ // if there no no numeric value, clear the input
19334
+ if (!_value.match(/\d/g)) {
19335
+ _value = '';
19336
+ }
19337
+ // clear leading 0s
19338
+ if (!allowLeadingZeros) {
19339
+ _value = fixLeadingZero(_value);
19340
+ }
19341
+ // apply fixedDecimalScale on blur event
19342
+ if (fixedDecimalScale && decimalScale) {
19343
+ _value = roundToPrecision(_value, decimalScale, fixedDecimalScale);
19344
+ }
19345
+ if (_value !== numAsString) {
19346
+ var formattedValue = format(_value, props);
19347
+ _onValueChange({
19348
+ formattedValue: formattedValue,
19349
+ value: _value,
19350
+ floatValue: parseFloat(_value),
19351
+ }, {
19352
+ event: e,
19353
+ source: SourceType.event,
19354
+ });
19355
+ }
19356
+ onBlur(e);
19357
+ };
19358
+ var isValidInputCharacter = function (inputChar) {
19359
+ if (inputChar === decimalSeparator)
19360
+ { return true; }
19361
+ return charIsNumber(inputChar);
19362
+ };
19363
+ return Object.assign(Object.assign({}, restProps), { value: formattedValue, valueIsNumericString: false, isValidInputCharacter: isValidInputCharacter, onValueChange: _onValueChange, format: _format, removeFormatting: _removeFormatting, getCaretBoundary: function (formattedValue) { return getCaretBoundary(formattedValue, props); }, onKeyDown: _onKeyDown, onBlur: _onBlur });
19364
+ }
19365
+ function NumericFormat(props) {
19366
+ var numericFormatProps = useNumericFormat(props);
19367
+ return React.createElement(NumberFormatBase, Object.assign({}, numericFormatProps));
19368
+ }
19369
+
19370
+ const TextWidgetBase = ({
19371
+ id,
19372
+ onChange,
19373
+ readonly,
19374
+ options: _options = {},
19375
+ disabled,
19376
+ required,
19377
+ value,
19378
+ uiSchema: _uiSchema = {},
19379
+ schema: _schema = {},
19380
+ overrideProps: _overrideProps = i => i
19381
+ }) => {
19382
+ var _uiSchema$uiOptions;
19383
+ // INFO: debouncing added for performance concerns
19384
+ const handleChange = useDebounceCallback(e => {
19385
+ onChange(e.target.value || undefined);
19386
+ }, 100);
19387
+ const {
19388
+ error
19389
+ } = useFormControl();
19390
+ const message = ((_uiSchema$uiOptions = _uiSchema["ui:options"]) == null ? void 0 : _uiSchema$uiOptions.message) || undefined;
19391
+ const messageProps = {
19392
+ title: (message == null ? void 0 : message.title) || undefined,
19393
+ description: (message == null ? void 0 : message.description) || undefined,
19394
+ type: (message == null ? void 0 : message.type) || "info",
19395
+ canDismiss: (message == null ? void 0 : message.canDismiss) || true
19396
+ };
19397
+ const {
19398
+ format: type,
19399
+ placeholder,
19400
+ title: label
19401
+ } = _schema;
19402
+ const InputProps = {
19403
+ readOnly: readonly,
19404
+ startAdornment: _options.prefix ? /*#__PURE__*/jsx(InputAdornment, {
19405
+ position: "start",
19406
+ style: {
19407
+ fontSize: 14
19408
+ },
19409
+ children: _options.prefix
19410
+ }) : null,
19411
+ endAdornment: _options.suffix ? /*#__PURE__*/jsx(InputAdornment, {
19412
+ position: "end",
19413
+ style: {
19414
+ fontSize: 14
19415
+ },
19416
+ children: _options.suffix
19417
+ }) : null
19418
+ };
19419
+ const componentProps = _extends({
19420
+ id,
19421
+ error,
19422
+ disabled,
19423
+ label,
19424
+ placeholder,
19425
+ required,
19426
+ // INFO: for performance concerns, textfield is NOT controlled field.
19427
+ // This will prevent his field to be changed outside of once concurrency
19428
+ // pattern implemented with React 18, it can be controlled as other
19429
+ // fields value={props.value || ""} onChange={(event) =>
19430
+ // props.onChange(event.target.value || null)} value: props.value,
19431
+ defaultValue: value,
19432
+ onChange: handleChange,
19433
+ autoComplete: "off",
19434
+ variant: "outlined",
19435
+ InputProps,
19436
+ sx: {
19437
+ width: "100%"
19438
+ },
19439
+ type
19440
+ }, _uiSchema["ui:props"]);
19441
+ return /*#__PURE__*/jsxs(Fragment, {
19442
+ children: [/*#__PURE__*/jsx(TextField, _extends({}, _overrideProps(componentProps))), message && /*#__PURE__*/jsx(Alert, _extends({
19443
+ sx: {
19444
+ mt: 1
19445
+ }
19446
+ }, messageProps))]
19447
+ });
19448
+ };
19449
+ TextWidgetBase.propTypes = {
19450
+ disabled: PropTypes.any,
19451
+ id: PropTypes.any,
19452
+ onChange: PropTypes.func,
19453
+ options: PropTypes.shape({
19454
+ prefix: PropTypes.any,
19455
+ suffix: PropTypes.any
19456
+ }),
19457
+ rawErrors: PropTypes.array,
19458
+ readonly: PropTypes.any,
19459
+ required: PropTypes.bool,
19460
+ schema: PropTypes.shape({
19461
+ format: PropTypes.any,
19462
+ placeholder: PropTypes.any,
19463
+ title: PropTypes.any
19464
+ }),
19465
+ uiSchema: PropTypes.any,
19466
+ value: PropTypes.any,
19467
+ overrideProps: PropTypes.func
19468
+ };
19469
+
19470
+ const _excluded = ["onChange"];
19471
+ const TextWidgetReadOnly$1 = props => {
19472
+ const {
19473
+ options: {
19474
+ prefix = "$",
19475
+ decimalScale = 2,
19476
+ thousandSeparator = ",",
19477
+ decimalSeparator = ".",
19478
+ allowNegative = true
19479
+ }
19480
+ } = props;
19481
+ const {
19482
+ value
19483
+ } = useNumericFormat({
19484
+ value: props.value,
19485
+ decimalScale,
19486
+ thousandSeparator,
19487
+ decimalSeparator,
19488
+ allowNegative
19489
+ });
19490
+ const formattedValue = `${prefix === null ? "" : prefix}${value}`;
19491
+ const _value = props.value == undefined ? props.value : formattedValue;
19492
+ return /*#__PURE__*/jsx(ReadOnlyView, {
19493
+ label: props.schema.title,
19494
+ value: _value
19495
+ });
19496
+ };
19497
+ TextWidgetReadOnly$1.propTypes = {
19498
+ schema: PropTypes.any,
19499
+ value: PropTypes.any
19500
+ };
19501
+ const CurrencyWidget = props => {
19502
+ var _options$prefix;
19503
+ const {
19504
+ options
19505
+ } = props;
19506
+ const prefix = (_options$prefix = options.prefix) != null ? _options$prefix : "$";
19507
+ const {
19508
+ options: {
19509
+ // INFO: default values
19510
+ decimalScale = 2,
19511
+ thousandSeparator = ",",
19512
+ decimalSeparator = ".",
19513
+ allowNegative = true
19514
+ }
19515
+ } = props;
19516
+ const NumberFormatCustom = useMemo(() => {
19517
+ return /*#__PURE__*/React.forwardRef(function NumberFormatCustom(props, ref) {
19518
+ const {
19519
+ onChange
19520
+ } = props,
19521
+ rest = _objectWithoutPropertiesLoose(props, _excluded);
19522
+ return /*#__PURE__*/jsx(NumericFormat, _extends({}, rest, {
19523
+ getInputRef: ref,
19524
+ onValueChange: values => {
19525
+ onChange({
19526
+ target: {
19527
+ name: props.name,
19528
+ value: values.value
19529
+ }
19530
+ });
19531
+ },
19532
+ decimalScale: decimalScale,
19533
+ fixedDecimalScale: decimalScale,
19534
+ thousandSeparator: thousandSeparator,
19535
+ decimalSeparator: decimalSeparator,
19536
+ allowNegative: allowNegative,
19537
+ placeholder: props.placeholder
19538
+ }));
19539
+ });
19540
+ }, [decimalScale, thousandSeparator, decimalSeparator, allowNegative]);
19541
+ const overrideProps = _props => {
19542
+ return _extends({}, _props, {
19543
+ InputProps: _extends({}, props.InputProps, {
19544
+ inputComponent: NumberFormatCustom,
19545
+ startAdornment: prefix ? /*#__PURE__*/jsx(InputAdornment, {
19546
+ position: "start",
19547
+ style: {
19548
+ fontSize: 14
19549
+ },
19550
+ children: options.prefix
19551
+ }) : null
19552
+ })
19553
+ });
19554
+ };
19555
+ return /*#__PURE__*/jsx(TextWidgetBase, _extends({}, props, {
19556
+ overrideProps: overrideProps
19557
+ }));
19558
+ };
19559
+ CurrencyWidget.propTypes = TextWidgetBase.propTypes;
19560
+ const HOCs$4 = [...commonWidgetHOCs, withReadyOnly(TextWidgetReadOnly$1), withEvalDisable()];
19561
+ var CurrencyWidget$1 = compose(HOCs$4)(CurrencyWidget);
18367
19562
 
18368
19563
  const decodeHtml = html => {
18369
19564
  const textarea = document.createElement("textarea");
@@ -18525,69 +19720,20 @@ const TextareaWidgetReadOnly = props => /*#__PURE__*/jsx(ReadOnlyView, {
18525
19720
  label: props.schema.title,
18526
19721
  value: props.value
18527
19722
  });
18528
- const TextareaWidget = props => {
18529
- // INFO: debouncing added for performance concerns
18530
- const handleChange = useDebounceCallback(e => {
18531
- props.onChange(e.target.value || undefined);
18532
- }, 100);
18533
- const {
18534
- error
18535
- } = useFormControl();
18536
- return /*#__PURE__*/jsx(TextField, {
18537
- id: props.id,
18538
- error: error,
18539
- disabled: props.disabled,
18540
- label: props.schema.title,
18541
- required: props.required,
18542
- defaultValue: props.value
18543
- // INFO: for performance concerns, textfield is NOT controlled field. This will prevent his field to be changed outside of
18544
- // Once concurrency pattern implemented with React 18, it can be
18545
- // controlled as other fields value={props.value || ""}
18546
- // onChange={(event) => props.onChange(event.target.value || null)}
18547
- ,
18548
- onChange: handleChange,
18549
- autoComplete: "off",
18550
- variant: "outlined",
18551
- InputProps: {
18552
- startAdornment: props.schema.prefix ? /*#__PURE__*/jsx(InputAdornment, {
18553
- position: "start",
18554
- style: {
18555
- fontSize: 12
18556
- },
18557
- children: props.schema.prefix
18558
- }) : null,
18559
- endAdornment: props.schema.suffix ? /*#__PURE__*/jsx(InputAdornment, {
18560
- position: "end",
18561
- style: {
18562
- fontSize: 12
18563
- },
18564
- children: props.schema.suffix
18565
- }) : null
18566
- },
18567
- sx: {
18568
- width: "100%"
18569
- },
18570
- type: props.schema.format,
18571
- placeholder: props.schema.placeholder,
18572
- multiline: true,
18573
- rows: 5
18574
- });
19723
+ TextareaWidgetReadOnly.propTypes = {
19724
+ schema: PropTypes.any,
19725
+ value: PropTypes.any
18575
19726
  };
18576
- TextareaWidget.propTypes = {
18577
- id: PropTypes.any,
18578
- onChange: PropTypes.func,
18579
- rawErrors: PropTypes.array,
18580
- disabled: PropTypes.bool,
18581
- required: PropTypes.any,
18582
- schema: PropTypes.shape({
18583
- disabled: PropTypes.any,
18584
- format: PropTypes.any,
18585
- placeholder: PropTypes.any,
18586
- prefix: PropTypes.any,
18587
- suffix: PropTypes.any,
18588
- title: PropTypes.any
18589
- }),
18590
- value: PropTypes.string
19727
+ const TextareaWidget = props => {
19728
+ const overrideProps = useCallback(rest => {
19729
+ return _extends({}, rest, {
19730
+ multiline: true,
19731
+ rows: 5
19732
+ });
19733
+ }, []);
19734
+ return /*#__PURE__*/jsx(TextWidgetBase, _extends({}, props, {
19735
+ overrideProps: overrideProps
19736
+ }));
18591
19737
  };
18592
19738
  const HOCs$2 = [...commonWidgetHOCs, withReadyOnly(TextareaWidgetReadOnly)];
18593
19739
  var TextareaWidget$1 = compose(HOCs$2)(TextareaWidget);
@@ -18600,92 +19746,9 @@ TextWidgetReadOnly.propTypes = {
18600
19746
  schema: PropTypes.any,
18601
19747
  value: PropTypes.any
18602
19748
  };
18603
- const TextWidget = props => {
18604
- var _props$uiSchema$uiOp;
18605
- // INFO: debouncing added for performance concerns
18606
- const handleChange = useDebounceCallback(e => {
18607
- props.onChange(e.target.value || undefined);
18608
- }, 100);
18609
- const {
18610
- error
18611
- } = useFormControl();
18612
- const message = ((_props$uiSchema$uiOp = props.uiSchema["ui:options"]) == null ? void 0 : _props$uiSchema$uiOp.message) || undefined;
18613
- const messageProps = {
18614
- title: (message == null ? void 0 : message.title) || undefined,
18615
- description: (message == null ? void 0 : message.description) || undefined,
18616
- type: (message == null ? void 0 : message.type) || "info",
18617
- canDismiss: (message == null ? void 0 : message.canDismiss) || true
18618
- };
18619
- return /*#__PURE__*/jsxs(Fragment, {
18620
- children: [/*#__PURE__*/jsx(TextField, {
18621
- id: props.id,
18622
- error: error,
18623
- disabled: props.disabled,
18624
- label: props.schema.title,
18625
- required: props.required,
18626
- defaultValue: props.value
18627
- // value={props.value}
18628
- // INFO: for performance concerns, textfield is NOT controlled field. This will prevent his field to be changed outside of
18629
- // Once concurrency pattern implemented with React 18, it can be
18630
- // controlled as other fields value={props.value || ""}
18631
- // onChange={(event) => props.onChange(event.target.value || null)}
18632
- ,
18633
- onChange: handleChange,
18634
- autoComplete: "off",
18635
- variant: "outlined",
18636
- InputProps: {
18637
- readOnly: props.readonly,
18638
- startAdornment: props.options.prefix ? /*#__PURE__*/jsx(InputAdornment, {
18639
- position: "start",
18640
- style: {
18641
- fontSize: 14
18642
- },
18643
- children: props.options.prefix
18644
- }) : null,
18645
- endAdornment: props.options.suffix ? /*#__PURE__*/jsx(InputAdornment, {
18646
- position: "end",
18647
- style: {
18648
- fontSize: 14
18649
- },
18650
- children: props.options.suffix
18651
- }) : null
18652
- },
18653
- sx: {
18654
- width: "100%"
18655
- },
18656
- type: props.schema.format,
18657
- placeholder: props.schema.placeholder
18658
- }), message && /*#__PURE__*/jsx(Alert, _extends({
18659
- sx: {
18660
- mt: 1
18661
- }
18662
- }, messageProps))]
18663
- });
18664
- };
18665
- TextWidget.defaultProps = {
18666
- uiSchema: {}
18667
- };
18668
- TextWidget.propTypes = {
18669
- disabled: PropTypes.any,
18670
- id: PropTypes.any,
18671
- onChange: PropTypes.func,
18672
- options: PropTypes.shape({
18673
- prefix: PropTypes.any,
18674
- suffix: PropTypes.any
18675
- }),
18676
- rawErrors: PropTypes.array,
18677
- readonly: PropTypes.any,
18678
- required: PropTypes.bool,
18679
- schema: PropTypes.shape({
18680
- format: PropTypes.any,
18681
- placeholder: PropTypes.any,
18682
- title: PropTypes.any
18683
- }),
18684
- uiSchema: PropTypes.any,
18685
- value: PropTypes.any
18686
- };
18687
19749
  const HOCs$1 = [...commonWidgetHOCs, withReadyOnly(TextWidgetReadOnly), withEvalDisable()];
18688
- var TextWidget$1 = compose(HOCs$1)(TextWidget);
19750
+ const TextWidget = compose(HOCs$1)(TextWidgetBase);
19751
+ TextWidget.PropTypes = TextWidgetBase.PropTypes;
18689
19752
 
18690
19753
  const getError = errors => {
18691
19754
  if (errors) {
@@ -18826,11 +19889,12 @@ const defaultWidgets = {
18826
19889
  toggleButton: ToggleButtonWidget$1,
18827
19890
  select: SelectWidget$1,
18828
19891
  LinkedSelects: SelectWidget$1,
18829
- TextWidget: TextWidget$1,
19892
+ TextWidget: TextWidget,
18830
19893
  TextareaWidget: TextareaWidget$1,
18831
19894
  PhoneWidget: PhoneWidget$1,
18832
19895
  ValidateWidget: ValidateWidget$1,
18833
- DateWidget
19896
+ DateWidget,
19897
+ CurrencyWidget: CurrencyWidget$1
18834
19898
  // CheckboxWidget
18835
19899
  };
18836
19900