aefis-core-ui 2.3.0-rc15 → 2.3.0-rc16

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.
@@ -55,7 +55,7 @@ import IconButton$2 from '@mui/material/IconButton';
55
55
  import Edit$1 from '@mui/icons-material/Edit';
56
56
  import AutorenewIcon from '@mui/icons-material/Autorenew';
57
57
  import { VerticalTimeline, VerticalTimelineElement } from 'react-vertical-timeline-component';
58
- import require$$0 from 'moment';
58
+ import Moment from 'react-moment';
59
59
  import AddIcon from '@mui/icons-material/Add';
60
60
  import { useInView } from 'react-intersection-observer';
61
61
  import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
@@ -67,6 +67,12 @@ import Nouislider from 'nouislider-react';
67
67
  import 'lodash/camelCase';
68
68
  import debounce from 'lodash/debounce';
69
69
  import StepConnector, { stepConnectorClasses } from '@mui/material/StepConnector';
70
+ import DeleteOutlineOutlinedIcon from '@mui/icons-material/DeleteOutlineOutlined';
71
+ import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
72
+ import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
73
+ import '@mui/icons-material/MoreVert';
74
+ import produce from 'immer';
75
+ import { v4 } from 'uuid';
70
76
  import { MuiForm5 } from '@rjsf/material-ui';
71
77
  import isEmpty from 'lodash/isEmpty';
72
78
  import compose from 'lodash/fp/compose';
@@ -75,7 +81,7 @@ import TextField$2 from '@mui/material/TextField';
75
81
  import get$1 from 'lodash/get';
76
82
  import isPlainObject from 'lodash/isPlainObject';
77
83
  import ToggleButton$1 from '@mui/material/ToggleButton';
78
- import { parse as parse$1, format as format$1, setDate, setMonth } from 'date-fns';
84
+ import { parse as parse$1, format, setDate, setMonth } from 'date-fns';
79
85
  import { MobileDatePicker as MobileDatePicker$1 } from '@mui/x-date-pickers/MobileDatePicker';
80
86
  import { LocalizationProvider as LocalizationProvider$1 } from '@mui/x-date-pickers/LocalizationProvider';
81
87
  import 'filepond-plugin-get-file/dist/filepond-plugin-get-file.css';
@@ -84,7 +90,9 @@ import FilePondPluginImageExifOrientation from 'filepond-plugin-image-exif-orien
84
90
  import FilePondPluginImagePreview from 'filepond-plugin-image-preview';
85
91
  import { registerPlugin, FilePond } from 'react-filepond';
86
92
  import FilePondPluginGetFile from 'filepond-plugin-get-file';
93
+ import FilePondPluginFileValidateSize from 'filepond-plugin-file-validate-size';
87
94
  import MaskedInput from 'react-text-mask';
95
+ import { NumericFormat, useNumericFormat } from 'react-number-format';
88
96
  import StylesProvider from '@mui/styles/StylesProvider';
89
97
 
90
98
  function _extends() {
@@ -1685,12 +1693,12 @@ const LegacyButtonTheme = createTheme(theme, {
1685
1693
  }
1686
1694
  });
1687
1695
 
1688
- const _excluded$k = ["name"];
1696
+ const _excluded$m = ["name"];
1689
1697
  const Button = /*#__PURE__*/forwardRef(function Button(_ref, ref) {
1690
1698
  let {
1691
1699
  name
1692
1700
  } = _ref,
1693
- props = _objectWithoutPropertiesLoose(_ref, _excluded$k);
1701
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$m);
1694
1702
  const isColorDefault = props.color === undefined || props.color === "default";
1695
1703
  const colorThemeName = isColorDefault ? "grey" : props.color;
1696
1704
  const theme = useTheme$1();
@@ -1783,7 +1791,7 @@ AnimatedExpandMoreIcon.propTypes = {
1783
1791
  sx: PropTypes.any
1784
1792
  };
1785
1793
 
1786
- const _excluded$j = ["name", "icon", "menuConfiguration", "color", "displayType", "variant", "onClick", "link"];
1794
+ const _excluded$l = ["name", "icon", "menuConfiguration", "color", "displayType", "variant", "onClick", "link"];
1787
1795
  const AefisButton = withStyles$1({
1788
1796
  root: {
1789
1797
  "&:focus": {
@@ -1805,7 +1813,7 @@ const MenuButton = /*#__PURE__*/forwardRef(function MenuButton(_ref, ref) {
1805
1813
  onClick,
1806
1814
  link
1807
1815
  } = _ref,
1808
- props = _objectWithoutPropertiesLoose(_ref, _excluded$j);
1816
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$l);
1809
1817
  const [anchorEl, setAnchorEl] = useState(null);
1810
1818
  const handleClick = (event, link, buttonId) => {
1811
1819
  setAnchorEl(event.currentTarget);
@@ -1905,7 +1913,12 @@ MenuButton.propTypes = {
1905
1913
  /** Button variant */
1906
1914
  variant: PropTypes.oneOf(["contained", "outlined", "text"]),
1907
1915
  /** The type of the button */
1908
- menuConfiguration: PropTypes.array,
1916
+ menuConfiguration: PropTypes.arrayOf(PropTypes.shape({
1917
+ name: PropTypes.string,
1918
+ icon: PropTypes.any,
1919
+ divider: PropTypes.any,
1920
+ onClick: PropTypes.function
1921
+ })),
1909
1922
  /** The function to execute when the button is clicked. */
1910
1923
  onClick: PropTypes.func
1911
1924
  };
@@ -1950,30 +1963,23 @@ const useStyles$F = makeStyles(theme => ({
1950
1963
  }));
1951
1964
  const titleProps = {
1952
1965
  color: "textPrimary",
1953
- variant: "h3",
1966
+ variant: "h6",
1954
1967
  style: {
1955
- fontSize: "1.2rem",
1968
+ fontSize: "1.1rem",
1956
1969
  fontWeight: 500,
1957
- lineHeight: 1.3,
1958
- letterSpacing: 0.5,
1959
- whiteSpace: "nowrap",
1960
- overflow: "hidden",
1961
- textOverflow: "ellipsis"
1970
+ lineHeight: 1.43,
1971
+ letterSpacing: "0.01071em"
1962
1972
  }
1963
1973
  };
1964
1974
  const subtitleProps = {
1965
1975
  color: "textSecondary",
1976
+ variant: "body1",
1966
1977
  style: {
1967
- fontSize: "0.875rem",
1968
- fontWeight: 400,
1969
- lineHeight: 1.4,
1970
- letterSpacing: 0,
1978
+ fontSize: "0.775rem",
1979
+ fontWeight: "bolder",
1971
1980
  display: "inline-flex",
1972
1981
  verticalAlign: "middle",
1973
- alignItems: "center",
1974
- whiteSpace: "nowrap",
1975
- overflow: "hidden",
1976
- textOverflow: "ellipsis"
1982
+ alignItems: "center"
1977
1983
  }
1978
1984
  };
1979
1985
  const getGradientBackgroundColorArray = arrayIndex => {
@@ -2001,6 +2007,20 @@ const ContentBox = props => {
2001
2007
  return props.children ? /*#__PURE__*/React.cloneElement(props.children) : "";
2002
2008
  };
2003
2009
  titleProps.component = props.titleComponent;
2010
+ if (props.wrapTitle) {
2011
+ titleProps["style"] = _extends({}, titleProps.style, {
2012
+ whiteSpace: "nowrap",
2013
+ overflow: "hidden",
2014
+ textOverflow: "ellipsis"
2015
+ });
2016
+ }
2017
+ if (props.wrapSubtitle) {
2018
+ titleProps["style"] = _extends({}, titleProps.style, {
2019
+ whiteSpace: "nowrap",
2020
+ overflow: "hidden",
2021
+ textOverflow: "ellipsis"
2022
+ });
2023
+ }
2004
2024
  const headerProps = {
2005
2025
  title: props.title,
2006
2026
  disableTypography: false,
@@ -2019,7 +2039,7 @@ const ContentBox = props => {
2019
2039
  }
2020
2040
  if (typeof props.subtitle !== "string" && props.subtitle !== undefined) {
2021
2041
  headerProps.title = /*#__PURE__*/jsx(Typography, {
2022
- variant: "h3",
2042
+ variant: "h6",
2023
2043
  component: props.titleComponent,
2024
2044
  style: titleProps.style,
2025
2045
  display: "block",
@@ -2030,13 +2050,13 @@ const ContentBox = props => {
2030
2050
  headerProps.subheader = props.subtitle;
2031
2051
  }
2032
2052
  if (props.titleBadge) {
2033
- headerProps.title = /*#__PURE__*/jsx("div", {
2053
+ headerProps.title = /*#__PURE__*/jsx(Box$1, {
2034
2054
  children: /*#__PURE__*/jsx(StyledBadge$1, {
2035
2055
  badgeContent: props.titleBadge,
2036
2056
  invisible: invisible,
2037
2057
  color: "secondary",
2038
2058
  children: /*#__PURE__*/jsx(Typography, {
2039
- variant: "h3",
2059
+ variant: "h6",
2040
2060
  component: props.titleComponent,
2041
2061
  style: titleProps.style,
2042
2062
  display: "block",
@@ -2057,12 +2077,13 @@ const ContentBox = props => {
2057
2077
  variant: "body1",
2058
2078
  component: "span",
2059
2079
  noWrap: true,
2060
- sx: {
2061
- color: "text.secondary"
2062
- },
2080
+ color: "textSecondary",
2063
2081
  style: {
2064
- fontSize: "0.875rem",
2065
- letterSpacing: 0
2082
+ fontSize: "0.775rem",
2083
+ fontWeight: "bolder",
2084
+ display: "inline-flex",
2085
+ verticalAlign: "middle",
2086
+ alignItems: "center"
2066
2087
  },
2067
2088
  children: props.subtitle
2068
2089
  });
@@ -2074,6 +2095,7 @@ const ContentBox = props => {
2074
2095
  const cardStyle = _extends({
2075
2096
  marginBottom: props.hasGutter ? 8 : 0,
2076
2097
  borderRadius: 16,
2098
+ transition: "border 100ms ease-out",
2077
2099
  boxShadow: props.displayType === "outlined" ? "none" : "rgb(58 53 65 / 10%) 0px 2px 10px 0px"
2078
2100
  }, props.cardStyle);
2079
2101
  if (props.displayType === "outlined") {
@@ -2091,7 +2113,7 @@ const ContentBox = props => {
2091
2113
  return /*#__PURE__*/jsxs(Box$1, {
2092
2114
  sx: props.sx,
2093
2115
  style: props.containerStyle,
2094
- children: [props.header && /*#__PURE__*/jsx("div", {
2116
+ children: [props.header && /*#__PURE__*/jsx(Box$1, {
2095
2117
  className: classes.sectionHeader,
2096
2118
  children: /*#__PURE__*/jsx(Typography, {
2097
2119
  variant: "h6",
@@ -2101,7 +2123,7 @@ const ContentBox = props => {
2101
2123
  }), /*#__PURE__*/jsxs(Card, {
2102
2124
  style: cardStyle,
2103
2125
  className: tag.tag,
2104
- children: [useHeaderImage && /*#__PURE__*/jsx("div", {
2126
+ children: [useHeaderImage && /*#__PURE__*/jsx(Box$1, {
2105
2127
  style: imageDivStyle,
2106
2128
  className: classes.imageContainer,
2107
2129
  title: props.title,
@@ -2113,6 +2135,10 @@ const ContentBox = props => {
2113
2135
  image: props.image
2114
2136
  }), props.title && /*#__PURE__*/jsx(CardHeader, _extends({}, headerProps)), props.formatContent && /*#__PURE__*/jsx(CardContent, {
2115
2137
  className: !props.title ? classes.cardContentWithoutTitle : classes.cardContent,
2138
+ sx: !props.children && !props.description ? {
2139
+ display: "none",
2140
+ visibility: "hidden"
2141
+ } : undefined,
2116
2142
  children: /*#__PURE__*/jsxs(React.Fragment, {
2117
2143
  children: [props.description && /*#__PURE__*/jsx(Typography, {
2118
2144
  variant: "body2",
@@ -2147,7 +2173,9 @@ ContentBox.defaultProps = {
2147
2173
  imageHeight: 150,
2148
2174
  hasGutter: true,
2149
2175
  imageBackgroundColor: "transparent",
2150
- titleComponent: "div"
2176
+ titleComponent: "div",
2177
+ wrapTitle: false,
2178
+ wrapSubtitle: false
2151
2179
  };
2152
2180
  ContentBox.propTypes = {
2153
2181
  /** Content of the content box */
@@ -2162,6 +2190,10 @@ ContentBox.propTypes = {
2162
2190
  subtitle: PropTypes.any,
2163
2191
  /** Main title of the content box. Can be a string or any component. */
2164
2192
  title: PropTypes.any,
2193
+ /** Wrap the title? */
2194
+ wrapTitle: PropTypes.bool,
2195
+ /** Wrap the subtitle? */
2196
+ wrapSubtitle: PropTypes.bool,
2165
2197
  /** Add a badge to the title of the content box. */
2166
2198
  titleBadge: PropTypes.number,
2167
2199
  /** The component to use to render the title. */
@@ -3435,7 +3467,7 @@ CardSectionTitle$1.propTypes = {
3435
3467
  title: PropTypes.string
3436
3468
  };
3437
3469
 
3438
- const _excluded$i = ["title", "children", "height", "titleComponent"];
3470
+ const _excluded$k = ["title", "children", "height", "titleComponent"];
3439
3471
  const CardSection$1 = _ref => {
3440
3472
  let {
3441
3473
  title,
@@ -3443,7 +3475,7 @@ const CardSection$1 = _ref => {
3443
3475
  height,
3444
3476
  titleComponent
3445
3477
  } = _ref,
3446
- props = _objectWithoutPropertiesLoose(_ref, _excluded$i);
3478
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$k);
3447
3479
  return /*#__PURE__*/jsxs(Box$1, _extends({
3448
3480
  sx: {
3449
3481
  height: height || "inherit"
@@ -3543,7 +3575,7 @@ SvgImage.propTypes = {
3543
3575
  width: PropTypes.any
3544
3576
  };
3545
3577
 
3546
- const _excluded$h = ["source", "description", "width", "height", "decorative", "showSkeleton", "fallbackImage"],
3578
+ const _excluded$j = ["source", "description", "width", "height", "decorative", "showSkeleton", "fallbackImage"],
3547
3579
  _excluded2$1 = ["src", "extension"];
3548
3580
  const RenderImage = _ref => {
3549
3581
  let {
@@ -3555,7 +3587,7 @@ const RenderImage = _ref => {
3555
3587
  showSkeleton,
3556
3588
  fallbackImage
3557
3589
  } = _ref,
3558
- other = _objectWithoutPropertiesLoose(_ref, _excluded$h);
3590
+ other = _objectWithoutPropertiesLoose(_ref, _excluded$j);
3559
3591
  const altText = decorative ? "" : description;
3560
3592
  const role = decorative ? "presentation" : "img";
3561
3593
  const hidden = !!decorative;
@@ -3633,7 +3665,7 @@ Image.propTypes = {
3633
3665
  extension: PropTypes.string
3634
3666
  };
3635
3667
 
3636
- const _excluded$g = ["type"];
3668
+ const _excluded$i = ["type"];
3637
3669
  const imageProps = {
3638
3670
  award: Award,
3639
3671
  building: Building,
@@ -3659,7 +3691,7 @@ const IsometricImage = _ref => {
3659
3691
  let {
3660
3692
  type
3661
3693
  } = _ref,
3662
- other = _objectWithoutPropertiesLoose(_ref, _excluded$g);
3694
+ other = _objectWithoutPropertiesLoose(_ref, _excluded$i);
3663
3695
  const image = getIsometricImage(type);
3664
3696
  return /*#__PURE__*/jsx(Image, _extends({
3665
3697
  src: image
@@ -4342,6 +4374,9 @@ const RenderCard = props => {
4342
4374
  configuration: props.actionsConfiguration,
4343
4375
  data: props.data
4344
4376
  }) : undefined,
4377
+ cardStyle: props.cardStyle || undefined,
4378
+ containerStyle: props.containerStyle || undefined,
4379
+ sx: props.sx || undefined,
4345
4380
  children: /*#__PURE__*/jsxs(Fragment, {
4346
4381
  children: [props.description && /*#__PURE__*/jsx(CardSection, {
4347
4382
  sx: descriptionContainerStyle,
@@ -4375,7 +4410,10 @@ RenderCard.propTypes = {
4375
4410
  avatarIconColor: PropTypes.string,
4376
4411
  gradientColorHeaderImageId: PropTypes.any,
4377
4412
  autoTruncateDescription: PropTypes.bool,
4378
- avatar: PropTypes.any
4413
+ avatar: PropTypes.any,
4414
+ cardStyle: PropTypes.any,
4415
+ containerStyle: PropTypes.any,
4416
+ sx: PropTypes.object
4379
4417
  };
4380
4418
  const BusinessObjectCard = props => {
4381
4419
  return props.displayType === "skeleton" ? /*#__PURE__*/jsx(RenderSkeleton, {
@@ -4420,16 +4458,22 @@ BusinessObjectCard.propTypes = {
4420
4458
  /** Override the avatar with provided avatar object. */
4421
4459
  avatar: PropTypes.any,
4422
4460
  /** Automatically truncate the description. For consistency, this should nearly always be set to "true" */
4423
- autoTruncateDescription: PropTypes.bool
4461
+ autoTruncateDescription: PropTypes.bool,
4462
+ /** Additional styles for the card */
4463
+ cardStyle: PropTypes.any,
4464
+ /** Additional styles for the content box container */
4465
+ containerStyle: PropTypes.any,
4466
+ /** Additional styles to apply */
4467
+ sx: PropTypes.object
4424
4468
  };
4425
4469
 
4426
- const _excluded$f = ["enableScrollTop", "containerProps"];
4470
+ const _excluded$h = ["enableScrollTop", "containerProps"];
4427
4471
  const SwipeableViews = _ref => {
4428
4472
  let {
4429
4473
  enableScrollTop = true,
4430
4474
  containerProps = {}
4431
4475
  } = _ref,
4432
- props = _objectWithoutPropertiesLoose(_ref, _excluded$f);
4476
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$h);
4433
4477
  const containerRef = containerProps.ref || useRef();
4434
4478
  useEffect(() => {
4435
4479
  if (enableScrollTop) {
@@ -5068,7 +5112,7 @@ SectionTitle.propTypes = {
5068
5112
  component: PropTypes.string
5069
5113
  };
5070
5114
 
5071
- const _excluded$e = ["title", "subtitle", "children", "display", "format", "renderList", "titleComponent"];
5115
+ const _excluded$g = ["title", "subtitle", "children", "display", "format", "renderList", "titleComponent"];
5072
5116
  const Section = _ref => {
5073
5117
  let {
5074
5118
  title,
@@ -5079,7 +5123,7 @@ const Section = _ref => {
5079
5123
  renderList,
5080
5124
  titleComponent
5081
5125
  } = _ref,
5082
- props = _objectWithoutPropertiesLoose(_ref, _excluded$e);
5126
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$g);
5083
5127
  const containerStyle = {
5084
5128
  boxSizing: "border-box",
5085
5129
  width: "100%",
@@ -5716,7 +5760,7 @@ FullPageViewer.propTypes = {
5716
5760
  onMessage: PropTypes.func
5717
5761
  };
5718
5762
 
5719
- const _excluded$d = ["height", "children", "onScroll", "showTopFade", "showBottomFade", "component", "onScrollReachStart", "onScrollReachEnd"];
5763
+ const _excluded$f = ["height", "children", "onScroll", "showTopFade", "showBottomFade", "component", "onScrollReachStart", "onScrollReachEnd"];
5720
5764
  const useStyles$w = makeStyles(() => ({
5721
5765
  scroller: {
5722
5766
  position: "relative",
@@ -5789,7 +5833,7 @@ const ScrollingContainer = _ref => {
5789
5833
  onScrollReachStart,
5790
5834
  onScrollReachEnd
5791
5835
  } = _ref,
5792
- props = _objectWithoutPropertiesLoose(_ref, _excluded$d);
5836
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$f);
5793
5837
  const classes = useStyles$w();
5794
5838
  const [scrolled, setScrolled] = useState(false);
5795
5839
  const rootStyle = {
@@ -7540,7 +7584,7 @@ var dataSourceManager = {
7540
7584
  getDataSourceUrl: getDataSourceUrl
7541
7585
  };
7542
7586
 
7543
- const _excluded$c = ["clearOnChange", "minimumLength"];
7587
+ const _excluded$e = ["clearOnChange", "minimumLength"];
7544
7588
  const WAIT_INTERVAL = 1000;
7545
7589
  const ENTER_KEY = 13;
7546
7590
  const TextSearch$1 = _ref => {
@@ -7548,7 +7592,7 @@ const TextSearch$1 = _ref => {
7548
7592
  clearOnChange,
7549
7593
  minimumLength
7550
7594
  } = _ref,
7551
- props = _objectWithoutPropertiesLoose(_ref, _excluded$c);
7595
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$e);
7552
7596
  const [value, setValue] = useState("");
7553
7597
  const [timer, setTimer] = useState(null);
7554
7598
  const handleChange = e => {
@@ -7583,13 +7627,13 @@ const TextSearch$1 = _ref => {
7583
7627
  value: value,
7584
7628
  onKeyDown: handleKeyDown,
7585
7629
  placeholder: props.placeholder,
7586
- sx: {
7630
+ sx: _extends({
7587
7631
  input: {
7588
7632
  "&::placeholder": {
7589
7633
  opacity: 0.7
7590
7634
  }
7591
7635
  }
7592
- }
7636
+ }, props.sx)
7593
7637
  }, props, {
7594
7638
  inputProps: _extends({}, props.inputProps, {
7595
7639
  "aria-label": props.placeholder
@@ -7677,7 +7721,7 @@ const mapFilters = newFilters => {
7677
7721
  return mappedFilters;
7678
7722
  };
7679
7723
 
7680
- const _excluded$b = ["parentMenuOpen", "label", "rightIcon", "leftIcon", "children", "className", "tabIndex", "ContainerProps"];
7724
+ const _excluded$d = ["parentMenuOpen", "label", "rightIcon", "leftIcon", "children", "className", "tabIndex", "ContainerProps"];
7681
7725
  const useMenuItemStyles = makeStyles(theme => ({
7682
7726
  root: props => ({
7683
7727
  backgroundColor: props.open ? theme.palette.action.hover : "rgba(0,0,0,0)"
@@ -7698,7 +7742,7 @@ const NestedMenuItem = /*#__PURE__*/React.forwardRef(function NestedMenuItem(pro
7698
7742
  tabIndex: tabIndexProp,
7699
7743
  ContainerProps: ContainerPropsProp = {}
7700
7744
  } = props,
7701
- MenuItemProps = _objectWithoutPropertiesLoose(props, _excluded$b);
7745
+ MenuItemProps = _objectWithoutPropertiesLoose(props, _excluded$d);
7702
7746
  const {
7703
7747
  ref: containerRefProp
7704
7748
  } = ContainerPropsProp,
@@ -8960,12 +9004,12 @@ Actions.propTypes = {
8960
9004
  onAction: PropTypes.func
8961
9005
  };
8962
9006
 
8963
- const _excluded$a = ["hasFilters"];
9007
+ const _excluded$c = ["hasFilters"];
8964
9008
  const RenderFilterButton = /*#__PURE__*/React.forwardRef(function RenderFilterButton(_ref, ref) {
8965
9009
  let {
8966
9010
  hasFilters
8967
9011
  } = _ref,
8968
- props = _objectWithoutPropertiesLoose(_ref, _excluded$a);
9012
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$c);
8969
9013
  return /*#__PURE__*/jsx(IconButton$1, _extends({}, props, {
8970
9014
  ref: ref,
8971
9015
  children: /*#__PURE__*/jsx(Badge, {
@@ -9058,7 +9102,7 @@ DefaultIconButton.propTypes = {
9058
9102
  onClick: PropTypes.func
9059
9103
  };
9060
9104
 
9061
- const _excluded$9 = ["filterSet", "onClick", "disableSetDefault", "index"];
9105
+ const _excluded$b = ["filterSet", "onClick", "disableSetDefault", "index"];
9062
9106
  const useStyles$m = makeStyles(theme => ({
9063
9107
  operations: {
9064
9108
  display: "flex",
@@ -9130,7 +9174,7 @@ const Item$1 = /*#__PURE__*/React.forwardRef((_ref, ref) => {
9130
9174
  disableSetDefault,
9131
9175
  index
9132
9176
  } = _ref,
9133
- props = _objectWithoutPropertiesLoose(_ref, _excluded$9);
9177
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$b);
9134
9178
  const {
9135
9179
  id,
9136
9180
  disabled,
@@ -9186,7 +9230,7 @@ const renderUserDefinedFilters = ({
9186
9230
  index: index
9187
9231
  }, `user-defined-filters-${index}`));
9188
9232
 
9189
- const _excluded$8 = ["filterSet", "onClick", "disableSetDefault", "index"];
9233
+ const _excluded$a = ["filterSet", "onClick", "disableSetDefault", "index"];
9190
9234
  const useStyles$l = makeStyles(() => ({
9191
9235
  operations: {
9192
9236
  display: "flex",
@@ -9228,7 +9272,7 @@ const Item = /*#__PURE__*/React.forwardRef((_ref, ref) => {
9228
9272
  disableSetDefault,
9229
9273
  index
9230
9274
  } = _ref,
9231
- props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
9275
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$a);
9232
9276
  const {
9233
9277
  id,
9234
9278
  disabled,
@@ -10095,33 +10139,6 @@ Drawer.propTypes = {
10095
10139
  titleComponent: PropTypes.oneOf(["h1", "h2", "h3", "div"])
10096
10140
  };
10097
10141
 
10098
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
10099
-
10100
- function getDefaultExportFromCjs (x) {
10101
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
10102
- }
10103
-
10104
- function createCommonjsModule(fn) {
10105
- var module = { exports: {} };
10106
- return fn(module, module.exports), module.exports;
10107
- }
10108
-
10109
- var dist = createCommonjsModule(function (module, exports) {
10110
- !function(e,t){module.exports=t(require$$0,React);}(commonjsGlobal,(function(e,t){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r});},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){e.exports=n(3)();},function(t,n){t.exports=e;},function(e,n){e.exports=t;},function(e,t,n){var r=n(4);function o(){}function i(){}i.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,i,a){if(a!==r){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:o};return n.PropTypes=n,n};},function(e,t,n){e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";},function(e,t,n){var r,o,i,a,l;
10111
- /*! Moment Duration Format v2.2.2
10112
- * https://github.com/jsmreese/moment-duration-format
10113
- * Date: 2018-02-16
10114
- *
10115
- * Duration format plugin function for the Moment.js library
10116
- * http://momentjs.com/
10117
- *
10118
- * Copyright 2018 John Madhavan-Reese
10119
- * Released under the MIT license
10120
- */a=this,l=function(e){var t=!1,n=!1,r=!1,o=!1,i="escape years months weeks days hours minutes seconds milliseconds general".split(" "),a=[{type:"seconds",targets:[{type:"minutes",value:60},{type:"hours",value:3600},{type:"days",value:86400},{type:"weeks",value:604800},{type:"months",value:2678400},{type:"years",value:31536e3}]},{type:"minutes",targets:[{type:"hours",value:60},{type:"days",value:1440},{type:"weeks",value:10080},{type:"months",value:44640},{type:"years",value:525600}]},{type:"hours",targets:[{type:"days",value:24},{type:"weeks",value:168},{type:"months",value:744},{type:"years",value:8760}]},{type:"days",targets:[{type:"weeks",value:7},{type:"months",value:31},{type:"years",value:365}]},{type:"months",targets:[{type:"years",value:12}]}];function l(e,t){return !(t.length>e.length)&&-1!==e.indexOf(t)}function u(e){for(var t="";e;)t+="0",e-=1;return t}function s(e,t){var n=e+"+"+v(V(t).sort(),(function(e){return e+":"+t[e]})).join(",");return s.cache[n]||(s.cache[n]=Intl.NumberFormat(e,t)),s.cache[n]}function c(e,t,i){var a,l,f,m=t.useToLocaleString,p=t.useGrouping,g=p&&t.grouping.slice(),y=t.maximumSignificantDigits,h=t.minimumIntegerDigits||1,d=t.fractionDigits||0,v=t.groupingSeparator,b=t.decimalSeparator;if(m&&i){var w,S={minimumIntegerDigits:h,useGrouping:p};return d&&(S.maximumFractionDigits=d,S.minimumFractionDigits=d),y&&e>0&&(S.maximumSignificantDigits=y),r?(o||((w=x({},t)).useGrouping=!1,w.decimalSeparator=".",e=parseFloat(c(e,w),10)),s(i,S).format(e)):(n||((w=x({},t)).useGrouping=!1,w.decimalSeparator=".",e=parseFloat(c(e,w),10)),e.toLocaleString(i,S))}var T=(y?e.toPrecision(y+1):e.toFixed(d+1)).split("e");f=T[1]||"",l=(T=T[0].split("."))[1]||"";var O=(a=T[0]||"").length,_=l.length,V=O+_,D=a+l;(y&&V===y+1||!y&&_===d+1)&&((D=function(e){for(var t=e.split("").reverse(),n=0,r=!0;r&&n<t.length;)n?"9"===t[n]?t[n]="0":(t[n]=(parseInt(t[n],10)+1).toString(),r=!1):(parseInt(t[n],10)<5&&(r=!1),t[n]="0"),n+=1;return r&&t.push("1"),t.reverse().join("")}(D)).length===V+1&&(O+=1),_&&(D=D.slice(0,-1)),a=D.slice(0,O),l=D.slice(O)),y&&(l=l.replace(/0*$/,""));var j=parseInt(f,10);j>0?l.length<=j?(a+=l+=u(j-l.length),l=""):(a+=l.slice(0,j),l=l.slice(j)):j<0&&(l=u(Math.abs(j)-a.length)+a+l,a="0"),y||((l=l.slice(0,d)).length<d&&(l+=u(d-l.length)),a.length<h&&(a=u(h-a.length)+a));var M,P="";if(p)for(T=a;T.length;)g.length&&(M=g.shift()),P&&(P=v+P),P=T.slice(-M)+P,T=T.slice(0,-M);else P=a;return l&&(P=P+b+l),P}function f(e,t){return e.label.length>t.label.length?-1:e.label.length<t.label.length?1:0}function m(e,t){var n=[];return d(V(t),(function(r){if("_durationLabels"===r.slice(0,15)){var o=r.slice(15).toLowerCase();d(V(t[r]),(function(i){i.slice(0,1)===e&&n.push({type:o,key:i,label:t[r][i]});}));}})),n}s.cache={};var p={durationLabelsStandard:{S:"millisecond",SS:"milliseconds",s:"second",ss:"seconds",m:"minute",mm:"minutes",h:"hour",hh:"hours",d:"day",dd:"days",w:"week",ww:"weeks",M:"month",MM:"months",y:"year",yy:"years"},durationLabelsShort:{S:"msec",SS:"msecs",s:"sec",ss:"secs",m:"min",mm:"mins",h:"hr",hh:"hrs",d:"dy",dd:"dys",w:"wk",ww:"wks",M:"mo",MM:"mos",y:"yr",yy:"yrs"},durationTimeTemplates:{HMS:"h:mm:ss",HM:"h:mm",MS:"m:ss"},durationLabelTypes:[{type:"standard",string:"__"},{type:"short",string:"_"}],durationPluralKey:function(e,t,n){return 1===t&&null===n?e:e+e}};function g(e){return "[object Array]"===Object.prototype.toString.call(e)}function y(e){return "[object Object]"===Object.prototype.toString.call(e)}function h(e,t){var n,r=0,o=e&&e.length||0;for("function"!=typeof t&&(n=t,t=function(e){return e===n});r<o;){if(t(e[r]))return e[r];r+=1;}}function d(e,t){var n=0,r=e.length;if(e&&r)for(;n<r;){if(!1===t(e[n],n))return;n+=1;}}function v(e,t){var n=0,r=e.length,o=[];if(!e||!r)return o;for(;n<r;)o[n]=t(e[n],n),n+=1;return o}function b(e,t){return v(e,(function(e){return e[t]}))}function w(e){var t=[];return d(e,(function(e){e&&t.push(e);})),t}function S(e){var t=[];return d(e,(function(e){h(t,e)||t.push(e);})),t}function T(e,t){var n=[];return d(e,(function(e){d(t,(function(t){e===t&&n.push(e);}));})),S(n)}function O(e,t){var n=[];return d(e,(function(r,o){if(!t(r))return n=e.slice(o),!1})),n}function _(e,t){return O(e.slice().reverse(),t).reverse()}function x(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}function V(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t}function D(e,t){var n=0,r=e.length;if(!e||!r)return !1;for(;n<r;){if(!0===t(e[n],n))return !0;n+=1;}return !1}function j(e){var t=[];return d(e,(function(e){t=t.concat(e);})),t}function M(e){return "3.6"===e(3.55,"en",{useGrouping:!1,minimumIntegerDigits:1,minimumFractionDigits:1,maximumFractionDigits:1})}function P(e){var t=!0;return !!((t=(t=(t=t&&"1"===e(1,"en",{minimumIntegerDigits:1}))&&"01"===e(1,"en",{minimumIntegerDigits:2}))&&"001"===e(1,"en",{minimumIntegerDigits:3}))&&(t=(t=(t=(t=t&&"100"===e(99.99,"en",{maximumFractionDigits:0,minimumFractionDigits:0}))&&"100.0"===e(99.99,"en",{maximumFractionDigits:1,minimumFractionDigits:1}))&&"99.99"===e(99.99,"en",{maximumFractionDigits:2,minimumFractionDigits:2}))&&"99.990"===e(99.99,"en",{maximumFractionDigits:3,minimumFractionDigits:3}))&&(t=(t=(t=(t=(t=t&&"100"===e(99.99,"en",{maximumSignificantDigits:1}))&&"100"===e(99.99,"en",{maximumSignificantDigits:2}))&&"100"===e(99.99,"en",{maximumSignificantDigits:3}))&&"99.99"===e(99.99,"en",{maximumSignificantDigits:4}))&&"99.99"===e(99.99,"en",{maximumSignificantDigits:5}))&&(t=(t=t&&"1,000"===e(1e3,"en",{useGrouping:!0}))&&"1000"===e(1e3,"en",{useGrouping:!1})))}function k(){var e,t=[].slice.call(arguments),n={};if(d(t,(function(t,r){if(!r){if(!g(t))throw "Expected array as the first argument to durationsFormat.";e=t;}"string"!=typeof t&&"function"!=typeof t?"number"!=typeof t?y(t)&&x(n,t):n.precision=t:n.template=t;})),!e||!e.length)return [];n.returnMomentTypes=!0;var r=v(e,(function(e){return e.format(n)})),o=T(i,S(b(j(r),"type"))),a=n.largest;return a&&(o=o.slice(0,a)),n.returnMomentTypes=!1,n.outputTypes=o,v(e,(function(e){return e.format(n)}))}function E(){var n=[].slice.call(arguments),o=x({},this.format.defaults),u=this.asMilliseconds(),s=this.asMonths();"function"==typeof this.isValid&&!1===this.isValid()&&(u=0,s=0);var j=u<0,M=e.duration(Math.abs(u),"milliseconds"),P=e.duration(Math.abs(s),"months");d(n,(function(e){"string"!=typeof e&&"function"!=typeof e?"number"!=typeof e?y(e)&&x(o,e):o.precision=e:o.template=e;}));var k={years:"y",months:"M",weeks:"w",days:"d",hours:"h",minutes:"m",seconds:"s",milliseconds:"S"},E={escape:/\[(.+?)\]/,years:/\*?[Yy]+/,months:/\*?M+/,weeks:/\*?[Ww]+/,days:/\*?[Dd]+/,hours:/\*?[Hh]+/,minutes:/\*?m+/,seconds:/\*?s+/,milliseconds:/\*?S+/,general:/.+?/};o.types=i;var L=function(e){return h(i,(function(t){return E[t].test(e)}))},F=new RegExp(v(i,(function(e){return E[e].source})).join("|"),"g");o.duration=this;var I="function"==typeof o.template?o.template.apply(o):o.template,N=o.outputTypes,C=o.returnMomentTypes,R=o.largest,G=[];N||(g(o.stopTrim)&&(o.stopTrim=o.stopTrim.join("")),o.stopTrim&&d(o.stopTrim.match(F),(function(e){var t=L(e);"escape"!==t&&"general"!==t&&G.push(t);})));var U=e.localeData();U||(U={}),d(V(p),(function(e){"function"!=typeof p[e]?U["_"+e]||(U["_"+e]=p[e]):U[e]||(U[e]=p[e]);})),d(V(U._durationTimeTemplates),(function(e){I=I.replace("_"+e+"_",U._durationTimeTemplates[e]);}));var q=o.userLocale||e.locale(),z=o.useLeftUnits,H=o.usePlural,W=o.precision,$=o.forceLength,A=o.useGrouping,B=o.trunc,K=o.useSignificantDigits&&W>0,Y=K?o.precision:0,J=Y,Q=o.minValue,X=!1,Z=o.maxValue,ee=!1,te=o.useToLocaleString,ne=o.groupingSeparator,re=o.decimalSeparator,oe=o.grouping;te=te&&(t||r);var ie=o.trim;g(ie)&&(ie=ie.join(" ")),null===ie&&(R||Z||K)&&(ie="all"),null!==ie&&!0!==ie&&"left"!==ie&&"right"!==ie||(ie="large"),!1===ie&&(ie="");var ae=function(e){return e.test(ie)},le=/large/,ue=/small/,se=/both/,ce=/mid/,fe=/^all|[^sm]all/,me=/final/,pe=R>0||D([le,se,fe],ae),ge=D([ue,se,fe],ae),ye=D([ce,fe],ae),he=D([me,fe],ae),de=v(I.match(F),(function(e,t){var n=L(e);return "*"===e.slice(0,1)&&(e=e.slice(1),"escape"!==n&&"general"!==n&&G.push(n)),{index:t,length:e.length,text:"",token:"escape"===n?e.replace(E.escape,"$1"):e,type:"escape"===n||"general"===n?null:n}})),ve={index:0,length:0,token:"",text:"",type:null},be=[];z&&de.reverse(),d(de,(function(e){if(e.type)return (ve.type||ve.text)&&be.push(ve),void(ve=e);z?ve.text=e.token+ve.text:ve.text+=e.token;})),(ve.type||ve.text)&&be.push(ve),z&&be.reverse();var we=T(i,S(w(b(be,"type"))));if(!we.length)return b(be,"text").join("");we=v(we,(function(e,t){var n,r=t+1===we.length,i=!t;n="years"===e||"months"===e?P.as(e):M.as(e);var a=Math.floor(n),l=n-a,u=h(be,(function(t){return e===t.type}));return i&&Z&&n>Z&&(ee=!0),r&&Q&&Math.abs(o.duration.as(e))<Q&&(X=!0),i&&null===$&&u.length>1&&($=!0),M.subtract(a,e),P.subtract(a,e),{rawValue:n,wholeValue:a,decimalValue:r?l:0,isSmallest:r,isLargest:i,type:e,tokenLength:u.length}}));var Se=B?Math.floor:Math.round,Te=function(e,t){var n=Math.pow(10,t);return Se(e*n)/n},Oe=!1,_e=!1,xe=function(e,t){var n={useGrouping:A,groupingSeparator:ne,decimalSeparator:re,grouping:oe,useToLocaleString:te};return K&&(Y<=0?(e.rawValue=0,e.wholeValue=0,e.decimalValue=0):(n.maximumSignificantDigits=Y,e.significantDigits=Y)),ee&&!_e&&(e.isLargest?(e.wholeValue=Z,e.decimalValue=0):(e.wholeValue=0,e.decimalValue=0)),X&&!_e&&(e.isSmallest?(e.wholeValue=Q,e.decimalValue=0):(e.wholeValue=0,e.decimalValue=0)),e.isSmallest||e.significantDigits&&e.significantDigits-e.wholeValue.toString().length<=0?W<0?e.value=Te(e.wholeValue,W):0===W?e.value=Se(e.wholeValue+e.decimalValue):K?(e.value=B?Te(e.rawValue,Y-e.wholeValue.toString().length):e.rawValue,e.wholeValue&&(Y-=e.wholeValue.toString().length)):(n.fractionDigits=W,e.value=B?e.wholeValue+Te(e.decimalValue,W):e.wholeValue+e.decimalValue):K&&e.wholeValue?(e.value=Math.round(Te(e.wholeValue,e.significantDigits-e.wholeValue.toString().length)),Y-=e.wholeValue.toString().length):e.value=e.wholeValue,e.tokenLength>1&&($||Oe)&&(n.minimumIntegerDigits=e.tokenLength,_e&&n.maximumSignificantDigits<e.tokenLength&&delete n.maximumSignificantDigits),!Oe&&(e.value>0||""===ie||h(G,e.type)||h(N,e.type))&&(Oe=!0),e.formattedValue=c(e.value,n,q),n.useGrouping=!1,n.decimalSeparator=".",e.formattedValueEn=c(e.value,n,"en"),2===e.tokenLength&&"milliseconds"===e.type&&(e.formattedValueMS=c(e.value,{minimumIntegerDigits:3,useGrouping:!1},"en").slice(0,2)),e};if((we=w(we=v(we,xe))).length>1){var Ve=function(e){return h(we,(function(t){return t.type===e}))},De=function(e){var t=Ve(e.type);t&&d(e.targets,(function(e){var n=Ve(e.type);n&&parseInt(t.formattedValueEn,10)===e.value&&(t.rawValue=0,t.wholeValue=0,t.decimalValue=0,n.rawValue+=1,n.wholeValue+=1,n.decimalValue=0,n.formattedValueEn=n.wholeValue.toString(),_e=!0);}));};d(a,De);}return _e&&(Oe=!1,Y=J,we=w(we=v(we,xe))),!N||ee&&!o.trim?(pe&&(we=O(we,(function(e){return !e.isSmallest&&!e.wholeValue&&!h(G,e.type)}))),R&&we.length&&(we=we.slice(0,R)),ge&&we.length>1&&(we=_(we,(function(e){return !e.wholeValue&&!h(G,e.type)&&!e.isLargest}))),ye&&(we=w(we=v(we,(function(e,t){return t>0&&t<we.length-1&&!e.wholeValue?null:e})))),!he||1!==we.length||we[0].wholeValue||!B&&we[0].isSmallest&&we[0].rawValue<Q||(we=[])):we=w(we=v(we,(function(e){return h(N,(function(t){return e.type===t}))?e:null}))),C?we:(d(be,(function(e){var t=k[e.type],n=h(we,(function(t){return t.type===e.type}));if(t&&n){var r=n.formattedValueEn.split(".");r[0]=parseInt(r[0],10),r[1]?r[1]=parseFloat("0."+r[1],10):r[1]=null;var o=U.durationPluralKey(t,r[0],r[1]),i=m(t,U),a=!1,u={};d(U._durationLabelTypes,(function(t){var n=h(i,(function(e){return e.type===t.type&&e.key===o}));n&&(u[n.type]=n.label,l(e.text,t.string)&&(e.text=e.text.replace(t.string,n.label),a=!0));})),H&&!a&&(i.sort(f),d(i,(function(t){return u[t.type]===t.label?!l(e.text,t.label)&&void 0:l(e.text,t.label)?(e.text=e.text.replace(t.label,u[t.type]),!1):void 0})));}})),(be=v(be,(function(e){if(!e.type)return e.text;var t=h(we,(function(t){return t.type===e.type}));if(!t)return "";var n="";return z&&(n+=e.text),(j&&ee||!j&&X)&&(n+="< ",ee=!1,X=!1),(j&&X||!j&&ee)&&(n+="> ",ee=!1,X=!1),j&&(t.value>0||""===ie||h(G,t.type)||h(N,t.type))&&(n+="-",j=!1),"milliseconds"===e.type&&t.formattedValueMS?n+=t.formattedValueMS:n+=t.formattedValue,z||(n+=e.text),n}))).join("").replace(/(,| |:|\.)*$/,"").replace(/^(,| |:|\.)*/,""))}function L(){var e=this.duration,t=function(t){return e._data[t]},n=h(this.types,t),r=function(e,t){for(var n=e.length;n-=1;)if(t(e[n]))return e[n]}(this.types,t);switch(n){case"milliseconds":return "S __";case"seconds":case"minutes":return "*_MS_";case"hours":return "_HMS_";case"days":if(n===r)return "d __";case"weeks":return n===r?"w __":(null===this.trim&&(this.trim="both"),"w __, d __, h __");case"months":if(n===r)return "M __";case"years":return n===r?"y __":(null===this.trim&&(this.trim="both"),"y __, M __, d __");default:return null===this.trim&&(this.trim="both"),"y __, d __, h __, m __, s __"}}function F(e){if(!e)throw "Moment Duration Format init cannot find moment instance.";e.duration.format=k,e.duration.fn.format=E,e.duration.fn.format.defaults={trim:null,stopTrim:null,largest:null,maxValue:null,minValue:null,precision:0,trunc:!1,forceLength:null,userLocale:null,usePlural:!0,useLeftUnits:!1,useGrouping:!0,useSignificantDigits:!1,template:L,useToLocaleString:!0,groupingSeparator:",",decimalSeparator:".",grouping:[3]},e.updateLocale("en",p);}var I=function(e,t,n){return e.toLocaleString(t,n)};t=function(){try{(0).toLocaleString("i");}catch(e){return "RangeError"===e.name}return !1}()&&P(I),n=t&&M(I);var N=function(e,t,n){if("undefined"!=typeof window&&window&&window.Intl&&window.Intl.NumberFormat)return window.Intl.NumberFormat(t,n).format(e)};return r=P(N),o=r&&M(N),F(e),F},o=[n(1)],void 0===(i="function"==typeof(r=l)?r.apply(t,o):r)||(e.exports=i),a&&(a.momentDurationFormatSetup=a.moment?l(a.moment):l);},function(e,t,n){n.r(t),n.d(t,"default",(function(){return _}));var r=n(2),o=n.n(r),i=n(0),a=n.n(i),l=n(1),u=n.n(l);n(5);function s(e){return (s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r);}return n}function f(e,t){if(null==e)return {};var n,r,o=function(e,t){if(null==e)return {};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n]);}return o}function m(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r);}}function p(e,t,n){return t&&m(e.prototype,t),n&&m(e,n),e}function g(e,t){return (g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return !1}}();return function(){var n,r=v(e);if(t){var o=v(this).constructor;n=Reflect.construct(r,arguments,o);}else n=r.apply(this,arguments);return h(this,n)}}function h(e,t){return !t||"object"!==s(t)&&"function"!=typeof t?d(e):t}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e){return (v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w=[a.a.string,a.a.number,a.a.array,a.a.object],S=[a.a.string,a.a.array],T=[a.a.object,a.a.bool],O=[a.a.string,a.a.bool],_=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&g(e,t);}(n,e);var t=y(n);function n(e){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),b(d(r=t.call(this,e)),"setTimer",(function(){var e=r.props.interval;r.clearTimer(),n.pooledTimer||0===e||(r.timer=setInterval((function(){r.update(r.props);}),e));})),b(d(r),"getTitle",(function(){var e=r.props.titleFormat,t=n.getDatetime(r.props),o=e||n.globalFormat;return t.format(o)})),b(d(r),"clearTimer",(function(){!n.pooledTimer&&r.timer&&(clearInterval(r.timer),r.timer=null),n.pooledTimer&&!r.timer&&n.removePooledElement(d(r));})),n.globalMoment||(n.globalMoment=u.a),r.state={content:""},r.timer=null,r}return p(n,null,[{key:"startPooledTimer",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6e4;n.clearPooledTimer(),n.pooledTimer=setInterval((function(){n.pooledElements.forEach((function(e){0!==e.props.interval&&e.update();}));}),e);}},{key:"clearPooledTimer",value:function(){n.pooledTimer&&(clearInterval(n.pooledTimer),n.pooledTimer=null,n.pooledElements=[]);}},{key:"pushPooledElement",value:function(e){e instanceof n?-1===n.pooledElements.indexOf(e)&&n.pooledElements.push(e):console.error("Element not an instance of Moment.");}},{key:"removePooledElement",value:function(e){var t=n.pooledElements.indexOf(e);-1!==t&&n.pooledElements.splice(t,1);}},{key:"getDatetime",value:function(e){var t=e.utc,r=e.unix,o=e.date,i=e.locale,a=e.parse,l=e.tz,u=e.local;o=o||e.children,a=a||n.globalParse,u=u||n.globalLocal,l=l||n.globalTimezone,i=n.globalLocale?n.globalLocale:i||n.globalMoment.locale();var s=null;return s=t?n.globalMoment.utc(o,a,i):r?n.globalMoment(1e3*o,a,i):n.globalMoment(o,a,i),l?s=s.tz(l):u&&(s=s.local()),s}},{key:"getContent",value:function(e){var t=e.fromNow,r=e.fromNowDuring,o=e.from,i=e.add,a=e.subtract,l=e.toNow,s=e.to,c=e.ago,f=e.calendar,m=e.diff,p=e.duration,g=e.durationFromNow,y=e.unit,h=e.decimal,d=e.trim,v=e.format;v=v||n.globalFormat;var b=n.getDatetime(e);i&&b.add(i),a&&b.subtract(a);var w=Boolean(r)&&-b.diff(u()())<r,S="";return S=!v||w||g||p?o?b.from(o,c):t||w?b.fromNow(c):s?b.to(s,c):l?b.toNow(c):f?b.calendar(null,f):m?b.diff(m,y,h):p?b.diff(p):g?u()().diff(b):b.toString():b.format(v),(p||g)&&(S=(S=u.a.duration(S)).format(v,{trim:d})),S=(n.globalFilter||e.filter)(S)}}]),p(n,[{key:"componentDidMount",value:function(){this.setTimer(),n.pooledTimer&&n.pushPooledElement(this);}},{key:"componentDidUpdate",value:function(e){var t=this.props.interval;e.interval!==t&&this.setTimer();}},{key:"componentWillUnmount",value:function(){this.clearTimer();}},{key:"update",value:function(e){var t=e||this.props,r=t.onChange,o=n.getContent(t);this.setState({content:o},(function(){r(o);}));}},{key:"render",value:function(){var e,t,r,i,a=this.props,l=a.withTitle,u=a.element,s=f(a,["withTitle","element"]),m=this.state.content,p=(e=s,t=n.propTypes,r=Object.keys(t),i=Object.assign({},e),Object.keys(i).filter((function(e){return -1!==r.indexOf(e)})).forEach((function(e){return delete i[e]})),i);return l&&(p.title=this.getTitle()),o.a.createElement(u||n.globalElement,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){b(e,t,n[t]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t));}));}return e}({dateTime:n.getDatetime(this.props)},p),m)}}],[{key:"getDerivedStateFromProps",value:function(e){return {content:n.getContent(e)}}}]),n}(o.a.Component);b(_,"propTypes",{element:a.a.any,date:a.a.oneOfType(w),parse:a.a.oneOfType(S),format:a.a.string,add:a.a.object,subtract:a.a.object,ago:a.a.bool,fromNow:a.a.bool,fromNowDuring:a.a.number,from:a.a.oneOfType(w),toNow:a.a.bool,to:a.a.oneOfType(w),calendar:a.a.oneOfType(T),unix:a.a.bool,utc:a.a.bool,local:a.a.bool,tz:a.a.string,withTitle:a.a.bool,titleFormat:a.a.string,locale:a.a.string,interval:a.a.number,diff:a.a.oneOfType(w),duration:a.a.oneOfType(w),durationFromNow:a.a.bool,trim:a.a.oneOfType(O),unit:a.a.string,decimal:a.a.bool,filter:a.a.func,onChange:a.a.func}),b(_,"defaultProps",{element:null,fromNow:!1,toNow:!1,calendar:!1,ago:!1,unix:!1,utc:!1,local:!1,unit:null,withTitle:!1,trim:!1,decimal:!1,titleFormat:"",interval:6e4,filter:function(e){return e},onChange:function(){}}),b(_,"globalMoment",null),b(_,"globalLocale",null),b(_,"globalLocal",null),b(_,"globalFormat",null),b(_,"globalParse",null),b(_,"globalFilter",null),b(_,"globalElement","time"),b(_,"globalTimezone",null),b(_,"pooledElements",[]),b(_,"pooledTimer",null);}])}));
10121
- });
10122
-
10123
- var Moment = /*@__PURE__*/getDefaultExportFromCjs(dist);
10124
-
10125
10142
  // Copyright (c) 2022 HelioCampus Inc., all rights reserved.
10126
10143
  const useStyles$h = makeStyles(() => ({
10127
10144
  rootContainer: {
@@ -10382,7 +10399,7 @@ const getInfoTextByFilterAndSortingCount = (filterCount, sortCount) => {
10382
10399
  return `${appliedText} applied to the data`;
10383
10400
  };
10384
10401
 
10385
- const _excluded$7 = ["status", "data", "isFetching", "fetchNextPage", "hasNextPage", "refetch"];
10402
+ const _excluded$9 = ["status", "data", "isFetching", "fetchNextPage", "hasNextPage", "refetch"];
10386
10403
  const useDidMount = () => {
10387
10404
  const didMountRef = useRef(false);
10388
10405
  useEffect(() => {
@@ -10497,7 +10514,7 @@ const RichDataTable = /*#__PURE__*/forwardRef(function RichDatatable(props, ref)
10497
10514
  hasNextPage,
10498
10515
  refetch
10499
10516
  } = _useDataSourceInfinit;
10500
- _objectWithoutPropertiesLoose(_useDataSourceInfinit, _excluded$7);
10517
+ _objectWithoutPropertiesLoose(_useDataSourceInfinit, _excluded$9);
10501
10518
  const isError = useIsError(status);
10502
10519
  const renderReTryButton = useCallback(status => /*#__PURE__*/jsx(Button, {
10503
10520
  onClick: () => refetch(),
@@ -10664,7 +10681,7 @@ const RichDataTable = /*#__PURE__*/forwardRef(function RichDatatable(props, ref)
10664
10681
  exportOptions: props.exportOptions,
10665
10682
  actions: props.actions && props.actions.length > 0 || props.addAction ? updateActions(props.actions, handleDrawerOpen, enableTableRowAction, selectedRowCount, Add) : undefined,
10666
10683
  onFilterClick: isFilterPanelEnabled ? handleFilterClick : undefined,
10667
- hasFilters: filterPanelState.filterCount > 0 || filterPanelState.sortCount > 0 || filterPanelState.searchText,
10684
+ hasFilters: filterPanelState.filterCount > 0 || filterPanelState.sortCount > 0 || !!filterPanelState.searchText,
10668
10685
  disableFilterButton: isFetching
10669
10686
  }, props.titleAndActionHeaderProps)), /*#__PURE__*/jsx(DataTable, _extends({}, props, {
10670
10687
  tableRef: DataTableRef,
@@ -10879,7 +10896,7 @@ const {
10879
10896
  withEvent: withBOPEvent
10880
10897
  } = createComponentEvent();
10881
10898
 
10882
- const _excluded$6 = ["onSubmit", "value", "columns", "filterPanelConfig", "multiple", "dataSource", "confirmButtonText"];
10899
+ const _excluded$8 = ["onSubmit", "value", "columns", "filterPanelConfig", "multiple", "dataSource", "confirmButtonText"];
10883
10900
  const useDialogOpenEventListener$1 = cb => useBOPEventlistener(event => {
10884
10901
  if (event.name === events.OPEN_ENHANCED_SEARCH_DIALOG) cb(event.payload);
10885
10902
  });
@@ -10893,7 +10910,7 @@ const EnhancedSearchDialog = _ref => {
10893
10910
  dataSource,
10894
10911
  confirmButtonText
10895
10912
  } = _ref,
10896
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
10913
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
10897
10914
  const [selection, setSelection] = useState([]);
10898
10915
  const [open, setOpen] = useState(false);
10899
10916
  useDialogOpenEventListener$1(isOpen => setOpen(isOpen));
@@ -11010,7 +11027,7 @@ const useDependencyChange = (callback, currentState) => {
11010
11027
  }
11011
11028
  };
11012
11029
 
11013
- 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"];
11030
+ const _excluded$7 = ["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", "preventHorizontalExpand"];
11014
11031
  const useStyles$f = makeStyles(theme => ({
11015
11032
  menu: {
11016
11033
  textDecoration: "none",
@@ -11072,9 +11089,10 @@ const BusinessObjectPicker = _ref => {
11072
11089
  enableInfinteScroll,
11073
11090
  renderAddItemForm,
11074
11091
  AddItemFormModalComponent,
11075
- autoCompleteProps = {}
11092
+ autoCompleteProps = {},
11093
+ preventHorizontalExpand = false
11076
11094
  } = _ref,
11077
- props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
11095
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
11078
11096
  const classes = useStyles$f();
11079
11097
  // TODO: implement controlled behaviour
11080
11098
  const [value, setValue] = useAutoCompleteValue(props.value, multiple);
@@ -11341,6 +11359,11 @@ const BusinessObjectPicker = _ref => {
11341
11359
  selectOnFocus: false,
11342
11360
  renderTags: renderTags || (props.type ? renderTypeTags : renderCustomTags),
11343
11361
  renderInput: params => /*#__PURE__*/jsx(TextSearch$1, _extends({}, params, props, {
11362
+ sx: _extends({}, preventHorizontalExpand && {
11363
+ "&>div.MuiInputBase-root": {
11364
+ flexWrap: "nowrap !important"
11365
+ }
11366
+ }),
11344
11367
  type: "text",
11345
11368
  inputProps: _extends({}, params.inputProps, {
11346
11369
  "data-testid": "content-input"
@@ -11510,7 +11533,9 @@ BusinessObjectPicker.propTypes = {
11510
11533
  /** render prop to handle form content, render function provided onSubmit callback function */
11511
11534
  renderAddItemForm: PropTypes.func,
11512
11535
  /** override props of MUI's AutoComplete components */
11513
- autoCompleteProps: PropTypes.object
11536
+ autoCompleteProps: PropTypes.object,
11537
+ /** preventHorizontalExpand */
11538
+ preventHorizontalExpand: PropTypes.bool
11514
11539
  };
11515
11540
  BusinessObjectPicker.defaultProps = {
11516
11541
  multiple: false,
@@ -12472,7 +12497,7 @@ CurriculumChart.propTypes = {
12472
12497
  onLoad: PropTypes.func
12473
12498
  };
12474
12499
 
12475
- const _excluded$4 = ["error", "inputFormat", "value", "isControlled", "onChange", "clearable", "disabled", "required", "showButton", "minimumDate", "maximumDate", "inputEndAdornmentText"];
12500
+ const _excluded$6 = ["error", "inputFormat", "value", "isControlled", "onChange", "clearable", "disabled", "required", "showButton", "minimumDate", "maximumDate", "inputEndAdornmentText"];
12476
12501
  const MuiDatePicker = props => {
12477
12502
  const isMobile = useMediaQuery$1(theme => theme.breakpoints.down("md"));
12478
12503
  if (props.type) {
@@ -12512,7 +12537,7 @@ const DatePickerBase = _ref => {
12512
12537
  maximumDate,
12513
12538
  inputEndAdornmentText
12514
12539
  } = _ref,
12515
- props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
12540
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
12516
12541
  const [value, setValue] = useFormItemState(propsValue, isControlled);
12517
12542
  const handleChange = newValue => {
12518
12543
  !isControlled && setValue(newValue);
@@ -15208,6 +15233,485 @@ RubricDistributionChart.propTypes = {
15208
15233
  titleComponent: PropTypes.oneOf(["h1", "h2", "h3", "h4", "div", "p"])
15209
15234
  };
15210
15235
 
15236
+ const _excluded$5 = ["rules"];
15237
+ const FieldWrapper = ({
15238
+ children
15239
+ }) => {
15240
+ return /*#__PURE__*/jsx(Box$1, {
15241
+ sx: {
15242
+ paddingTop: 1,
15243
+ overflow: "auto"
15244
+ },
15245
+ children: children
15246
+ });
15247
+ };
15248
+ const TemplateField = ({
15249
+ templateSelectionCode,
15250
+ templateOptions,
15251
+ templateInputMap,
15252
+ onChange
15253
+ }) => {
15254
+ const data = useMemo(() => templateOptions.map(({
15255
+ label,
15256
+ code: value
15257
+ }) => ({
15258
+ label,
15259
+ value
15260
+ }), [templateOptions]));
15261
+ const value = useMemo(() => {
15262
+ if (!templateSelectionCode) return undefined;
15263
+ return {
15264
+ value: templateSelectionCode,
15265
+ label: templateInputMap[templateSelectionCode].label
15266
+ };
15267
+ }, [templateSelectionCode]);
15268
+ return /*#__PURE__*/jsx(BusinessObjectPicker$1, {
15269
+ multiple: false,
15270
+ data: data,
15271
+ value: value,
15272
+ onChange: onChange,
15273
+ optionTemplate: "{{label}}",
15274
+ preventHorizontalExpand: true
15275
+ });
15276
+ };
15277
+ function Row({
15278
+ groupId,
15279
+ index,
15280
+ ruleId,
15281
+ ruleIndex,
15282
+ name: templateSelectionCode,
15283
+ // template selection
15284
+ value: ruleValue,
15285
+ // rule value
15286
+ template: ruleTemplate,
15287
+ onRuleDelete,
15288
+ onTemplateSelect,
15289
+ onTemplateValueChange,
15290
+ templateInputMap,
15291
+ templateOptions
15292
+ }) {
15293
+ const handleChange = useDebounceCallback((value, template) => {
15294
+ onTemplateValueChange({
15295
+ value,
15296
+ template,
15297
+ // TODO: send these as 2nd argument
15298
+ groupId,
15299
+ ruleId
15300
+ // TODO: fix index and ruleIndex lot of re-rendering
15301
+ // index,
15302
+ // ruleIndex
15303
+ });
15304
+ });
15305
+
15306
+ const templateValueField = useMemo(() => {
15307
+ if (!templateSelectionCode) return null;
15308
+ const TemplateInputField = templateInputMap[templateSelectionCode].component;
15309
+ return /*#__PURE__*/jsx(TemplateInputField, {
15310
+ value: ruleValue,
15311
+ template: ruleTemplate
15312
+ // TODO: add debouncer
15313
+ ,
15314
+ onChange: handleChange
15315
+ });
15316
+
15317
+ // TODO: take out index from here together with onChange handler
15318
+ // index, ruleIndex,
15319
+ }, [groupId, ruleId, templateSelectionCode, ruleValue, ruleTemplate]);
15320
+ return /*#__PURE__*/jsxs(Box$1, {
15321
+ sx: {
15322
+ display: "flex",
15323
+ flexWrap: "no-wrap",
15324
+ paddingTop: 1
15325
+ },
15326
+ children: [/*#__PURE__*/jsxs(Grid, {
15327
+ sx: {
15328
+ flex: 1,
15329
+ backgroundColor: "#f9f9f9",
15330
+ marginLeft: 1,
15331
+ paddingTop: 1,
15332
+ paddingLeft: 2,
15333
+ paddingBottom: 1,
15334
+ paddingRight: 2,
15335
+ borderRadius: "8px",
15336
+ marginBottom: "4px"
15337
+ } // this is for grow
15338
+ ,
15339
+ container: true,
15340
+ rowSpacing: 0.5,
15341
+ columnSpacing: 2,
15342
+ direction: "row",
15343
+ children: [/*#__PURE__*/jsx(Grid, {
15344
+ item: true,
15345
+ xs: 12,
15346
+ sm: 12,
15347
+ md: 4,
15348
+ style: {
15349
+ paddingLeft: 0
15350
+ },
15351
+ children: /*#__PURE__*/jsx(FieldWrapper, {
15352
+ children: /*#__PURE__*/jsx(TemplateField, {
15353
+ templateSelectionCode: templateSelectionCode,
15354
+ templateInputMap: templateInputMap,
15355
+ templateOptions: templateOptions,
15356
+ onChange: valueFieldCode => {
15357
+ onTemplateSelect({
15358
+ templateCode: (valueFieldCode == null ? void 0 : valueFieldCode.value) || null,
15359
+ groupId,
15360
+ ruleId,
15361
+ index,
15362
+ ruleIndex
15363
+ });
15364
+ }
15365
+ })
15366
+ })
15367
+ }), /*#__PURE__*/jsx(Grid, {
15368
+ item: true,
15369
+ xs: 12,
15370
+ sm: 12,
15371
+ md: 8,
15372
+ children: /*#__PURE__*/jsx(FieldWrapper, {
15373
+ children: templateValueField
15374
+ })
15375
+ })]
15376
+ }), /*#__PURE__*/jsx(Box$1, {
15377
+ sx: {
15378
+ width: "48px",
15379
+ marginTop: "22px"
15380
+ },
15381
+ children: /*#__PURE__*/jsx(MenuButton, {
15382
+ displayType: "icon",
15383
+ menuConfiguration: [{
15384
+ name: "Move Up",
15385
+ icon: /*#__PURE__*/jsx(KeyboardArrowUpIcon, {}),
15386
+ onClick: () => {}
15387
+ }, {
15388
+ name: "Move Down",
15389
+ icon: /*#__PURE__*/jsx(KeyboardArrowDownIcon, {}),
15390
+ onClick: () => {}
15391
+ }, {
15392
+ name: "Add Rule Below",
15393
+ icon: /*#__PURE__*/jsx(AddIcon, {}),
15394
+ onClick: () => {}
15395
+ }, {
15396
+ name: "Delete",
15397
+ icon: /*#__PURE__*/jsx(DeleteOutlineOutlinedIcon, {}),
15398
+ onClick: () => {
15399
+ onRuleDelete({
15400
+ ruleId,
15401
+ index,
15402
+ ruleIndex,
15403
+ groupId
15404
+ });
15405
+ }
15406
+ }]
15407
+ })
15408
+ })]
15409
+ });
15410
+ }
15411
+ const RuleGroup = /*#__PURE__*/memo(_ref => {
15412
+ let {
15413
+ rules
15414
+ } = _ref,
15415
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
15416
+ return /*#__PURE__*/jsx(Box$1, {
15417
+ sx: {
15418
+ paddingBottom: 1
15419
+ },
15420
+ children: rules.map(({
15421
+ id,
15422
+ name,
15423
+ value,
15424
+ template
15425
+ }, ruleIndex) => /*#__PURE__*/jsx(Row, _extends({
15426
+ name: name,
15427
+ value: value,
15428
+ template: template,
15429
+ ruleIndex: ruleIndex,
15430
+ ruleId: id
15431
+ }, rest), id))
15432
+ });
15433
+ });
15434
+
15435
+ const RuleGroupFooter = /*#__PURE__*/memo(({
15436
+ groupId,
15437
+ onGroupDelete,
15438
+ onRuleAdd
15439
+ }) => /*#__PURE__*/jsx(Box$1, {
15440
+ sx: {
15441
+ display: "flex",
15442
+ justifyContent: "end",
15443
+ marginRight: 6
15444
+ },
15445
+ children: /*#__PURE__*/jsxs(Box$1, {
15446
+ sx: {
15447
+ display: "flex",
15448
+ flexDirection: "row"
15449
+ },
15450
+ children: [/*#__PURE__*/jsx(Button
15451
+ // onClick={onGroupDelete}
15452
+ , {
15453
+ onClick: () => onGroupDelete({
15454
+ groupId
15455
+ }),
15456
+ startIcon: /*#__PURE__*/jsx(DeleteOutlineOutlinedIcon, {}),
15457
+ children: "Delete Group"
15458
+ }), /*#__PURE__*/jsx(Button, {
15459
+ onClick: () => onRuleAdd({
15460
+ groupId
15461
+ })
15462
+ // onClick={onRuleAdd}
15463
+ ,
15464
+ startIcon: /*#__PURE__*/jsx(AddIcon, {}),
15465
+ children: "Add Rule"
15466
+ })]
15467
+ })
15468
+ }));
15469
+
15470
+ const BuilderHeader = /*#__PURE__*/memo(({
15471
+ onAdd,
15472
+ children
15473
+ }) => /*#__PURE__*/jsxs(Box$1, {
15474
+ sx: {
15475
+ display: "flex"
15476
+ },
15477
+ children: [/*#__PURE__*/jsx(Box$1, {
15478
+ sx: {
15479
+ flex: 1
15480
+ },
15481
+ children: children
15482
+ }), /*#__PURE__*/jsx(Box$1, {
15483
+ sx: {
15484
+ display: "flex",
15485
+ justifyContent: "end",
15486
+ paddingBottom: 1
15487
+ },
15488
+ children: /*#__PURE__*/jsx(Button, {
15489
+ startIcon: /*#__PURE__*/jsx(AddIcon, {}),
15490
+ onClick: onAdd,
15491
+ children: "Add Group"
15492
+ })
15493
+ })]
15494
+ }));
15495
+
15496
+ const RuleGroupIndex = /*#__PURE__*/memo(({
15497
+ onMovePosition,
15498
+ groupId,
15499
+ index,
15500
+ isFirst,
15501
+ isLast
15502
+ }) => /*#__PURE__*/jsx(Box$1, {
15503
+ sx: {
15504
+ width: "40px",
15505
+ height: "88px"
15506
+ },
15507
+ children: /*#__PURE__*/jsxs(Box$1, {
15508
+ sx: {
15509
+ display: "flex",
15510
+ flexDirection: "column",
15511
+ alignItems: "center",
15512
+ position: "relative",
15513
+ top: "0px",
15514
+ width: "20px"
15515
+ },
15516
+ children: [/*#__PURE__*/jsx(IconButton$1, {
15517
+ sx: {
15518
+ visibility: isFirst ? "hidden" : "none"
15519
+ },
15520
+ "aria-label": "move up",
15521
+ onClick: () => onMovePosition({
15522
+ groupId,
15523
+ index
15524
+ }, true),
15525
+ children: /*#__PURE__*/jsx(KeyboardArrowUpIcon, {
15526
+ sx: {
15527
+ color: "grey"
15528
+ }
15529
+ })
15530
+ }), /*#__PURE__*/jsx(Typography, {
15531
+ variant: "body1",
15532
+ color: "#727373",
15533
+ sx: {
15534
+ fontWeight: "500"
15535
+ },
15536
+ children: index + 1
15537
+ }), /*#__PURE__*/jsx(IconButton$1, {
15538
+ "aria-label": "move down",
15539
+ sx: {
15540
+ visibility: isLast ? "hidden" : "none"
15541
+ },
15542
+ onClick: () => onMovePosition({
15543
+ groupId,
15544
+ index
15545
+ }, false),
15546
+ children: /*#__PURE__*/jsx(KeyboardArrowDownIcon, {
15547
+ sx: {
15548
+ color: "grey"
15549
+ }
15550
+ })
15551
+ })]
15552
+ })
15553
+ }));
15554
+
15555
+ const _excluded$4 = ["code"];
15556
+ const TextBuilder = /*#__PURE__*/memo(({
15557
+ renderHeader,
15558
+ templateOptions,
15559
+ value: _value = [],
15560
+ onChange: _onChange = () => {},
15561
+ defaultRule
15562
+ }) => {
15563
+ const templateInputMap = useMemo(() => templateOptions.reduce((obj, _ref) => {
15564
+ let {
15565
+ code
15566
+ } = _ref,
15567
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
15568
+ return _extends({}, obj, {
15569
+ [code]: rest
15570
+ });
15571
+ }, {}), [templateOptions]);
15572
+
15573
+ // TODO: change rows => RuleGroups
15574
+ const [rows, setRows] = useState(_value);
15575
+ const setMutatableRows = useCallback(setterFn => {
15576
+ setRows(rows => produce(rows, setterFn));
15577
+ }, []);
15578
+ useEffect(() => {
15579
+ _onChange(rows);
15580
+ }, [rows]);
15581
+ const handleAddGroup = () => {
15582
+ // TODO use setMutatableRows
15583
+ setRows([...rows, {
15584
+ index: rows.length,
15585
+ groupId: v4(),
15586
+ rules: [_extends({
15587
+ id: v4()
15588
+ }, defaultRule)]
15589
+ }]);
15590
+ };
15591
+ const handleGroupDelete = ({
15592
+ groupId
15593
+ }) => {
15594
+ const newRows = rows.filter(row => row.groupId !== groupId);
15595
+ setRows(newRows);
15596
+ };
15597
+ const handleRuleDelete = ({
15598
+ index,
15599
+ ruleIndex,
15600
+ groupId,
15601
+ ruleId
15602
+ }) => {
15603
+ setMutatableRows(groups => {
15604
+ groups[index].rules = groups[index].rules.filter(rule => rule.id !== ruleId);
15605
+ });
15606
+ };
15607
+
15608
+ // TODO change name
15609
+ const handleRuleTemplateSelect = ({
15610
+ groupId,
15611
+ index,
15612
+ ruleId,
15613
+ ruleIndex,
15614
+ templateCode
15615
+ }) => {
15616
+ setMutatableRows(groups => {
15617
+ groups[index].rules[ruleIndex].name = templateCode || null;
15618
+ groups[index].rules[ruleIndex].value = null;
15619
+ groups[index].rules[ruleIndex].template = null;
15620
+ });
15621
+ };
15622
+ const handleRuleTemplateValueChange = ({
15623
+ value,
15624
+ template,
15625
+ groupId,
15626
+ index,
15627
+ ruleId,
15628
+ ruleIndex
15629
+ }) => {
15630
+ setMutatableRows(groups => {
15631
+ const rule = groups.find(group => group.groupId === groupId).rules.find(rule => rule.id === ruleId);
15632
+ rule.value = value;
15633
+ rule.template = template;
15634
+ // groups[index].rules[ruleIndex].value = value;
15635
+ // groups[index].rules[ruleIndex].template = template;
15636
+ });
15637
+ };
15638
+
15639
+ const moveGroupPosition = ({
15640
+ index
15641
+ }, isUp) => {
15642
+ const newRows = rows.slice();
15643
+ const nextRow = isUp ? index - 1 : index + 1;
15644
+ [newRows[index], newRows[nextRow]] = [newRows[nextRow], newRows[index]];
15645
+ setRows(newRows);
15646
+ };
15647
+ const handleAddRule = ({
15648
+ groupId
15649
+ }) => {
15650
+ // TODO use setMutatableRows
15651
+ const newRules = rows.map(row => {
15652
+ if (row.groupId !== groupId) return row;
15653
+ return _extends({}, row, {
15654
+ rules: [...row.rules, _extends({
15655
+ id: v4()
15656
+ }, defaultRule)]
15657
+ });
15658
+ });
15659
+ setRows(newRules);
15660
+ };
15661
+ return /*#__PURE__*/jsxs(ContentBox, {
15662
+ sx: {
15663
+ ".MuiFormControl-root": {
15664
+ background: "white"
15665
+ }
15666
+ },
15667
+ children: [/*#__PURE__*/jsx(BuilderHeader, {
15668
+ onAdd: handleAddGroup,
15669
+ children: renderHeader()
15670
+ }), rows.map(({
15671
+ groupId,
15672
+ rules
15673
+ }, index) => /*#__PURE__*/jsx(ContentBox, {
15674
+ displayType: "outlined",
15675
+ sx: {
15676
+ paddingBottom: 2
15677
+ },
15678
+ children: /*#__PURE__*/jsxs(Box$1, {
15679
+ sx: {
15680
+ display: "flex",
15681
+ flexWrap: "no-wrap",
15682
+ border: "1px solid transparent"
15683
+ },
15684
+ children: [/*#__PURE__*/jsx(RuleGroupIndex, {
15685
+ onMovePosition: moveGroupPosition,
15686
+ isFirst: index === 0,
15687
+ isLast: index === rows.length - 1,
15688
+ index: index,
15689
+ groupId: groupId
15690
+ }), /*#__PURE__*/jsxs(Box$1, {
15691
+ sx: {
15692
+ flex: 1
15693
+ },
15694
+ children: [/*#__PURE__*/jsx(RuleGroup, {
15695
+ index: index,
15696
+ rules: rules,
15697
+ groupId: groupId,
15698
+ templateOptions: templateOptions,
15699
+ templateInputMap: templateInputMap,
15700
+ onRuleDelete: handleRuleDelete,
15701
+ onTemplateSelect: handleRuleTemplateSelect,
15702
+ onTemplateValueChange: handleRuleTemplateValueChange
15703
+ }), /*#__PURE__*/jsx(RuleGroupFooter, {
15704
+ groupIndex: index,
15705
+ groupId: groupId,
15706
+ onGroupDelete: handleGroupDelete,
15707
+ onRuleAdd: handleAddRule
15708
+ })]
15709
+ })]
15710
+ })
15711
+ }, groupId))]
15712
+ });
15713
+ });
15714
+
15211
15715
  const moreThan = ruleValue => ({
15212
15716
  fieldValue
15213
15717
  }) => {
@@ -16576,14 +17080,6 @@ const render = (value, formState) => {
16576
17080
  }
16577
17081
  return mustache.render(value, formState);
16578
17082
  };
16579
- const renderUrl = (value, formState) => {
16580
- if (value === undefined || value === null) {
16581
- return value;
16582
- }
16583
- return decodeHtml$2(mustache.render(value, formState));
16584
- };
16585
- const useRenderUrl = template => useSelectFormState(state => renderUrl(template, state));
16586
- const useRender = template => useSelectFormState(state => render(template, state));
16587
17083
 
16588
17084
  const useQueryTemplateParam = queryTemplate => {
16589
17085
  const selector = useCallback(state => {
@@ -16870,7 +17366,7 @@ const DateSelectReadOnly$1 = ({
16870
17366
  schema
16871
17367
  }) => {
16872
17368
  const value = useMemo(() => {
16873
- if (formData == undefined) return null;
17369
+ if (!(formData != null && formData.date)) return null;
16874
17370
  const date = new Date(formData.date);
16875
17371
  const options = _extends({}, formData.type === "y" && {
16876
17372
  year: "numeric"
@@ -16920,30 +17416,37 @@ const DateSelect = props => {
16920
17416
  rawErrors,
16921
17417
  disabled
16922
17418
  } = props;
16923
- const [selectedDate, setSelectedDate] = useState(null);
16924
- const [dateType, setDateType] = useState(dateTypes.day);
16925
17419
  const serverSideDateFormat = "MM-dd-yyyy";
16926
- useEffect(() => {
17420
+ const [{
17421
+ selectedDate,
17422
+ dateType
17423
+ }, setFieldValue] = useState(() => {
16927
17424
  if (formData && typeof formData === "object" && formData.date != undefined) {
16928
- let obj = formData;
16929
- setDateType(findDateType(obj.type));
16930
- setSelectedDate(parse$1(obj.date, serverSideDateFormat, new Date()));
17425
+ return {
17426
+ selectedDate: parse$1(formData.date, serverSideDateFormat, new Date()),
17427
+ dateType: findDateType(formData.type)
17428
+ };
16931
17429
  } else {
16932
- setDateType(dateTypes.day);
16933
- setSelectedDate(null);
17430
+ return {
17431
+ selectedDate: null,
17432
+ dateType: formData != null && formData.type ? findDateType(formData.type) : dateTypes.day
17433
+ };
16934
17434
  }
16935
- }, [formData]);
17435
+ });
16936
17436
  const handleDateTypeChange = (event, newDateType) => {
16937
- if (newDateType != null) {
16938
- setDateType(newDateType);
16939
- if (typeof selectedDate !== "undefined" && selectedDate != null) {
16940
- format$1(selectedDate, serverSideDateFormat);
16941
- onChange({
16942
- date: format$1(selectedDate, serverSideDateFormat),
16943
- type: newDateType.type
16944
- });
16945
- }
17437
+ // INFO: toggle sends null value on double click
17438
+ if (!newDateType) return;
17439
+ let newDate = null;
17440
+ if (typeof selectedDate !== "undefined" && selectedDate != null) {
17441
+ newDate = format(selectedDate, serverSideDateFormat);
16946
17442
  }
17443
+ setFieldValue(prev => _extends({}, prev, {
17444
+ dateType: newDateType
17445
+ }));
17446
+ onChange({
17447
+ date: newDate,
17448
+ type: newDateType.type
17449
+ });
16947
17450
  };
16948
17451
  const handleDateChange = newDate => {
16949
17452
  if (newDate != null) {
@@ -16953,13 +17456,17 @@ const DateSelect = props => {
16953
17456
  newDate = setDate(newDate, 1);
16954
17457
  newDate = setMonth(newDate, 0);
16955
17458
  }
16956
- setSelectedDate(newDate);
17459
+ setFieldValue(prev => _extends({}, prev, {
17460
+ selectedDate: newDate
17461
+ }));
16957
17462
  onChange({
16958
- date: format$1(newDate, serverSideDateFormat),
17463
+ date: format(newDate, serverSideDateFormat),
16959
17464
  type: dateType.type
16960
17465
  });
16961
17466
  } else {
16962
- setSelectedDate(newDate);
17467
+ setFieldValue(prev => _extends({}, prev, {
17468
+ selectedDate: null
17469
+ }));
16963
17470
  onChange({
16964
17471
  date: null,
16965
17472
  type: dateType.type
@@ -17029,7 +17536,7 @@ const DateSelect = props => {
17029
17536
  inputVariant: "outlined",
17030
17537
  inputFormat: dateType.format,
17031
17538
  views: dateType.views,
17032
- value: typeof selectedDate === "undefined" ? null : selectedDate,
17539
+ value: selectedDate || null,
17033
17540
  onChange: handleDateChange,
17034
17541
  disabled: disabled,
17035
17542
  renderInput: params => /*#__PURE__*/jsx(TextField, _extends({}, params, {
@@ -17039,7 +17546,12 @@ const DateSelect = props => {
17039
17546
  sx: dateInputStyles
17040
17547
  })),
17041
17548
  minDate: minDate,
17042
- maxDate: maxDate
17549
+ maxDate: maxDate,
17550
+ componentsProps: {
17551
+ actionBar: {
17552
+ actions: ["cancel", "clear", "accept"]
17553
+ }
17554
+ }
17043
17555
  })
17044
17556
  })]
17045
17557
  });
@@ -17079,49 +17591,6 @@ const DisableWrapper = ({
17079
17591
  }));
17080
17592
  };
17081
17593
 
17082
- const ImageUploadReadOnly = ({
17083
- formData,
17084
- schema,
17085
- uiSchema: _uiSchema = {
17086
- "ui:options": {}
17087
- }
17088
- }) => {
17089
- const {
17090
- downloadUrl: downloadUrlTemplate,
17091
- extension: extensionTemplate
17092
- } = _uiSchema["ui:options"];
17093
- const downloadUrl = useRenderUrl(downloadUrlTemplate);
17094
- const extension = useRender(extensionTemplate);
17095
- return /*#__PURE__*/jsxs(Fragment, {
17096
- children: [/*#__PURE__*/jsx(Typography, {
17097
- gutterBottom: true,
17098
- variant: "subtitle2",
17099
- children: schema.title
17100
- }), /*#__PURE__*/jsx(Paper, {
17101
- sx: {
17102
- height: 185,
17103
- justifyContent: "center",
17104
- display: "flex",
17105
- padding: 2,
17106
- overflow: "hidden"
17107
- },
17108
- variant: "outlined",
17109
- children: /*#__PURE__*/jsx(Image, {
17110
- src: downloadUrl,
17111
- style: {
17112
- height: "100%",
17113
- width: "auto"
17114
- },
17115
- extension: extension
17116
- })
17117
- })]
17118
- });
17119
- };
17120
- ImageUploadReadOnly.propTypes = {
17121
- schema: PropTypes.any,
17122
- renderedValues: PropTypes.any
17123
- };
17124
-
17125
17594
  const FieldContainer = props => {
17126
17595
  return /*#__PURE__*/jsx(Box$2, _extends({}, props, {
17127
17596
  sx: _extends({}, props.sx, {
@@ -17133,7 +17602,30 @@ const FieldContainer = props => {
17133
17602
  };
17134
17603
  FieldContainer.propTypes = Box$2.propTypes;
17135
17604
 
17136
- registerPlugin(FilePondPluginFileValidateType, FilePondPluginImageExifOrientation, FilePondPluginImagePreview, FilePondPluginGetFile);
17605
+ registerPlugin(FilePondPluginFileValidateType, FilePondPluginFileValidateSize, FilePondPluginImageExifOrientation, FilePondPluginImagePreview, FilePondPluginGetFile);
17606
+
17607
+ // Check enums below
17608
+ // source:https://github.com/pqina/filepond-docs/blob/master/content/patterns/API/filepond-object.md#filepond-status
17609
+ const FILE_STATUS = {
17610
+ INIT: 1,
17611
+ IDLE: 2,
17612
+ PROCESSING_QUEUED: 9,
17613
+ PROCESSING: 3,
17614
+ PROCESSING_COMPLETE: 5,
17615
+ // upload complete
17616
+ PROCESSING_ERROR: 6,
17617
+ PROCESSING_REVERT_ERROR: 10,
17618
+ LOADING: 7,
17619
+ LOAD_ERROR: 8
17620
+ };
17621
+ const FILE_ORIGIN = {
17622
+ INPUT: 1,
17623
+ // add by user
17624
+ LIMBO: 2,
17625
+ // temp file
17626
+ LOCAL: 3 // pre-loaded files
17627
+ };
17628
+
17137
17629
  const Upload = props => {
17138
17630
  const {
17139
17631
  schema,
@@ -17142,106 +17634,202 @@ const Upload = props => {
17142
17634
  "ui:options": {}
17143
17635
  },
17144
17636
  onChange,
17145
- disabled,
17146
- required
17637
+ disabled
17147
17638
  } = props;
17639
+ const emptyValue = uiSchema["ui:emptyValue"] || null;
17148
17640
  const isReadOnly = useReadOnly();
17149
17641
  const {
17150
- documentName: documentNameTemplate,
17151
- downloadUrl: downloadUrlTemplate,
17152
- extension: extensionTemplate,
17153
17642
  uploadDataSource,
17154
- mapUploadResponse,
17155
17643
  acceptedFileTypes,
17156
17644
  message,
17157
- isImage
17645
+ // TODO: can be handled generic way with HOC
17646
+ isImage = true,
17647
+ // multiple = true, // change to false
17648
+
17649
+ isPreviewHidden = false,
17650
+ idTemplate,
17651
+ downloadUrlTemplate,
17652
+ nameTemplate,
17653
+ mapUploadResponseToIdTemplate,
17654
+ maxFiles = 1,
17655
+ maxFileSize = null,
17656
+ maxTotalFileSize = null
17158
17657
  } = uiSchema["ui:options"];
17159
- const inputProps = uiSchema == null ? void 0 : uiSchema["ui:props"];
17160
- const documentName = useRender(documentNameTemplate);
17161
- const downloadUrl = useRenderUrl(downloadUrlTemplate);
17162
- useRender(extensionTemplate);
17163
- const [files, setFiles] = useState([]);
17164
- const uploadUrl = useMemo(() => getDataSourceUrl(uploadDataSource), [uploadDataSource]);
17165
-
17166
- // INFO: this state is needed to prevent re-load of file during submit
17167
- const [currentFileId, setCurrentFileId] = useState();
17168
17658
 
17169
- // TODO: change this to useMemo with help of useLastestDeps
17170
- useEffect(() => {
17171
- if (formData === currentFileId) return;
17172
- const files = [{
17173
- source: documentName || "File",
17174
- options: {
17175
- type: "local",
17176
- metadata: {
17177
- url: downloadUrl
17659
+ // TODO: implement single vs multipe mode, currently only multiple is active
17660
+ // let _formData = formData; if (multiple && (formData === null ||
17661
+ // formData === undefined)) { _formData = [];
17662
+ // }
17663
+ const _formData = formData || [];
17664
+ const initialFiles = useMemo(() => {
17665
+ return _formData.map(({
17666
+ data
17667
+ }) => {
17668
+ const id = mustache.render(idTemplate, data);
17669
+ const downloadUrl = downloadUrlTemplate ? decodeHtml$2(mustache.render(downloadUrlTemplate, data)) : downloadUrlTemplate;
17670
+ const name = mustache.render(nameTemplate, data);
17671
+ return {
17672
+ // INFO: source appears in preview but also needed to identify
17673
+ // the download URL. Check issue:
17674
+ // https://github.com/pqina/filepond/issues/284
17675
+ source: `${name} id:${id}`,
17676
+ options: {
17677
+ type: "local",
17678
+ origin: downloadUrl,
17679
+ // INFO: id is used in getFileIds function
17680
+ metadata: {
17681
+ url: downloadUrl,
17682
+ id
17683
+ }
17178
17684
  }
17179
- }
17180
- }];
17181
- if (formData != undefined) setFiles(files);
17182
- }, [formData]);
17183
- const handleLoad = (source, load, error) => {
17184
- fetch(downloadUrl).then(res => res.blob()).then(res => {
17685
+ };
17686
+ });
17687
+ }, []);
17688
+ const inputProps = uiSchema == null ? void 0 : uiSchema["ui:props"];
17689
+ const filePondRef = useRef();
17690
+ const getFileIds = () => {
17691
+ var _filePondRef$current;
17692
+ return ((_filePondRef$current = filePondRef.current) == null ? void 0 : _filePondRef$current.getFiles().filter(file => {
17693
+ const {
17694
+ origin,
17695
+ status
17696
+ } = file;
17697
+ if (origin === FILE_ORIGIN.LOCAL) return true;
17698
+ if (origin === FILE_ORIGIN.INPUT && status === FILE_STATUS.PROCESSING_COMPLETE) return true;
17699
+ }).map(file => {
17700
+ if (file.origin === FILE_ORIGIN.LOCAL) return file.getMetadata().id;
17701
+ return file.serverId;
17702
+ }).map(i => i.toString())) || [];
17703
+ };
17704
+ const uploadUrl = useMemo(() => getDataSourceUrl(uploadDataSource), [uploadDataSource]);
17705
+ const handleLoad = (source, load, error, progress, abort, headers) => {
17706
+ // INFO: source appears in preview but also needed to identify
17707
+ // the download URL. Check issue:
17708
+ // https://github.com/pqina/filepond/issues/284
17709
+ const file = initialFiles.find(item => item.source === source);
17710
+ const loadUrl = file.options.origin;
17711
+ fetch(loadUrl).then(res => res.blob()).then(res => {
17185
17712
  const file = res.type === "jpeg/jfif" || !res.type ? new Blob([res], {
17186
17713
  type: "image/jpeg"
17187
17714
  }) : res;
17188
- load(file);
17715
+ const preview = isPreviewHidden ? res : file;
17716
+ load(preview);
17189
17717
  }).catch(error);
17718
+
17719
+ // Should expose an abort method so the request can be cancelled
17720
+ return {
17721
+ abort: () => abort()
17722
+ };
17190
17723
  };
17191
17724
  const handleUploadResponse = res => {
17192
17725
  try {
17193
17726
  const jsonRes = JSON.parse(res);
17194
- const fileUuid = mapUploadResponse ? mustache.render(mapUploadResponse.fileUuid, jsonRes) : jsonRes.DATA.fileUuid;
17195
- setCurrentFileId(fileUuid);
17196
- onChange(fileUuid);
17727
+ const id = mustache.render(mapUploadResponseToIdTemplate, jsonRes);
17728
+ return id;
17197
17729
  } catch (err) {
17198
- console.log(err);
17730
+ var _window$logger;
17731
+ (_window$logger = window.logger) == null ? void 0 : _window$logger.sendLog({
17732
+ name: `Upload response could not be parsed. ${err}`,
17733
+ data: res
17734
+ });
17199
17735
  }
17200
17736
  };
17201
- const handleDelete = () => {
17202
- setCurrentFileId();
17203
- setFiles([]);
17204
- onChange();
17205
- };
17737
+
17738
+ // TODO: move to message HOC
17206
17739
  const messageProps = {
17207
17740
  title: (message == null ? void 0 : message.title) || undefined,
17208
17741
  description: (message == null ? void 0 : message.description) || undefined,
17209
17742
  type: (message == null ? void 0 : message.type) || "info",
17210
17743
  canDismiss: (message == null ? void 0 : message.canDismiss) || true
17211
17744
  };
17212
- const filePondProps = {
17213
- acceptedFileTypes: acceptedFileTypes ? acceptedFileTypes : isImage ? ["image/*"] : null,
17214
- files,
17215
- allowMultiple: false,
17216
- server: {
17217
- url: uploadUrl,
17218
- process: {
17219
- method: "POST",
17220
- headers: {
17221
- Methods: "POST"
17222
- },
17223
- onload: handleUploadResponse
17745
+ const {
17746
+ error
17747
+ } = useNotify();
17748
+ const handleFileChange = () => {
17749
+ const ids = getFileIds();
17750
+
17751
+ // TODO: fill the data
17752
+ const value = ids.map(id => ({
17753
+ value: id,
17754
+ data: {}
17755
+ }));
17756
+ if (value.length === 0) onChange(emptyValue);else onChange(value);
17757
+ };
17758
+
17759
+ // TODO: move to memo component
17760
+ const FileUpload = useMemo(() => {
17761
+ const styles = isReadOnly ? {
17762
+ // INFO: hide drop panel and drop panel
17763
+ "div>div>div.filepond--drop-label": {
17764
+ display: "none"
17224
17765
  },
17225
- load: handleLoad,
17226
- revert: handleDelete
17227
- },
17228
- onupdatefiles: files => {
17229
- if (files.length === 0) {
17230
- onChange(undefined);
17766
+ "button.filepond--action-remove-item": {
17767
+ display: "none"
17231
17768
  }
17232
- setFiles(files);
17233
- },
17234
- allowProcess: false,
17235
- disabled: isReadOnly,
17236
- allowDownloadByUrl: true
17237
- };
17238
- const overrideProps = typeof inputProps === "function" ? inputProps(filePondProps) : inputProps;
17769
+ } : null;
17770
+ const getAcceptedFileTypes = () => {
17771
+ if (acceptedFileTypes) return acceptedFileTypes;
17772
+ if (isImage) return ["image/*"];
17773
+ return null;
17774
+ };
17775
+ const filePondProps = {
17776
+ acceptedFileTypes: getAcceptedFileTypes(),
17777
+ files: initialFiles,
17778
+ // files: undefined,
17779
+ allowMultiple: true,
17780
+ server: {
17781
+ url: uploadUrl,
17782
+ process: {
17783
+ method: "POST",
17784
+ headers: {
17785
+ Methods: "POST"
17786
+ },
17787
+ onload: handleUploadResponse,
17788
+ onerror: e => {
17789
+ var _window$logger2;
17790
+ const message = `The image could not be uploaded.`;
17791
+ error(message);
17792
+ (_window$logger2 = window.logger) == null ? void 0 : _window$logger2.sendLog({
17793
+ name: message,
17794
+ data: e
17795
+ });
17796
+ }
17797
+ },
17798
+ load: handleLoad
17799
+ },
17800
+ onprocessfile: () => handleFileChange(),
17801
+ onremovefile: () => handleFileChange(),
17802
+ maxParallelUploads: 3,
17803
+ allowProcess: false,
17804
+ disabled: isReadOnly,
17805
+ allowDownloadByUrl: true,
17806
+ maxFiles: maxFiles,
17807
+ maxFileSize,
17808
+ maxTotalFileSize,
17809
+ // INFO: allowDrop create problem on file type validation //
17810
+ // (check badge form), for preview image allowDrop: false, //
17811
+ // labelIdle: "Click Here to Browse File(s)" //
17812
+ allowFileTypeValidation: false
17813
+ };
17814
+ const overrideProps = typeof inputProps === "function" ? inputProps(filePondProps) : inputProps;
17815
+ return /*#__PURE__*/jsx(Box$1, {
17816
+ sx: styles,
17817
+ children: /*#__PURE__*/jsx(FilePond, _extends({
17818
+ ref: filePondRef
17819
+ }, filePondProps, overrideProps))
17820
+ });
17821
+ }, []);
17822
+
17823
+ // TODO: better implementation
17239
17824
  if (isReadOnly) {
17240
17825
  if (formData == undefined) return /*#__PURE__*/jsx(ReadOnlyView, {
17241
17826
  label: schema.title,
17242
17827
  emptyViewText: "No file uploaded"
17243
17828
  });
17244
- if (isImage) return /*#__PURE__*/jsx(ImageUploadReadOnly, _extends({}, props));
17829
+ return /*#__PURE__*/jsx(ReadOnlyView, {
17830
+ label: schema.title,
17831
+ renderValue: () => FileUpload
17832
+ });
17245
17833
  }
17246
17834
  return /*#__PURE__*/jsxs(FieldContainer, {
17247
17835
  children: [/*#__PURE__*/jsxs(DisableWrapper, {
@@ -17258,7 +17846,7 @@ const Upload = props => {
17258
17846
  sx: {
17259
17847
  marginTop: 1
17260
17848
  },
17261
- children: /*#__PURE__*/jsx(FilePond, _extends({}, filePondProps, overrideProps))
17849
+ children: FileUpload
17262
17850
  })]
17263
17851
  }), message && /*#__PURE__*/jsx(Alert, _extends({}, messageProps))]
17264
17852
  });
@@ -18345,7 +18933,13 @@ const DateWidgetRaw = ({
18345
18933
  required: required,
18346
18934
  onChange: handleChange,
18347
18935
  disabled: disabled
18348
- }, uiSchema == null ? void 0 : uiSchema["ui:props"]));
18936
+ }, uiSchema == null ? void 0 : uiSchema["ui:props"], {
18937
+ componentsProps: {
18938
+ actionBar: {
18939
+ actions: ["cancel", "clear", "accept"]
18940
+ }
18941
+ }
18942
+ }));
18349
18943
  };
18350
18944
  DateWidgetRaw.propTypes = {
18351
18945
  onChange: PropTypes.func,
@@ -18480,1003 +19074,6 @@ const PhoneWidgetReadOnly = props => {
18480
19074
  const HOCs$5 = [...commonWidgetHOCs, withReadyOnly(PhoneWidgetReadOnly)];
18481
19075
  var PhoneWidget$1 = compose(HOCs$5)(PhoneWidget);
18482
19076
 
18483
- /**
18484
- * react-number-format - 5.1.3
18485
- * Author : Sudhanshu Yadav
18486
- * Copyright (c) 2016, 2023 to Sudhanshu Yadav, released under the MIT license.
18487
- * https://github.com/s-yadav/react-number-format
18488
- */
18489
-
18490
- /******************************************************************************
18491
- Copyright (c) Microsoft Corporation.
18492
-
18493
- Permission to use, copy, modify, and/or distribute this software for any
18494
- purpose with or without fee is hereby granted.
18495
-
18496
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
18497
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18498
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
18499
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18500
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18501
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18502
- PERFORMANCE OF THIS SOFTWARE.
18503
- ***************************************************************************** */
18504
-
18505
- function __rest(s, e) {
18506
- var t = {};
18507
- for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
18508
- { t[p] = s[p]; } }
18509
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18510
- { for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18511
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18512
- { t[p[i]] = s[p[i]]; }
18513
- } }
18514
- return t;
18515
- }
18516
-
18517
- var SourceType;
18518
- (function (SourceType) {
18519
- SourceType["event"] = "event";
18520
- SourceType["props"] = "prop";
18521
- })(SourceType || (SourceType = {}));
18522
-
18523
- // basic noop function
18524
- function noop() { }
18525
- function charIsNumber(char) {
18526
- return !!(char || '').match(/\d/);
18527
- }
18528
- function isNil(val) {
18529
- return val === null || val === undefined;
18530
- }
18531
- function isNanValue(val) {
18532
- return typeof val === 'number' && isNaN(val);
18533
- }
18534
- function escapeRegExp(str) {
18535
- return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
18536
- }
18537
- function getThousandsGroupRegex(thousandsGroupStyle) {
18538
- switch (thousandsGroupStyle) {
18539
- case 'lakh':
18540
- return /(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/g;
18541
- case 'wan':
18542
- return /(\d)(?=(\d{4})+(?!\d))/g;
18543
- case 'thousand':
18544
- default:
18545
- return /(\d)(?=(\d{3})+(?!\d))/g;
18546
- }
18547
- }
18548
- function applyThousandSeparator(str, thousandSeparator, thousandsGroupStyle) {
18549
- var thousandsGroupRegex = getThousandsGroupRegex(thousandsGroupStyle);
18550
- var index = str.search(/[1-9]/);
18551
- index = index === -1 ? str.length : index;
18552
- return (str.substring(0, index) +
18553
- str.substring(index, str.length).replace(thousandsGroupRegex, '$1' + thousandSeparator));
18554
- }
18555
- function usePersistentCallback(cb) {
18556
- var callbackRef = useRef(cb);
18557
- // keep the callback ref upto date
18558
- callbackRef.current = cb;
18559
- /**
18560
- * initialize a persistent callback which never changes
18561
- * through out the component lifecycle
18562
- */
18563
- var persistentCbRef = useRef(function () {
18564
- var args = [], len = arguments.length;
18565
- while ( len-- ) args[ len ] = arguments[ len ];
18566
-
18567
- return callbackRef.current.apply(callbackRef, args);
18568
- });
18569
- return persistentCbRef.current;
18570
- }
18571
- //spilt a float number into different parts beforeDecimal, afterDecimal, and negation
18572
- function splitDecimal(numStr, allowNegative) {
18573
- if ( allowNegative === void 0 ) allowNegative = true;
18574
-
18575
- var hasNegation = numStr[0] === '-';
18576
- var addNegation = hasNegation && allowNegative;
18577
- numStr = numStr.replace('-', '');
18578
- var parts = numStr.split('.');
18579
- var beforeDecimal = parts[0];
18580
- var afterDecimal = parts[1] || '';
18581
- return {
18582
- beforeDecimal: beforeDecimal,
18583
- afterDecimal: afterDecimal,
18584
- hasNegation: hasNegation,
18585
- addNegation: addNegation,
18586
- };
18587
- }
18588
- function fixLeadingZero(numStr) {
18589
- if (!numStr)
18590
- { return numStr; }
18591
- var isNegative = numStr[0] === '-';
18592
- if (isNegative)
18593
- { numStr = numStr.substring(1, numStr.length); }
18594
- var parts = numStr.split('.');
18595
- var beforeDecimal = parts[0].replace(/^0+/, '') || '0';
18596
- var afterDecimal = parts[1] || '';
18597
- return ("" + (isNegative ? '-' : '') + beforeDecimal + (afterDecimal ? ("." + afterDecimal) : ''));
18598
- }
18599
- /**
18600
- * limit decimal numbers to given scale
18601
- * Not used .fixedTo because that will break with big numbers
18602
- */
18603
- function limitToScale(numStr, scale, fixedDecimalScale) {
18604
- var str = '';
18605
- var filler = fixedDecimalScale ? '0' : '';
18606
- for (var i = 0; i <= scale - 1; i++) {
18607
- str += numStr[i] || filler;
18608
- }
18609
- return str;
18610
- }
18611
- function repeat(str, count) {
18612
- return Array(count + 1).join(str);
18613
- }
18614
- function toNumericString(num) {
18615
- var _num = num + ''; // typecast number to string
18616
- // store the sign and remove it from the number.
18617
- var sign = _num[0] === '-' ? '-' : '';
18618
- if (sign)
18619
- { _num = _num.substring(1); }
18620
- // split the number into cofficient and exponent
18621
- var ref = _num.split(/[eE]/g);
18622
- var coefficient = ref[0];
18623
- var exponent = ref[1];
18624
- // covert exponent to number;
18625
- exponent = Number(exponent);
18626
- // if there is no exponent part or its 0, return the coffiecient with sign
18627
- if (!exponent)
18628
- { return sign + coefficient; }
18629
- coefficient = coefficient.replace('.', '');
18630
- /**
18631
- * for scientific notation the current decimal index will be after first number (index 0)
18632
- * So effective decimal index will always be 1 + exponent value
18633
- */
18634
- var decimalIndex = 1 + exponent;
18635
- var coffiecientLn = coefficient.length;
18636
- if (decimalIndex < 0) {
18637
- // if decimal index is less then 0 add preceding 0s
18638
- // add 1 as join will have
18639
- coefficient = '0.' + repeat('0', Math.abs(decimalIndex)) + coefficient;
18640
- }
18641
- else if (decimalIndex >= coffiecientLn) {
18642
- // if decimal index is less then 0 add leading 0s
18643
- coefficient = coefficient + repeat('0', decimalIndex - coffiecientLn);
18644
- }
18645
- else {
18646
- // else add decimal point at proper index
18647
- coefficient =
18648
- (coefficient.substring(0, decimalIndex) || '0') + '.' + coefficient.substring(decimalIndex);
18649
- }
18650
- return sign + coefficient;
18651
- }
18652
- /**
18653
- * This method is required to round prop value to given scale.
18654
- * Not used .round or .fixedTo because that will break with big numbers
18655
- */
18656
- function roundToPrecision(numStr, scale, fixedDecimalScale) {
18657
- //if number is empty don't do anything return empty string
18658
- if (['', '-'].indexOf(numStr) !== -1)
18659
- { return numStr; }
18660
- var shouldHaveDecimalSeparator = (numStr.indexOf('.') !== -1 || fixedDecimalScale) && scale;
18661
- var ref = splitDecimal(numStr);
18662
- var beforeDecimal = ref.beforeDecimal;
18663
- var afterDecimal = ref.afterDecimal;
18664
- var hasNegation = ref.hasNegation;
18665
- var floatValue = parseFloat(("0." + (afterDecimal || '0')));
18666
- var floatValueStr = afterDecimal.length <= scale ? ("0." + afterDecimal) : floatValue.toFixed(scale);
18667
- var roundedDecimalParts = floatValueStr.split('.');
18668
- var intPart = beforeDecimal
18669
- .split('')
18670
- .reverse()
18671
- .reduce(function (roundedStr, current, idx) {
18672
- if (roundedStr.length > idx) {
18673
- return ((Number(roundedStr[0]) + Number(current)).toString() +
18674
- roundedStr.substring(1, roundedStr.length));
18675
- }
18676
- return current + roundedStr;
18677
- }, roundedDecimalParts[0]);
18678
- var decimalPart = limitToScale(roundedDecimalParts[1] || '', scale, fixedDecimalScale);
18679
- var negation = hasNegation ? '-' : '';
18680
- var decimalSeparator = shouldHaveDecimalSeparator ? '.' : '';
18681
- return ("" + negation + intPart + decimalSeparator + decimalPart);
18682
- }
18683
- /** set the caret positon in an input field **/
18684
- function setCaretPosition(el, caretPos) {
18685
- el.value = el.value;
18686
- // ^ this is used to not only get 'focus', but
18687
- // to make sure we don't have it everything -selected-
18688
- // (it causes an issue in chrome, and having it doesn't hurt any other browser)
18689
- if (el !== null) {
18690
- /* @ts-ignore */
18691
- if (el.createTextRange) {
18692
- /* @ts-ignore */
18693
- var range = el.createTextRange();
18694
- range.move('character', caretPos);
18695
- range.select();
18696
- return true;
18697
- }
18698
- // (el.selectionStart === 0 added for Firefox bug)
18699
- if (el.selectionStart || el.selectionStart === 0) {
18700
- el.focus();
18701
- el.setSelectionRange(caretPos, caretPos);
18702
- return true;
18703
- }
18704
- // fail city, fortunately this never happens (as far as I've tested) :)
18705
- el.focus();
18706
- return false;
18707
- }
18708
- }
18709
- function findChangeRange(prevValue, newValue) {
18710
- var i = 0, j = 0;
18711
- var prevLength = prevValue.length;
18712
- var newLength = newValue.length;
18713
- while (prevValue[i] === newValue[i] && i < prevLength)
18714
- { i++; }
18715
- //check what has been changed from last
18716
- while (prevValue[prevLength - 1 - j] === newValue[newLength - 1 - j] &&
18717
- newLength - j > i &&
18718
- prevLength - j > i) {
18719
- j++;
18720
- }
18721
- return {
18722
- from: { start: i, end: prevLength - j },
18723
- to: { start: i, end: newLength - j },
18724
- };
18725
- }
18726
- /*
18727
- Returns a number whose value is limited to the given range
18728
- */
18729
- function clamp(num, min, max) {
18730
- return Math.min(Math.max(num, min), max);
18731
- }
18732
- function geInputCaretPosition(el) {
18733
- /*Max of selectionStart and selectionEnd is taken for the patch of pixel and other mobile device caret bug*/
18734
- return Math.max(el.selectionStart, el.selectionEnd);
18735
- }
18736
- function addInputMode() {
18737
- return (typeof navigator !== 'undefined' &&
18738
- !(navigator.platform && /iPhone|iPod/.test(navigator.platform)));
18739
- }
18740
- function getDefaultChangeMeta(value) {
18741
- return {
18742
- from: {
18743
- start: 0,
18744
- end: 0,
18745
- },
18746
- to: {
18747
- start: 0,
18748
- end: value.length,
18749
- },
18750
- lastValue: '',
18751
- };
18752
- }
18753
- function getCaretPosition(newFormattedValue, lastFormattedValue, curValue, curCaretPos, boundary, isValidInputCharacter) {
18754
- /**
18755
- * if something got inserted on empty value, add the formatted character before the current value,
18756
- * This is to avoid the case where typed character is present on format characters
18757
- */
18758
- var firstAllowedPosition = boundary.findIndex(function (b) { return b; });
18759
- var prefixFormat = newFormattedValue.slice(0, firstAllowedPosition);
18760
- if (!lastFormattedValue && !curValue.startsWith(prefixFormat)) {
18761
- curValue = prefixFormat + curValue;
18762
- curCaretPos = curCaretPos + prefixFormat.length;
18763
- }
18764
- var curValLn = curValue.length;
18765
- var formattedValueLn = newFormattedValue.length;
18766
- // create index map
18767
- var addedIndexMap = {};
18768
- var indexMap = new Array(curValLn);
18769
- for (var i = 0; i < curValLn; i++) {
18770
- indexMap[i] = -1;
18771
- for (var j = 0, jLn = formattedValueLn; j < jLn; j++) {
18772
- if (curValue[i] === newFormattedValue[j] && addedIndexMap[j] !== true) {
18773
- indexMap[i] = j;
18774
- addedIndexMap[j] = true;
18775
- break;
18776
- }
18777
- }
18778
- }
18779
- /**
18780
- * For current caret position find closest characters (left and right side)
18781
- * which are properly mapped to formatted value.
18782
- * The idea is that the new caret position will exist always in the boundary of
18783
- * that mapped index
18784
- */
18785
- var pos = curCaretPos;
18786
- while (pos < curValLn && (indexMap[pos] === -1 || !isValidInputCharacter(curValue[pos]))) {
18787
- pos++;
18788
- }
18789
- // if the caret position is on last keep the endIndex as last for formatted value
18790
- var endIndex = pos === curValLn || indexMap[pos] === -1 ? formattedValueLn : indexMap[pos];
18791
- pos = curCaretPos - 1;
18792
- while (pos > 0 && indexMap[pos] === -1)
18793
- { pos--; }
18794
- var startIndex = pos === -1 || indexMap[pos] === -1 ? 0 : indexMap[pos] + 1;
18795
- /**
18796
- * case where a char is added on suffix and removed from middle, example 2sq345 becoming $2,345 sq
18797
- * there is still a mapping but the order of start index and end index is changed
18798
- */
18799
- if (startIndex > endIndex)
18800
- { return endIndex; }
18801
- /**
18802
- * given the current caret position if it closer to startIndex
18803
- * keep the new caret position on start index or keep it closer to endIndex
18804
- */
18805
- return curCaretPos - startIndex < endIndex - curCaretPos ? startIndex : endIndex;
18806
- }
18807
- /* This keeps the caret within typing area so people can't type in between prefix or suffix or format characters */
18808
- function getCaretPosInBoundary(value, caretPos, boundary, direction) {
18809
- var valLn = value.length;
18810
- // clamp caret position to [0, value.length]
18811
- caretPos = clamp(caretPos, 0, valLn);
18812
- if (direction === 'left') {
18813
- while (caretPos >= 0 && !boundary[caretPos])
18814
- { caretPos--; }
18815
- // if we don't find any suitable caret position on left, set it on first allowed position
18816
- if (caretPos === -1)
18817
- { caretPos = boundary.indexOf(true); }
18818
- }
18819
- else {
18820
- while (caretPos <= valLn && !boundary[caretPos])
18821
- { caretPos++; }
18822
- // if we don't find any suitable caret position on right, set it on last allowed position
18823
- if (caretPos > valLn)
18824
- { caretPos = boundary.lastIndexOf(true); }
18825
- }
18826
- // if we still don't find caret position, set it at the end of value
18827
- if (caretPos === -1)
18828
- { caretPos = valLn; }
18829
- return caretPos;
18830
- }
18831
- function caretUnknownFormatBoundary(formattedValue) {
18832
- var boundaryAry = Array.from({ length: formattedValue.length + 1 }).map(function () { return true; });
18833
- for (var i = 0, ln = boundaryAry.length; i < ln; i++) {
18834
- // consider caret to be in boundary if it is before or after numeric value
18835
- boundaryAry[i] = Boolean(charIsNumber(formattedValue[i]) || charIsNumber(formattedValue[i - 1]));
18836
- }
18837
- return boundaryAry;
18838
- }
18839
- function useInternalValues(value, defaultValue, valueIsNumericString, format, removeFormatting, onValueChange) {
18840
- if ( onValueChange === void 0 ) onValueChange = noop;
18841
-
18842
- var propValues = useRef();
18843
- var getValues = usePersistentCallback(function (value) {
18844
- var formattedValue, numAsString;
18845
- if (isNil(value) || isNanValue(value)) {
18846
- numAsString = '';
18847
- formattedValue = '';
18848
- }
18849
- else if (typeof value === 'number' || valueIsNumericString) {
18850
- numAsString = typeof value === 'number' ? toNumericString(value) : value;
18851
- formattedValue = format(numAsString);
18852
- }
18853
- else {
18854
- numAsString = removeFormatting(value, undefined);
18855
- formattedValue = value;
18856
- }
18857
- return { formattedValue: formattedValue, numAsString: numAsString };
18858
- });
18859
- var ref = useState(function () {
18860
- return getValues(defaultValue);
18861
- });
18862
- var values = ref[0];
18863
- var setValues = ref[1];
18864
- var _onValueChange = function (values, sourceInfo) {
18865
- setValues({
18866
- formattedValue: values.formattedValue,
18867
- numAsString: values.value,
18868
- });
18869
- onValueChange(values, sourceInfo);
18870
- };
18871
- useMemo(function () {
18872
- //if element is moved to uncontrolled mode, don't reset the value
18873
- if (!isNil(value)) {
18874
- propValues.current = getValues(value);
18875
- setValues(propValues.current);
18876
- }
18877
- else {
18878
- propValues.current = undefined;
18879
- }
18880
- }, [value, getValues]);
18881
- return [values, _onValueChange];
18882
- }
18883
-
18884
- function defaultRemoveFormatting(value) {
18885
- return value.replace(/[^0-9]/g, '');
18886
- }
18887
- function defaultFormat(value) {
18888
- return value;
18889
- }
18890
- function NumberFormatBase(props) {
18891
- var type = props.type; if ( type === void 0 ) type = 'text';
18892
- var displayType = props.displayType; if ( displayType === void 0 ) displayType = 'input';
18893
- var customInput = props.customInput;
18894
- var renderText = props.renderText;
18895
- var getInputRef = props.getInputRef;
18896
- var format = props.format; if ( format === void 0 ) format = defaultFormat;
18897
- var removeFormatting = props.removeFormatting; if ( removeFormatting === void 0 ) removeFormatting = defaultRemoveFormatting;
18898
- var defaultValue = props.defaultValue;
18899
- var valueIsNumericString = props.valueIsNumericString;
18900
- var onValueChange = props.onValueChange;
18901
- var isAllowed = props.isAllowed;
18902
- var onChange = props.onChange; if ( onChange === void 0 ) onChange = noop;
18903
- var onKeyDown = props.onKeyDown; if ( onKeyDown === void 0 ) onKeyDown = noop;
18904
- var onMouseUp = props.onMouseUp; if ( onMouseUp === void 0 ) onMouseUp = noop;
18905
- var onFocus = props.onFocus; if ( onFocus === void 0 ) onFocus = noop;
18906
- var onBlur = props.onBlur; if ( onBlur === void 0 ) onBlur = noop;
18907
- var propValue = props.value;
18908
- var getCaretBoundary = props.getCaretBoundary; if ( getCaretBoundary === void 0 ) getCaretBoundary = caretUnknownFormatBoundary;
18909
- var isValidInputCharacter = props.isValidInputCharacter; if ( isValidInputCharacter === void 0 ) isValidInputCharacter = charIsNumber;
18910
- var otherProps = __rest(props, ["type", "displayType", "customInput", "renderText", "getInputRef", "format", "removeFormatting", "defaultValue", "valueIsNumericString", "onValueChange", "isAllowed", "onChange", "onKeyDown", "onMouseUp", "onFocus", "onBlur", "value", "getCaretBoundary", "isValidInputCharacter"]);
18911
- var ref = useInternalValues(propValue, defaultValue, Boolean(valueIsNumericString), format, removeFormatting, onValueChange);
18912
- var ref_0 = ref[0];
18913
- var formattedValue = ref_0.formattedValue;
18914
- var numAsString = ref_0.numAsString;
18915
- var onFormattedValueChange = ref[1];
18916
- var lastUpdatedValue = useRef();
18917
- var _onValueChange = function (values, source) {
18918
- lastUpdatedValue.current = values.formattedValue;
18919
- onFormattedValueChange(values, source);
18920
- };
18921
- // check if there is any change in the value due to props change
18922
- useEffect(function () {
18923
- var newFormattedValue = format(numAsString);
18924
- // if the formatted value is not synced to parent, or if the formatted value is different
18925
- if (lastUpdatedValue.current === undefined || newFormattedValue !== lastUpdatedValue.current) {
18926
- var input = focusedElm.current;
18927
- // formatting can remove some of the number chars, so we need to fine number string again
18928
- var _numAsString = removeFormatting(newFormattedValue, undefined);
18929
- updateValue({
18930
- formattedValue: newFormattedValue,
18931
- numAsString: _numAsString,
18932
- input: input,
18933
- setCaretPosition: true,
18934
- source: SourceType.props,
18935
- event: undefined,
18936
- });
18937
- }
18938
- });
18939
- var ref$1 = useState(false);
18940
- var mounted = ref$1[0];
18941
- var setMounted = ref$1[1];
18942
- var focusedElm = useRef(null);
18943
- var timeout = useRef({
18944
- setCaretTimeout: null,
18945
- focusTimeout: null,
18946
- });
18947
- useEffect(function () {
18948
- setMounted(true);
18949
- return function () {
18950
- clearTimeout(timeout.current.setCaretTimeout);
18951
- clearTimeout(timeout.current.focusTimeout);
18952
- };
18953
- }, []);
18954
- var _format = format;
18955
- var getValueObject = function (formattedValue, numAsString) {
18956
- var floatValue = parseFloat(numAsString);
18957
- return {
18958
- formattedValue: formattedValue,
18959
- value: numAsString,
18960
- floatValue: isNaN(floatValue) ? undefined : floatValue,
18961
- };
18962
- };
18963
- var setPatchedCaretPosition = function (el, caretPos, currentValue) {
18964
- /* setting caret position within timeout of 0ms is required for mobile chrome,
18965
- otherwise browser resets the caret position after we set it
18966
- We are also setting it without timeout so that in normal browser we don't see the flickering */
18967
- setCaretPosition(el, caretPos);
18968
- timeout.current.setCaretTimeout = setTimeout(function () {
18969
- if (el.value === currentValue)
18970
- { setCaretPosition(el, caretPos); }
18971
- }, 0);
18972
- };
18973
- /* This keeps the caret within typing area so people can't type in between prefix or suffix */
18974
- var correctCaretPosition = function (value, caretPos, direction) {
18975
- return getCaretPosInBoundary(value, caretPos, getCaretBoundary(value), direction);
18976
- };
18977
- var getNewCaretPosition = function (inputValue, newFormattedValue, caretPos) {
18978
- var caretBoundary = getCaretBoundary(newFormattedValue);
18979
- var updatedCaretPos = getCaretPosition(newFormattedValue, formattedValue, inputValue, caretPos, caretBoundary, isValidInputCharacter);
18980
- //correct caret position if its outside of editable area
18981
- updatedCaretPos = getCaretPosInBoundary(newFormattedValue, updatedCaretPos, caretBoundary);
18982
- return updatedCaretPos;
18983
- };
18984
- var updateValue = function (params) {
18985
- var newFormattedValue = params.formattedValue; if ( newFormattedValue === void 0 ) newFormattedValue = '';
18986
- var input = params.input;
18987
- var setCaretPosition = params.setCaretPosition; if ( setCaretPosition === void 0 ) setCaretPosition = true;
18988
- var source = params.source;
18989
- var event = params.event;
18990
- var numAsString = params.numAsString;
18991
- var caretPos = params.caretPos;
18992
- if (input) {
18993
- //calculate caret position if not defined
18994
- if (caretPos === undefined && setCaretPosition) {
18995
- var inputValue = params.inputValue || input.value;
18996
- var currentCaretPosition = geInputCaretPosition(input);
18997
- /**
18998
- * set the value imperatively, this is required for IE fix
18999
- * This is also required as if new caret position is beyond the previous value.
19000
- * Caret position will not be set correctly
19001
- */
19002
- input.value = newFormattedValue;
19003
- //get the caret position
19004
- caretPos = getNewCaretPosition(inputValue, newFormattedValue, currentCaretPosition);
19005
- }
19006
- /**
19007
- * set the value imperatively, as we set the caret position as well imperatively.
19008
- * This is to keep value and caret position in sync
19009
- */
19010
- input.value = newFormattedValue;
19011
- //set caret position, and value imperatively when element is provided
19012
- if (setCaretPosition && caretPos !== undefined) {
19013
- //set caret position
19014
- setPatchedCaretPosition(input, caretPos, newFormattedValue);
19015
- }
19016
- }
19017
- if (newFormattedValue !== formattedValue) {
19018
- // trigger onValueChange synchronously, so parent is updated along with the number format. Fix for #277, #287
19019
- _onValueChange(getValueObject(newFormattedValue, numAsString), { event: event, source: source });
19020
- }
19021
- };
19022
- var formatInputValue = function (inputValue, event, source) {
19023
- var changeRange = findChangeRange(formattedValue, inputValue);
19024
- var changeMeta = Object.assign(Object.assign({}, changeRange), { lastValue: formattedValue });
19025
- var _numAsString = removeFormatting(inputValue, changeMeta);
19026
- var _formattedValue = _format(_numAsString);
19027
- // formatting can remove some of the number chars, so we need to fine number string again
19028
- _numAsString = removeFormatting(_formattedValue, undefined);
19029
- if (isAllowed && !isAllowed(getValueObject(_formattedValue, _numAsString))) {
19030
- //reset the caret position
19031
- var input = event.target;
19032
- var currentCaretPosition = geInputCaretPosition(input);
19033
- var caretPos = getNewCaretPosition(inputValue, formattedValue, currentCaretPosition);
19034
- setPatchedCaretPosition(input, caretPos, formattedValue);
19035
- return false;
19036
- }
19037
- updateValue({
19038
- formattedValue: _formattedValue,
19039
- numAsString: _numAsString,
19040
- inputValue: inputValue,
19041
- event: event,
19042
- source: source,
19043
- setCaretPosition: true,
19044
- input: event.target,
19045
- });
19046
- return true;
19047
- };
19048
- var _onChange = function (e) {
19049
- var el = e.target;
19050
- var inputValue = el.value;
19051
- var changed = formatInputValue(inputValue, e, SourceType.event);
19052
- if (changed)
19053
- { onChange(e); }
19054
- };
19055
- var _onKeyDown = function (e) {
19056
- var el = e.target;
19057
- var key = e.key;
19058
- var selectionStart = el.selectionStart;
19059
- var selectionEnd = el.selectionEnd;
19060
- var value = el.value; if ( value === void 0 ) value = '';
19061
- var expectedCaretPosition;
19062
- //Handle backspace and delete against non numerical/decimal characters or arrow keys
19063
- if (key === 'ArrowLeft' || key === 'Backspace') {
19064
- expectedCaretPosition = Math.max(selectionStart - 1, 0);
19065
- }
19066
- else if (key === 'ArrowRight') {
19067
- expectedCaretPosition = Math.min(selectionStart + 1, value.length);
19068
- }
19069
- else if (key === 'Delete') {
19070
- expectedCaretPosition = selectionStart;
19071
- }
19072
- //if expectedCaretPosition is not set it means we don't want to Handle keyDown
19073
- // also if multiple characters are selected don't handle
19074
- if (expectedCaretPosition === undefined || selectionStart !== selectionEnd) {
19075
- onKeyDown(e);
19076
- return;
19077
- }
19078
- var newCaretPosition = expectedCaretPosition;
19079
- if (key === 'ArrowLeft' || key === 'ArrowRight') {
19080
- var direction = key === 'ArrowLeft' ? 'left' : 'right';
19081
- newCaretPosition = correctCaretPosition(value, expectedCaretPosition, direction);
19082
- }
19083
- else if (key === 'Delete' && !isValidInputCharacter(value[expectedCaretPosition])) {
19084
- // in case of delete go to closest caret boundary on the right side
19085
- newCaretPosition = correctCaretPosition(value, expectedCaretPosition, 'right');
19086
- }
19087
- else if (key === 'Backspace' && !isValidInputCharacter(value[expectedCaretPosition])) {
19088
- // in case of backspace go to closest caret boundary on the left side
19089
- newCaretPosition = correctCaretPosition(value, expectedCaretPosition, 'left');
19090
- }
19091
- if (newCaretPosition !== expectedCaretPosition) {
19092
- setPatchedCaretPosition(el, newCaretPosition, value);
19093
- }
19094
- /* NOTE: this is just required for unit test as we need to get the newCaretPosition,
19095
- Remove this when you find different solution */
19096
- /* @ts-ignore */
19097
- if (e.isUnitTestRun) {
19098
- setPatchedCaretPosition(el, newCaretPosition, value);
19099
- }
19100
- onKeyDown(e);
19101
- };
19102
- /** required to handle the caret position when click anywhere within the input **/
19103
- var _onMouseUp = function (e) {
19104
- var el = e.target;
19105
- /**
19106
- * NOTE: we have to give default value for value as in case when custom input is provided
19107
- * value can come as undefined when nothing is provided on value prop.
19108
- */
19109
- var selectionStart = el.selectionStart;
19110
- var selectionEnd = el.selectionEnd;
19111
- var value = el.value; if ( value === void 0 ) value = '';
19112
- if (selectionStart === selectionEnd) {
19113
- var caretPosition = correctCaretPosition(value, selectionStart);
19114
- if (caretPosition !== selectionStart) {
19115
- setPatchedCaretPosition(el, caretPosition, value);
19116
- }
19117
- }
19118
- onMouseUp(e);
19119
- };
19120
- var _onFocus = function (e) {
19121
- // Workaround Chrome and Safari bug https://bugs.chromium.org/p/chromium/issues/detail?id=779328
19122
- // (onFocus event target selectionStart is always 0 before setTimeout)
19123
- if (e.persist)
19124
- { e.persist(); }
19125
- var el = e.target;
19126
- focusedElm.current = el;
19127
- timeout.current.focusTimeout = setTimeout(function () {
19128
- var selectionStart = el.selectionStart;
19129
- var selectionEnd = el.selectionEnd;
19130
- var value = el.value; if ( value === void 0 ) value = '';
19131
- var caretPosition = correctCaretPosition(value, selectionStart);
19132
- //setPatchedCaretPosition only when everything is not selected on focus (while tabbing into the field)
19133
- if (caretPosition !== selectionStart &&
19134
- !(selectionStart === 0 && selectionEnd === value.length)) {
19135
- setPatchedCaretPosition(el, caretPosition, value);
19136
- }
19137
- onFocus(e);
19138
- }, 0);
19139
- };
19140
- var _onBlur = function (e) {
19141
- focusedElm.current = null;
19142
- clearTimeout(timeout.current.focusTimeout);
19143
- clearTimeout(timeout.current.setCaretTimeout);
19144
- onBlur(e);
19145
- };
19146
- // add input mode on element based on format prop and device once the component is mounted
19147
- var inputMode = mounted && addInputMode() ? 'numeric' : undefined;
19148
- var inputProps = Object.assign({ inputMode: inputMode }, otherProps, {
19149
- type: type,
19150
- value: formattedValue,
19151
- onChange: _onChange,
19152
- onKeyDown: _onKeyDown,
19153
- onMouseUp: _onMouseUp,
19154
- onFocus: _onFocus,
19155
- onBlur: _onBlur,
19156
- });
19157
- if (displayType === 'text') {
19158
- return renderText ? (React.createElement(React.Fragment, null, renderText(formattedValue, otherProps) || null)) : (React.createElement("span", Object.assign({}, otherProps, { ref: getInputRef }), formattedValue));
19159
- }
19160
- else if (customInput) {
19161
- var CustomInput = customInput;
19162
- /* @ts-ignore */
19163
- return React.createElement(CustomInput, Object.assign({}, inputProps, { ref: getInputRef }));
19164
- }
19165
- return React.createElement("input", Object.assign({}, inputProps, { ref: getInputRef }));
19166
- }
19167
-
19168
- function format(numStr, props) {
19169
- var decimalScale = props.decimalScale;
19170
- var fixedDecimalScale = props.fixedDecimalScale;
19171
- var prefix = props.prefix; if ( prefix === void 0 ) prefix = '';
19172
- var suffix = props.suffix; if ( suffix === void 0 ) suffix = '';
19173
- var allowNegative = props.allowNegative; if ( allowNegative === void 0 ) allowNegative = true;
19174
- var thousandsGroupStyle = props.thousandsGroupStyle; if ( thousandsGroupStyle === void 0 ) thousandsGroupStyle = 'thousand';
19175
- // don't apply formatting on empty string or '-'
19176
- if (numStr === '' || numStr === '-') {
19177
- return numStr;
19178
- }
19179
- var ref = getSeparators(props);
19180
- var thousandSeparator = ref.thousandSeparator;
19181
- var decimalSeparator = ref.decimalSeparator;
19182
- /**
19183
- * Keep the decimal separator
19184
- * when decimalScale is not defined or non zero and the numStr has decimal in it
19185
- * Or if decimalScale is > 0 and fixeDecimalScale is true (even if numStr has no decimal)
19186
- */
19187
- var hasDecimalSeparator = (decimalScale !== 0 && numStr.indexOf('.') !== -1) || (decimalScale && fixedDecimalScale);
19188
- var ref$1 = splitDecimal(numStr, allowNegative);
19189
- var beforeDecimal = ref$1.beforeDecimal;
19190
- var afterDecimal = ref$1.afterDecimal;
19191
- var addNegation = ref$1.addNegation; // eslint-disable-line prefer-const
19192
- //apply decimal precision if its defined
19193
- if (decimalScale !== undefined) {
19194
- afterDecimal = limitToScale(afterDecimal, decimalScale, !!fixedDecimalScale);
19195
- }
19196
- if (thousandSeparator) {
19197
- beforeDecimal = applyThousandSeparator(beforeDecimal, thousandSeparator, thousandsGroupStyle);
19198
- }
19199
- //add prefix and suffix when there is a number present
19200
- if (prefix)
19201
- { beforeDecimal = prefix + beforeDecimal; }
19202
- if (suffix)
19203
- { afterDecimal = afterDecimal + suffix; }
19204
- //restore negation sign
19205
- if (addNegation)
19206
- { beforeDecimal = '-' + beforeDecimal; }
19207
- numStr = beforeDecimal + ((hasDecimalSeparator && decimalSeparator) || '') + afterDecimal;
19208
- return numStr;
19209
- }
19210
- function getSeparators(props) {
19211
- var decimalSeparator = props.decimalSeparator; if ( decimalSeparator === void 0 ) decimalSeparator = '.';
19212
- var thousandSeparator = props.thousandSeparator;
19213
- var allowedDecimalSeparators = props.allowedDecimalSeparators;
19214
- if (thousandSeparator === true) {
19215
- thousandSeparator = ',';
19216
- }
19217
- if (!allowedDecimalSeparators) {
19218
- allowedDecimalSeparators = [decimalSeparator, '.'];
19219
- }
19220
- return {
19221
- decimalSeparator: decimalSeparator,
19222
- thousandSeparator: thousandSeparator,
19223
- allowedDecimalSeparators: allowedDecimalSeparators,
19224
- };
19225
- }
19226
- function handleNegation(value, allowNegative) {
19227
- if ( value === void 0 ) value = '';
19228
-
19229
- var negationRegex = new RegExp('(-)');
19230
- var doubleNegationRegex = new RegExp('(-)(.)*(-)');
19231
- // Check number has '-' value
19232
- var hasNegation = negationRegex.test(value);
19233
- // Check number has 2 or more '-' values
19234
- var removeNegation = doubleNegationRegex.test(value);
19235
- //remove negation
19236
- value = value.replace(/-/g, '');
19237
- if (hasNegation && !removeNegation && allowNegative) {
19238
- value = '-' + value;
19239
- }
19240
- return value;
19241
- }
19242
- function getNumberRegex(decimalSeparator, global) {
19243
- return new RegExp(("(^-)|[0-9]|" + (escapeRegExp(decimalSeparator))), global ? 'g' : undefined);
19244
- }
19245
- function removeFormatting(value, changeMeta, props) {
19246
- if ( changeMeta === void 0 ) changeMeta = getDefaultChangeMeta(value);
19247
-
19248
- var allowNegative = props.allowNegative; if ( allowNegative === void 0 ) allowNegative = true;
19249
- var prefix = props.prefix; if ( prefix === void 0 ) prefix = '';
19250
- var suffix = props.suffix; if ( suffix === void 0 ) suffix = '';
19251
- var decimalScale = props.decimalScale;
19252
- var from = changeMeta.from;
19253
- var to = changeMeta.to;
19254
- var start = to.start;
19255
- var end = to.end;
19256
- var ref = getSeparators(props);
19257
- var allowedDecimalSeparators = ref.allowedDecimalSeparators;
19258
- var decimalSeparator = ref.decimalSeparator;
19259
- var isBeforeDecimalSeparator = value[end] === decimalSeparator;
19260
- /** Check for any allowed decimal separator is added in the numeric format and replace it with decimal separator */
19261
- if (end - start === 1 && allowedDecimalSeparators.indexOf(value[start]) !== -1) {
19262
- var separator = decimalScale === 0 ? '' : decimalSeparator;
19263
- value = value.substring(0, start) + separator + value.substring(start + 1, value.length);
19264
- }
19265
- var hasNegation = false;
19266
- /**
19267
- * if prefix starts with - the number hast to have two - at the start
19268
- * if suffix starts with - and the value length is same as suffix length, then the - sign is from the suffix
19269
- * In other cases, if the value starts with - then it is a negation
19270
- */
19271
- if (prefix.startsWith('-'))
19272
- { hasNegation = value.startsWith('--'); }
19273
- else if (suffix.startsWith('-') && value.length === suffix.length)
19274
- { hasNegation = false; }
19275
- else if (value[0] === '-')
19276
- { hasNegation = true; }
19277
- // remove negation from start to simplify prefix logic as negation comes before prefix
19278
- if (hasNegation) {
19279
- value = value.substring(1);
19280
- // account for the removal of the negation for start and end index
19281
- start -= 1;
19282
- end -= 1;
19283
- }
19284
- /**
19285
- * remove prefix
19286
- * Remove whole prefix part if its present on the value
19287
- * If the prefix is partially deleted (in which case change start index will be less the prefix length)
19288
- * Remove only partial part of prefix.
19289
- */
19290
- var startIndex = 0;
19291
- if (value.startsWith(prefix))
19292
- { startIndex += prefix.length; }
19293
- else if (start < prefix.length)
19294
- { startIndex = start; }
19295
- value = value.substring(startIndex);
19296
- // account for deleted prefix for end index
19297
- end -= startIndex;
19298
- /**
19299
- * Remove suffix
19300
- * Remove whole suffix part if its present on the value
19301
- * If the suffix is partially deleted (in which case change end index will be greater than the suffixStartIndex)
19302
- * remove the partial part of suffix
19303
- */
19304
- var endIndex = value.length;
19305
- var suffixStartIndex = value.length - suffix.length;
19306
- if (value.endsWith(suffix))
19307
- { endIndex = suffixStartIndex; }
19308
- else if (end > value.length - suffix.length)
19309
- { endIndex = end; }
19310
- value = value.substring(0, endIndex);
19311
- // add the negation back and handle for double negation
19312
- value = handleNegation(hasNegation ? ("-" + value) : value, allowNegative);
19313
- // remove non numeric characters
19314
- value = (value.match(getNumberRegex(decimalSeparator, true)) || []).join('');
19315
- // replace the decimalSeparator with ., and only keep the first separator, ignore following ones
19316
- var firstIndex = value.indexOf(decimalSeparator);
19317
- value = value.replace(new RegExp(escapeRegExp(decimalSeparator), 'g'), function (match, index) {
19318
- return index === firstIndex ? '.' : '';
19319
- });
19320
- //check if beforeDecimal got deleted and there is nothing after decimal,
19321
- //clear all numbers in such case while keeping the - sign
19322
- var ref$1 = splitDecimal(value, allowNegative);
19323
- var beforeDecimal = ref$1.beforeDecimal;
19324
- var afterDecimal = ref$1.afterDecimal;
19325
- var addNegation = ref$1.addNegation; // eslint-disable-line prefer-const
19326
- //clear only if something got deleted before decimal (cursor is before decimal)
19327
- if (to.end - to.start < from.end - from.start &&
19328
- beforeDecimal === '' &&
19329
- isBeforeDecimalSeparator &&
19330
- !parseFloat(afterDecimal)) {
19331
- value = addNegation ? '-' : '';
19332
- }
19333
- return value;
19334
- }
19335
- function getCaretBoundary(formattedValue, props) {
19336
- var prefix = props.prefix; if ( prefix === void 0 ) prefix = '';
19337
- var suffix = props.suffix; if ( suffix === void 0 ) suffix = '';
19338
- var boundaryAry = Array.from({ length: formattedValue.length + 1 }).map(function () { return true; });
19339
- var hasNegation = formattedValue[0] === '-';
19340
- // fill for prefix and negation
19341
- boundaryAry.fill(false, 0, prefix.length + (hasNegation ? 1 : 0));
19342
- // fill for suffix
19343
- var valLn = formattedValue.length;
19344
- boundaryAry.fill(false, valLn - suffix.length + 1, valLn + 1);
19345
- return boundaryAry;
19346
- }
19347
- function validateProps(props) {
19348
- var ref = getSeparators(props);
19349
- var thousandSeparator = ref.thousandSeparator;
19350
- var decimalSeparator = ref.decimalSeparator;
19351
- if (thousandSeparator === decimalSeparator) {
19352
- 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 "));
19353
- }
19354
- }
19355
- function useNumericFormat(props) {
19356
- var decimalSeparator = props.decimalSeparator; if ( decimalSeparator === void 0 ) decimalSeparator = '.';
19357
- var allowLeadingZeros = props.allowLeadingZeros;
19358
- var onKeyDown = props.onKeyDown; if ( onKeyDown === void 0 ) onKeyDown = noop;
19359
- var onBlur = props.onBlur; if ( onBlur === void 0 ) onBlur = noop;
19360
- var thousandSeparator = props.thousandSeparator;
19361
- var decimalScale = props.decimalScale;
19362
- var fixedDecimalScale = props.fixedDecimalScale;
19363
- var prefix = props.prefix; if ( prefix === void 0 ) prefix = '';
19364
- var defaultValue = props.defaultValue;
19365
- var value = props.value;
19366
- var valueIsNumericString = props.valueIsNumericString;
19367
- var onValueChange = props.onValueChange;
19368
- var restProps = __rest(props, ["decimalSeparator", "allowedDecimalSeparators", "thousandsGroupStyle", "suffix", "allowNegative", "allowLeadingZeros", "onKeyDown", "onBlur", "thousandSeparator", "decimalScale", "fixedDecimalScale", "prefix", "defaultValue", "value", "valueIsNumericString", "onValueChange"]);
19369
- // validate props
19370
- validateProps(props);
19371
- var _format = function (numStr) { return format(numStr, props); };
19372
- var _removeFormatting = function (inputValue, changeMeta) { return removeFormatting(inputValue, changeMeta, props); };
19373
- var _valueIsNumericString = valueIsNumericString;
19374
- if (!isNil(value)) {
19375
- _valueIsNumericString = valueIsNumericString !== null && valueIsNumericString !== void 0 ? valueIsNumericString : typeof value === 'number';
19376
- }
19377
- else if (!isNil(defaultValue)) {
19378
- _valueIsNumericString = valueIsNumericString !== null && valueIsNumericString !== void 0 ? valueIsNumericString : typeof defaultValue === 'number';
19379
- }
19380
- var roundIncomingValueToPrecision = function (value) {
19381
- if (isNil(value) || isNanValue(value))
19382
- { return value; }
19383
- if (typeof value === 'number') {
19384
- value = toNumericString(value);
19385
- }
19386
- /**
19387
- * only round numeric or float string values coming through props,
19388
- * we don't need to do it for onChange events, as we want to prevent typing there
19389
- */
19390
- if (_valueIsNumericString && typeof decimalScale === 'number') {
19391
- return roundToPrecision(value, decimalScale, Boolean(fixedDecimalScale));
19392
- }
19393
- return value;
19394
- };
19395
- var ref = useInternalValues(roundIncomingValueToPrecision(value), roundIncomingValueToPrecision(defaultValue), Boolean(_valueIsNumericString), _format, _removeFormatting, onValueChange);
19396
- var ref_0 = ref[0];
19397
- var numAsString = ref_0.numAsString;
19398
- var formattedValue = ref_0.formattedValue;
19399
- var _onValueChange = ref[1];
19400
- var _onKeyDown = function (e) {
19401
- var el = e.target;
19402
- var key = e.key;
19403
- var selectionStart = el.selectionStart;
19404
- var selectionEnd = el.selectionEnd;
19405
- var value = el.value; if ( value === void 0 ) value = '';
19406
- // if multiple characters are selected and user hits backspace, no need to handle anything manually
19407
- if (selectionStart !== selectionEnd) {
19408
- onKeyDown(e);
19409
- return;
19410
- }
19411
- // if user hits backspace, while the cursor is before prefix, and the input has negation, remove the negation
19412
- if (key === 'Backspace' && value[0] === '-' && selectionStart === prefix.length + 1) {
19413
- // bring the cursor to after negation
19414
- setCaretPosition(el, 1);
19415
- }
19416
- // don't allow user to delete decimal separator when decimalScale and fixedDecimalScale is set
19417
- var ref = getSeparators(props);
19418
- var decimalSeparator = ref.decimalSeparator;
19419
- var allowedDecimalSeparators = ref.allowedDecimalSeparators;
19420
- if (key === 'Backspace' &&
19421
- value[selectionStart - 1] === decimalSeparator &&
19422
- decimalScale &&
19423
- fixedDecimalScale) {
19424
- setCaretPosition(el, selectionStart - 1);
19425
- e.preventDefault();
19426
- }
19427
- // if user presses the allowed decimal separator before the separator, move the cursor after the separator
19428
- if ((allowedDecimalSeparators === null || allowedDecimalSeparators === void 0 ? void 0 : allowedDecimalSeparators.includes(key)) && value[selectionStart] === decimalSeparator) {
19429
- setCaretPosition(el, selectionStart + 1);
19430
- }
19431
- var _thousandSeparator = thousandSeparator === true ? ',' : thousandSeparator;
19432
- // move cursor when delete or backspace is pressed before/after thousand separator
19433
- if (key === 'Backspace' && value[selectionStart - 1] === _thousandSeparator) {
19434
- setCaretPosition(el, selectionStart - 1);
19435
- }
19436
- if (key === 'Delete' && value[selectionStart] === _thousandSeparator) {
19437
- setCaretPosition(el, selectionStart + 1);
19438
- }
19439
- onKeyDown(e);
19440
- };
19441
- var _onBlur = function (e) {
19442
- var _value = numAsString;
19443
- // if there no no numeric value, clear the input
19444
- if (!_value.match(/\d/g)) {
19445
- _value = '';
19446
- }
19447
- // clear leading 0s
19448
- if (!allowLeadingZeros) {
19449
- _value = fixLeadingZero(_value);
19450
- }
19451
- // apply fixedDecimalScale on blur event
19452
- if (fixedDecimalScale && decimalScale) {
19453
- _value = roundToPrecision(_value, decimalScale, fixedDecimalScale);
19454
- }
19455
- if (_value !== numAsString) {
19456
- var formattedValue = format(_value, props);
19457
- _onValueChange({
19458
- formattedValue: formattedValue,
19459
- value: _value,
19460
- floatValue: parseFloat(_value),
19461
- }, {
19462
- event: e,
19463
- source: SourceType.event,
19464
- });
19465
- }
19466
- onBlur(e);
19467
- };
19468
- var isValidInputCharacter = function (inputChar) {
19469
- if (inputChar === decimalSeparator)
19470
- { return true; }
19471
- return charIsNumber(inputChar);
19472
- };
19473
- 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 });
19474
- }
19475
- function NumericFormat(props) {
19476
- var numericFormatProps = useNumericFormat(props);
19477
- return React.createElement(NumberFormatBase, Object.assign({}, numericFormatProps));
19478
- }
19479
-
19480
19077
  const TextWidgetBase = ({
19481
19078
  id,
19482
19079
  onChange,
@@ -20287,5 +19884,5 @@ const DynamicFormHooks = {
20287
19884
  useReadOnly
20288
19885
  };
20289
19886
 
20290
- export { Actions$1 as Actions, Alert, AvatarBox, AvatarTitle, BusinessObject, BusinessObjectCard, EmptyCardSection as BusinessObjectCardEmptySection, CardSection as BusinessObjectCardSection, CardSectionTitle as BusinessObjectCardSectionTitle, BusinessObjectPanel, Header$1 as BusinessObjectPanelHeader, Section as BusinessObjectPanelSection, SectionTitle as BusinessObjectPanelSectionTitle, BusinessObjectPicker$1 as BusinessObjectPicker, BusinessObjectStatus, BusinessObjectStatusButton, BusinessObjectTable, Button, Chip, ContentBox, CoreProvider, CurriculumChart, DataTable, DatePickerBase as DatePicker, DisplayInFrame, DocViewer, Drawer, DynamicForm$1 as DynamicForm, BusinessObjectPickerField$1 as DynamicFormBusinessObjectPickerField, DynamicFormHooks, EditableText, FilterPanel, FilterChips$1 as FilterPanelFilterChips, mapFilters as FilterPanelMapFilters, FullPageViewer, Icon$1 as Icon, Image, IsometricImage, List, ListItem, ListItemGroup, MenuButton, ModalDialog, Notification, OutcomeSpace, PanelDrawer, ProgressChart, RichDataTable, RubricDistributionChart, RubricLegend, RubricScoreSlider, ScrollToTopButton, ScrollingContainer, SkeletonContent, StatBoxes, StatusMessage, SvgImage, SwipeableTabPanel, Content as SwipeableTabPanelContent, Timeline, TitleAndActionHeader, TitleAndDescription, UserAvatar, WizardPanel, businessObjectColor, businessObjectConfiguration, businessObjectIcon, createComponentEvent, createEvent, createComponentStore as createStore, dataSourceManager, filterSortData, getBaseUrl, getConfiguration, getDataSourceUrl, http, outcomeSpaceColor, outcomeSpaceTypeFromSource, registerDataSource, registerDataSources, setDataSourceConfiguration, template, useComponentWillMount, useDataSourceInfiniteQuery, useDataSourceMutation, useDataSourceQuery, useDataSourceUrl, useDebounceCallback, useNotify, useRefDimensions, withStatusButtonDataSource };
19887
+ export { Actions$1 as Actions, Alert, AvatarBox, AvatarTitle, BusinessObject, BusinessObjectCard, EmptyCardSection as BusinessObjectCardEmptySection, CardSection as BusinessObjectCardSection, CardSectionTitle as BusinessObjectCardSectionTitle, BusinessObjectPanel, Header$1 as BusinessObjectPanelHeader, Section as BusinessObjectPanelSection, SectionTitle as BusinessObjectPanelSectionTitle, BusinessObjectPicker$1 as BusinessObjectPicker, BusinessObjectStatus, BusinessObjectStatusButton, BusinessObjectTable, Button, Chip, ContentBox, CoreProvider, CurriculumChart, DataTable, DatePickerBase as DatePicker, DisplayInFrame, DocViewer, Drawer, DynamicForm$1 as DynamicForm, BusinessObjectPickerField$1 as DynamicFormBusinessObjectPickerField, DynamicFormHooks, EditableText, FilterPanel, FilterChips$1 as FilterPanelFilterChips, mapFilters as FilterPanelMapFilters, FullPageViewer, Icon$1 as Icon, Image, IsometricImage, List, ListItem, ListItemGroup, MenuButton, ModalDialog, Notification, OutcomeSpace, PanelDrawer, ProgressChart, RichDataTable, RubricDistributionChart, RubricLegend, RubricScoreSlider, ScrollToTopButton, ScrollingContainer, SkeletonContent, StatBoxes, StatusMessage, SvgImage, SwipeableTabPanel, Content as SwipeableTabPanelContent, TextBuilder, Timeline, TitleAndActionHeader, TitleAndDescription, UserAvatar, WizardPanel, businessObjectColor, businessObjectConfiguration, businessObjectIcon, createComponentEvent, createEvent, createComponentStore as createStore, dataSourceManager, filterSortData, getBaseUrl, getConfiguration, getDataSourceUrl, http, outcomeSpaceColor, outcomeSpaceTypeFromSource, registerDataSource, registerDataSources, setDataSourceConfiguration, template, useComponentWillMount, useDataSourceInfiniteQuery, useDataSourceMutation, useDataSourceQuery, useDataSourceUrl, useDebounceCallback, useNotify, useRefDimensions, withStatusButtonDataSource };
20291
19888
  //# sourceMappingURL=index.modern.js.map