aefis-core-ui 2.3.0-rc2 → 2.3.0-rc21

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.
@@ -10,6 +10,7 @@ import { red, orange, green, blue, grey, yellow, indigo, purple, cyan, teal, lim
10
10
  import makeStyles$1 from '@mui/styles/makeStyles';
11
11
  import withStyles from '@mui/styles/withStyles';
12
12
  import { useTheme, alpha, createTheme as createTheme$1, ThemeProvider, styled as styled$1, StyledEngineProvider } from '@mui/material/styles';
13
+ import { useFormControl } from '@mui/material/FormControl';
13
14
  import mustache from 'mustache';
14
15
  import { Box as Box$2 } from '@mui/system';
15
16
  import { Skeleton as Skeleton$4, TextField as TextField$1, Box as Box$3 } from '@mui/material/';
@@ -66,16 +67,21 @@ import Nouislider from 'nouislider-react';
66
67
  import 'lodash/camelCase';
67
68
  import debounce from 'lodash/debounce';
68
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';
69
76
  import { MuiForm5 } from '@rjsf/material-ui';
70
77
  import isEmpty from 'lodash/isEmpty';
71
78
  import compose from 'lodash/fp/compose';
72
79
  import Chip$2 from '@mui/material/Chip';
73
80
  import TextField$2 from '@mui/material/TextField';
74
- import { useFormControl } from '@mui/material/FormControl';
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() {
@@ -1295,20 +1303,13 @@ AvatarBox.propTypes = {
1295
1303
  hasShadow: PropTypes.bool
1296
1304
  };
1297
1305
 
1298
- // Copyright (c) 2022 HelioCampus Inc., all rights reserved.
1299
1306
  const useStyles$G = makeStyles$1(theme => ({
1300
1307
  formattedContainer: {
1301
- display: "flex",
1302
- alignItems: "center",
1303
- padding: theme.spacing(2),
1304
- boxSizing: "border-box",
1305
- width: "100%"
1308
+ display: "flex"
1306
1309
  },
1307
1310
  container: {
1308
1311
  display: "flex",
1309
- alignItems: "center",
1310
- boxSizing: "border-box",
1311
- width: "100%"
1312
+ boxSizing: "border-box"
1312
1313
  },
1313
1314
  avatar: {
1314
1315
  flex: "0 0 auto",
@@ -1316,10 +1317,7 @@ const useStyles$G = makeStyles$1(theme => ({
1316
1317
  },
1317
1318
  title: {
1318
1319
  color: "rgb(0, 0, 0)",
1319
- fontWeight: 500,
1320
- font: "inherit",
1321
- lineHeight: 1.43,
1322
- letterSpacing: "0.01071em"
1320
+ fontWeight: 500
1323
1321
  },
1324
1322
  subtitle: {
1325
1323
  letterSpacing: "0.01em",
@@ -1353,176 +1351,170 @@ const icon = {
1353
1351
 
1354
1352
  /** Component to display a title, subtitle, and caption along with an icon avatar. */
1355
1353
 
1356
- const AvatarTitle = /*#__PURE__*/React.memo(function AvatarTitle(props) {
1354
+ const AvatarTitle = /*#__PURE__*/React.memo(function AvatarTitle({
1355
+ type = "default",
1356
+ avatar,
1357
+ avatarVariant = "round",
1358
+ title,
1359
+ titleComponent = "div",
1360
+ subtitle,
1361
+ caption,
1362
+ avatarColor,
1363
+ formatContent = true,
1364
+ size = "medium",
1365
+ titleCase = "default",
1366
+ subtitleCase = "default",
1367
+ contentAlignment = "center",
1368
+ avatarShadow = false,
1369
+ emphasizeSubtitle = false
1370
+ }) {
1357
1371
  const classes = useStyles$G();
1358
1372
  const avatarStyle = {
1359
1373
  info: {
1360
1374
  backgroundColor: info.default,
1361
- boxShadow: props.avatarShadow ? "rgb(58 53 65 / 42%) 0px 4px 8px -4px" : "none",
1362
- borderRadius: props.avatarVariant === "square" ? "6px" : "50%"
1375
+ boxShadow: avatarShadow ? "rgb(58 53 65 / 42%) 0px 4px 8px -4px" : "none",
1376
+ borderRadius: avatarVariant === "square" ? "6px" : "50%"
1363
1377
  },
1364
1378
  success: {
1365
1379
  backgroundColor: success.default,
1366
- boxShadow: props.avatarShadow ? "rgb(58 53 65 / 42%) 0px 4px 8px -4px" : "none",
1367
- borderRadius: props.avatarVariant === "square" ? "6px" : "50%"
1380
+ boxShadow: avatarShadow ? "rgb(58 53 65 / 42%) 0px 4px 8px -4px" : "none",
1381
+ borderRadius: avatarVariant === "square" ? "6px" : "50%"
1368
1382
  },
1369
1383
  error: {
1370
1384
  backgroundColor: danger.default,
1371
- boxShadow: props.avatarShadow ? "rgb(58 53 65 / 42%) 0px 4px 8px -4px" : "none",
1372
- borderRadius: props.avatarVariant === "square" ? "6px" : "50%"
1385
+ boxShadow: avatarShadow ? "rgb(58 53 65 / 42%) 0px 4px 8px -4px" : "none",
1386
+ borderRadius: avatarVariant === "square" ? "6px" : "50%"
1373
1387
  },
1374
1388
  warning: {
1375
1389
  backgroundColor: warning.default,
1376
- boxShadow: props.avatarShadow ? "rgb(58 53 65 / 42%) 0px 4px 8px -4px" : "none",
1377
- borderRadius: props.avatarVariant === "square" ? "6px" : "50%"
1390
+ boxShadow: avatarShadow ? "rgb(58 53 65 / 42%) 0px 4px 8px -4px" : "none",
1391
+ borderRadius: avatarVariant === "square" ? "6px" : "50%"
1378
1392
  },
1379
1393
  custom: {
1380
- backgroundColor: props.avatarColor,
1381
- boxShadow: props.avatarShadow ? "rgb(58 53 65 / 42%) 0px 4px 8px -4px" : "none",
1382
- borderRadius: props.avatarVariant === "square" ? "6px" : "50%"
1394
+ backgroundColor: avatarColor,
1395
+ boxShadow: avatarShadow ? "rgb(58 53 65 / 42%) 0px 4px 8px -4px" : "none",
1396
+ borderRadius: avatarVariant === "square" ? "6px" : "50%"
1383
1397
  }
1384
1398
  };
1399
+ const defaultTitleStyle = {
1400
+ color: emphasizeSubtitle ? "#757575" : "#000000",
1401
+ textTransform: titleCase === "default" ? "none" : titleCase === "upper" ? "uppercase" : "lowercase"
1402
+ };
1403
+ const defaultSubtitleStyle = {
1404
+ fontWeight: emphasizeSubtitle ? "bolder" : "normal",
1405
+ color: emphasizeSubtitle ? "#000000" : "rgba(0, 0, 0, 0.6)",
1406
+ textTransform: subtitleCase === "default" ? "none" : subtitleCase === "upper" ? "uppercase" : "lowercase"
1407
+ };
1408
+ const defaultCaptionStyle = {
1409
+ textTransform: subtitleCase === "default" ? "none" : subtitleCase === "upper" ? "uppercase" : "lowercase"
1410
+ };
1385
1411
  const titleStyle = {
1386
- xsmall: {
1387
- fontSize: "0.875rem"
1388
- },
1389
- small: {
1390
- fontSize: "1rem"
1391
- },
1392
- medium: {
1412
+ xsmall: _extends({
1413
+ fontSize: emphasizeSubtitle ? "0.675rem" : "0.7775rem",
1414
+ lineHeight: 0.9,
1415
+ letterSpacing: "0.5px"
1416
+ }, defaultTitleStyle),
1417
+ small: _extends({
1418
+ fontSize: "0.975rem"
1419
+ }, defaultTitleStyle),
1420
+ medium: _extends({
1393
1421
  fontSize: "1.1rem"
1394
- },
1395
- large: {
1422
+ }, defaultTitleStyle),
1423
+ large: _extends({
1396
1424
  fontSize: "1.2rem"
1397
- }
1425
+ }, defaultTitleStyle)
1398
1426
  };
1399
1427
  const subtitleStyle = {
1400
- xsmall: {
1401
- fontSize: "0.775rem",
1402
- textTransform: props.subtitleCase === "default" ? "none" : props.subtitleCase === "upper" ? "uppercase" : "lowercase"
1403
- },
1404
- small: {
1405
- fontSize: "0.775rem",
1406
- fontWeight: "bolder",
1407
- textTransform: props.subtitleCase === "default" ? "none" : props.subtitleCase === "upper" ? "uppercase" : "lowercase"
1408
- },
1409
- medium: {
1410
- fontSize: "0.875rem",
1411
- textTransform: props.subtitleCase === "default" ? "none" : props.subtitleCase === "upper" ? "uppercase" : "lowercase"
1412
- },
1413
- large: {
1414
- fontSize: "0.875rem",
1415
- textTransform: props.subtitleCase === "default" ? "none" : props.subtitleCase === "upper" ? "uppercase" : "lowercase"
1416
- }
1428
+ xsmall: _extends({
1429
+ fontSize: emphasizeSubtitle ? "0.875rem" : "0.775rem",
1430
+ lineHeight: 0.975,
1431
+ marginTop: "2px",
1432
+ letterSpacing: "0.15px"
1433
+ }, defaultSubtitleStyle),
1434
+ small: _extends({
1435
+ fontSize: "0.775rem"
1436
+ }, defaultSubtitleStyle),
1437
+ medium: _extends({
1438
+ fontSize: "0.875rem"
1439
+ }, defaultSubtitleStyle),
1440
+ large: _extends({
1441
+ fontSize: "0.875rem"
1442
+ }, defaultSubtitleStyle)
1417
1443
  };
1418
1444
  const captionStyle = {
1419
- xsmall: {
1420
- fontSize: "0.675rem",
1421
- textTransform: props.subtitleCase === "default" ? "none" : props.subtitleCase === "upper" ? "uppercase" : "lowercase"
1422
- },
1423
- small: {
1445
+ xsmall: _extends({
1446
+ fontSize: "0.675rem"
1447
+ }, defaultCaptionStyle),
1448
+ small: _extends({
1424
1449
  fontSize: "0.675rem",
1425
- fontWeight: "bolder",
1426
- textTransform: props.subtitleCase === "default" ? "none" : props.subtitleCase === "upper" ? "uppercase" : "lowercase"
1427
- },
1428
- medium: {
1429
- fontSize: "0.775rem",
1430
- textTransform: props.subtitleCase === "default" ? "none" : props.subtitleCase === "upper" ? "uppercase" : "lowercase"
1431
- },
1432
- large: {
1433
- fontSize: "0.775rem",
1434
- textTransform: props.subtitleCase === "default" ? "none" : props.subtitleCase === "upper" ? "uppercase" : "lowercase"
1435
- }
1450
+ fontWeight: "bolder"
1451
+ }, defaultCaptionStyle),
1452
+ medium: _extends({
1453
+ fontSize: "0.775rem"
1454
+ }, defaultCaptionStyle),
1455
+ large: _extends({
1456
+ fontSize: "0.775rem"
1457
+ }, defaultCaptionStyle)
1436
1458
  };
1437
1459
  const avatarContainerStyle = {
1438
1460
  display: "flex",
1439
- alignItems: props.contentAlignment === "top" ? "flex-start" : "center",
1440
- width: "100%"
1461
+ alignItems: contentAlignment === "top" ? "flex-start" : "center"
1441
1462
  };
1442
- const avatarIcon = props.type === "custom" ? props.avatar : icon[props.type];
1443
- return /*#__PURE__*/jsx(Box$1, {
1444
- className: props.formatContent ? classes.formattedContainer : classes.container,
1445
- children: /*#__PURE__*/jsx(Box$1, {
1463
+ const avatarIcon = type === "custom" ? avatar : icon[type];
1464
+ return /*#__PURE__*/jsxs(Box$1, {
1465
+ className: formatContent ? classes.formattedContainer : classes.container,
1466
+ children: [/*#__PURE__*/jsxs(Box$1, {
1467
+ sx: avatarContainerStyle,
1468
+ children: [size === "xsmall" && /*#__PURE__*/jsx(XSmallAvatar, {
1469
+ className: classes.avatar,
1470
+ style: avatarStyle[type],
1471
+ variant: avatarVariant,
1472
+ children: avatarIcon
1473
+ }), size === "small" && /*#__PURE__*/jsx(SmallAvatar, {
1474
+ className: classes.avatar,
1475
+ style: avatarStyle[type],
1476
+ variant: avatarVariant,
1477
+ children: avatarIcon
1478
+ }), size === "medium" && /*#__PURE__*/jsx(Avatar$1, {
1479
+ className: classes.avatar,
1480
+ style: avatarStyle[type],
1481
+ variant: avatarVariant,
1482
+ children: avatarIcon
1483
+ }), size === "large" && /*#__PURE__*/jsx(LargeAvatar, {
1484
+ variant: avatarVariant,
1485
+ className: classes.avatar,
1486
+ style: avatarStyle[type],
1487
+ children: avatarIcon
1488
+ })]
1489
+ }), /*#__PURE__*/jsxs(Box$1, {
1446
1490
  sx: {
1447
- boxSizing: "border-box",
1448
- width: "100%"
1491
+ display: "flex",
1492
+ flexDirection: "column"
1449
1493
  },
1450
- children: /*#__PURE__*/jsxs(Box$1, {
1451
- sx: avatarContainerStyle,
1452
- children: [/*#__PURE__*/jsxs(Box$1, {
1453
- children: [props.size === "xsmall" && /*#__PURE__*/jsx(XSmallAvatar, {
1454
- className: classes.avatar,
1455
- style: avatarStyle[props.type],
1456
- variant: props.avatarVariant,
1457
- children: avatarIcon
1458
- }), props.size === "small" && /*#__PURE__*/jsx(SmallAvatar, {
1459
- className: classes.avatar,
1460
- style: avatarStyle[props.type],
1461
- variant: props.avatarVariant,
1462
- children: avatarIcon
1463
- }), props.size === "medium" && /*#__PURE__*/jsx(Avatar$1, {
1464
- className: classes.avatar,
1465
- style: avatarStyle[props.type],
1466
- variant: props.avatarVariant,
1467
- children: avatarIcon
1468
- }), props.size === "large" && /*#__PURE__*/jsx(LargeAvatar, {
1469
- variant: props.avatarVariant,
1470
- className: classes.avatar,
1471
- style: avatarStyle[props.type],
1472
- children: avatarIcon
1473
- })]
1474
- }), /*#__PURE__*/jsx(Box$1, {
1475
- sx: {
1476
- display: "flex",
1477
- alignItems: "center"
1478
- },
1479
- children: /*#__PURE__*/jsxs(Box$1, {
1480
- sx: {
1481
- display: "block"
1482
- },
1483
- children: [/*#__PURE__*/jsx(Box$1, {
1484
- children: typeof props.title === "string" ? /*#__PURE__*/jsx(Typography, {
1485
- variant: "h6",
1486
- component: props.titleComponent,
1487
- style: titleStyle[props.size],
1488
- className: classes.title,
1489
- children: props.title
1490
- }) : props.title
1491
- }), props.subtitle && /*#__PURE__*/jsx(Box$1, {
1492
- children: typeof props.subtitle === "string" ? /*#__PURE__*/jsx(Typography, {
1493
- variant: "body1",
1494
- component: "div",
1495
- style: subtitleStyle[props.size],
1496
- color: "textSecondary",
1497
- className: classes.subtitle,
1498
- children: props.subtitle
1499
- }) : props.subtitle
1500
- }), props.caption && /*#__PURE__*/jsx(Box$1, {
1501
- children: typeof props.subtitle === "string" ? /*#__PURE__*/jsx(Typography, {
1502
- variant: "body1",
1503
- component: "div",
1504
- style: captionStyle[props.size],
1505
- color: "textSecondary",
1506
- className: classes.subtitle,
1507
- children: props.caption
1508
- }) : props.caption
1509
- })]
1510
- })
1511
- })]
1512
- })
1513
- })
1494
+ children: [typeof title === "string" ? /*#__PURE__*/jsx(Typography, {
1495
+ variant: "h6",
1496
+ component: titleComponent,
1497
+ style: titleStyle[size],
1498
+ className: classes.title,
1499
+ children: title
1500
+ }) : title, subtitle && typeof subtitle === "string" ? /*#__PURE__*/jsx(Typography, {
1501
+ variant: "body1",
1502
+ component: "div",
1503
+ style: subtitleStyle[size],
1504
+ color: "textSecondary",
1505
+ className: classes.subtitle,
1506
+ children: subtitle
1507
+ }) : subtitle, caption && typeof subtitle === "string" ? /*#__PURE__*/jsx(Typography, {
1508
+ variant: "body1",
1509
+ component: "div",
1510
+ style: captionStyle[size],
1511
+ color: "textSecondary",
1512
+ className: classes.subtitle,
1513
+ children: caption
1514
+ }) : caption]
1515
+ })]
1514
1516
  });
1515
1517
  });
1516
- AvatarTitle.defaultProps = {
1517
- formatContent: true,
1518
- size: "medium",
1519
- type: "default",
1520
- titleComponent: "div",
1521
- subtitleCase: "default",
1522
- contentAlignment: "center",
1523
- avatarVariant: "round",
1524
- avatarShadow: false
1525
- };
1526
1518
  AvatarTitle.propTypes = {
1527
1519
  /** The type of avatar title. This will determine how the avatar color and icon is set. If "custom" is given, you can provide your own icon and color. */
1528
1520
  type: PropTypes.oneOf(["info", "success", "warning", "error", "custom"]),
@@ -1545,11 +1537,15 @@ AvatarTitle.propTypes = {
1545
1537
  /** The size of the avatar title */
1546
1538
  size: PropTypes.oneOf(["xsmall", "small", "medium", "large"]),
1547
1539
  /** The case used to display the subtitle and caption. */
1540
+ titleCase: PropTypes.oneOf(["default", "lower", "upper"]),
1541
+ /** The case used to display the subtitle and caption. */
1548
1542
  subtitleCase: PropTypes.oneOf(["default", "lower", "upper"]),
1549
1543
  /** How to align the content. */
1550
1544
  contentAlignment: PropTypes.oneOf(["center", "top"]),
1551
1545
  /** Display a slight shadow around the avatar? */
1552
- avatarShadow: PropTypes.bool
1546
+ avatarShadow: PropTypes.bool,
1547
+ /** Emphasize value */
1548
+ emphasizeSubtitle: PropTypes.bool
1553
1549
  };
1554
1550
 
1555
1551
  const IconButton = /*#__PURE__*/forwardRef(function IconButton(props, ref) {
@@ -1685,12 +1681,12 @@ const LegacyButtonTheme = createTheme(theme, {
1685
1681
  }
1686
1682
  });
1687
1683
 
1688
- const _excluded$k = ["name"];
1684
+ const _excluded$m = ["name"];
1689
1685
  const Button = /*#__PURE__*/forwardRef(function Button(_ref, ref) {
1690
1686
  let {
1691
1687
  name
1692
1688
  } = _ref,
1693
- props = _objectWithoutPropertiesLoose(_ref, _excluded$k);
1689
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$m);
1694
1690
  const isColorDefault = props.color === undefined || props.color === "default";
1695
1691
  const colorThemeName = isColorDefault ? "grey" : props.color;
1696
1692
  const theme = useTheme$1();
@@ -1724,7 +1720,7 @@ Button.defaultProps = {
1724
1720
  variant: "text",
1725
1721
  disableElevation: true
1726
1722
  };
1727
- Button.propTypes = {
1723
+ Button.propTypes = _extends({
1728
1724
  /** A descriptive name of the button. Used by screen readers to explain the intent of the button. If not provided, the button content is used. */
1729
1725
  name: PropTypes.string,
1730
1726
  /** Remove the elevation from the button. */
@@ -1737,7 +1733,7 @@ Button.propTypes = {
1737
1733
  disabled: PropTypes.bool,
1738
1734
  /** The content of the button */
1739
1735
  children: PropTypes.any
1740
- };
1736
+ }, Button$1.propTypes);
1741
1737
 
1742
1738
  const AnimatedExpandMoreIcon = ({
1743
1739
  isOpen,
@@ -1783,7 +1779,7 @@ AnimatedExpandMoreIcon.propTypes = {
1783
1779
  sx: PropTypes.any
1784
1780
  };
1785
1781
 
1786
- const _excluded$j = ["name", "icon", "menuConfiguration", "color", "displayType", "variant", "onClick", "link"];
1782
+ const _excluded$l = ["name", "icon", "menuConfiguration", "color", "displayType", "variant", "onClick", "link"];
1787
1783
  const AefisButton = withStyles$1({
1788
1784
  root: {
1789
1785
  "&:focus": {
@@ -1805,7 +1801,7 @@ const MenuButton = /*#__PURE__*/forwardRef(function MenuButton(_ref, ref) {
1805
1801
  onClick,
1806
1802
  link
1807
1803
  } = _ref,
1808
- props = _objectWithoutPropertiesLoose(_ref, _excluded$j);
1804
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$l);
1809
1805
  const [anchorEl, setAnchorEl] = useState(null);
1810
1806
  const handleClick = (event, link, buttonId) => {
1811
1807
  setAnchorEl(event.currentTarget);
@@ -1828,15 +1824,18 @@ const MenuButton = /*#__PURE__*/forwardRef(function MenuButton(_ref, ref) {
1828
1824
  "aria-haspopup": true,
1829
1825
  "aria-expanded": Boolean(anchorEl)
1830
1826
  };
1831
- const buttonProps = {
1827
+ const buttonProps = _extends({
1832
1828
  id: buttonId,
1833
- color: displayType === "default" ? color : undefined,
1834
- name: name,
1835
- startIcon: icon && displayType === "default" ? /*#__PURE__*/jsx(Icon$1, {
1829
+ name: name
1830
+ }, displayType === "default" && {
1831
+ color
1832
+ }, icon && displayType === "default" && {
1833
+ startIcon: /*#__PURE__*/jsx(Icon$1, {
1836
1834
  name: props.icon
1837
- }) : undefined,
1838
- variant: displayType === "default" ? variant : undefined
1839
- };
1835
+ })
1836
+ }, displayType === "default" && {
1837
+ variant
1838
+ });
1840
1839
  return /*#__PURE__*/jsxs(React.Fragment, {
1841
1840
  children: [displayType === "icon" ? /*#__PURE__*/jsx(IconButton, _extends({}, buttonProps, a11yprops, {
1842
1841
  onClick: e => handleClick(e, link, buttonId),
@@ -1905,7 +1904,12 @@ MenuButton.propTypes = {
1905
1904
  /** Button variant */
1906
1905
  variant: PropTypes.oneOf(["contained", "outlined", "text"]),
1907
1906
  /** The type of the button */
1908
- menuConfiguration: PropTypes.array,
1907
+ menuConfiguration: PropTypes.arrayOf(PropTypes.shape({
1908
+ name: PropTypes.string,
1909
+ icon: PropTypes.any,
1910
+ divider: PropTypes.any,
1911
+ onClick: PropTypes.func
1912
+ })),
1909
1913
  /** The function to execute when the button is clicked. */
1910
1914
  onClick: PropTypes.func
1911
1915
  };
@@ -1913,7 +1917,7 @@ MenuButton.propTypes = {
1913
1917
  const useTag = color => {
1914
1918
  const useStyles = makeStyles(theme => ({
1915
1919
  tag: {
1916
- borderLeft: `4px solid ${color ? color : theme.palette.primary.main}`
1920
+ borderLeft: `16px solid ${color ? color : theme.palette.primary.main}`
1917
1921
  }
1918
1922
  }));
1919
1923
  return useStyles();
@@ -1950,30 +1954,23 @@ const useStyles$F = makeStyles(theme => ({
1950
1954
  }));
1951
1955
  const titleProps = {
1952
1956
  color: "textPrimary",
1953
- variant: "h3",
1957
+ variant: "h6",
1954
1958
  style: {
1955
- fontSize: "1.2rem",
1959
+ fontSize: "1.1rem",
1956
1960
  fontWeight: 500,
1957
- lineHeight: 1.3,
1958
- letterSpacing: 0.5,
1959
- whiteSpace: "nowrap",
1960
- overflow: "hidden",
1961
- textOverflow: "ellipsis"
1961
+ lineHeight: 1.43,
1962
+ letterSpacing: "0.01071em"
1962
1963
  }
1963
1964
  };
1964
1965
  const subtitleProps = {
1965
1966
  color: "textSecondary",
1967
+ variant: "body1",
1966
1968
  style: {
1967
- fontSize: "0.875rem",
1968
- fontWeight: 400,
1969
- lineHeight: 1.4,
1970
- letterSpacing: 0,
1969
+ fontSize: "0.775rem",
1970
+ fontWeight: "bolder",
1971
1971
  display: "inline-flex",
1972
1972
  verticalAlign: "middle",
1973
- alignItems: "center",
1974
- whiteSpace: "nowrap",
1975
- overflow: "hidden",
1976
- textOverflow: "ellipsis"
1973
+ alignItems: "center"
1977
1974
  }
1978
1975
  };
1979
1976
  const getGradientBackgroundColorArray = arrayIndex => {
@@ -2001,6 +1998,20 @@ const ContentBox = props => {
2001
1998
  return props.children ? /*#__PURE__*/React.cloneElement(props.children) : "";
2002
1999
  };
2003
2000
  titleProps.component = props.titleComponent;
2001
+ if (props.wrapTitle) {
2002
+ titleProps["style"] = _extends({}, titleProps.style, {
2003
+ whiteSpace: "nowrap",
2004
+ overflow: "hidden",
2005
+ textOverflow: "ellipsis"
2006
+ });
2007
+ }
2008
+ if (props.wrapSubtitle) {
2009
+ titleProps["style"] = _extends({}, titleProps.style, {
2010
+ whiteSpace: "nowrap",
2011
+ overflow: "hidden",
2012
+ textOverflow: "ellipsis"
2013
+ });
2014
+ }
2004
2015
  const headerProps = {
2005
2016
  title: props.title,
2006
2017
  disableTypography: false,
@@ -2019,7 +2030,7 @@ const ContentBox = props => {
2019
2030
  }
2020
2031
  if (typeof props.subtitle !== "string" && props.subtitle !== undefined) {
2021
2032
  headerProps.title = /*#__PURE__*/jsx(Typography, {
2022
- variant: "h3",
2033
+ variant: "h6",
2023
2034
  component: props.titleComponent,
2024
2035
  style: titleProps.style,
2025
2036
  display: "block",
@@ -2030,13 +2041,13 @@ const ContentBox = props => {
2030
2041
  headerProps.subheader = props.subtitle;
2031
2042
  }
2032
2043
  if (props.titleBadge) {
2033
- headerProps.title = /*#__PURE__*/jsx("div", {
2044
+ headerProps.title = /*#__PURE__*/jsx(Box$1, {
2034
2045
  children: /*#__PURE__*/jsx(StyledBadge$1, {
2035
2046
  badgeContent: props.titleBadge,
2036
2047
  invisible: invisible,
2037
2048
  color: "secondary",
2038
2049
  children: /*#__PURE__*/jsx(Typography, {
2039
- variant: "h3",
2050
+ variant: "h6",
2040
2051
  component: props.titleComponent,
2041
2052
  style: titleProps.style,
2042
2053
  display: "block",
@@ -2057,12 +2068,13 @@ const ContentBox = props => {
2057
2068
  variant: "body1",
2058
2069
  component: "span",
2059
2070
  noWrap: true,
2060
- sx: {
2061
- color: "text.secondary"
2062
- },
2071
+ color: "textSecondary",
2063
2072
  style: {
2064
- fontSize: "0.875rem",
2065
- letterSpacing: 0
2073
+ fontSize: "0.775rem",
2074
+ fontWeight: "bolder",
2075
+ display: "inline-flex",
2076
+ verticalAlign: "middle",
2077
+ alignItems: "center"
2066
2078
  },
2067
2079
  children: props.subtitle
2068
2080
  });
@@ -2074,6 +2086,7 @@ const ContentBox = props => {
2074
2086
  const cardStyle = _extends({
2075
2087
  marginBottom: props.hasGutter ? 8 : 0,
2076
2088
  borderRadius: 16,
2089
+ transition: "border 100ms ease-out",
2077
2090
  boxShadow: props.displayType === "outlined" ? "none" : "rgb(58 53 65 / 10%) 0px 2px 10px 0px"
2078
2091
  }, props.cardStyle);
2079
2092
  if (props.displayType === "outlined") {
@@ -2088,10 +2101,14 @@ const ContentBox = props => {
2088
2101
  height: props.imageHeight,
2089
2102
  backgroundColor: props.imageBackgroundColor ? props.imageBackgroundColor : "transparent"
2090
2103
  } : {};
2104
+ const otherSx = !props.children && !props.description ? {
2105
+ display: "none",
2106
+ visibility: "hidden"
2107
+ } : undefined;
2091
2108
  return /*#__PURE__*/jsxs(Box$1, {
2092
2109
  sx: props.sx,
2093
2110
  style: props.containerStyle,
2094
- children: [props.header && /*#__PURE__*/jsx("div", {
2111
+ children: [props.header && /*#__PURE__*/jsx(Box$1, {
2095
2112
  className: classes.sectionHeader,
2096
2113
  children: /*#__PURE__*/jsx(Typography, {
2097
2114
  variant: "h6",
@@ -2101,7 +2118,7 @@ const ContentBox = props => {
2101
2118
  }), /*#__PURE__*/jsxs(Card, {
2102
2119
  style: cardStyle,
2103
2120
  className: tag.tag,
2104
- children: [useHeaderImage && /*#__PURE__*/jsx("div", {
2121
+ children: [useHeaderImage && /*#__PURE__*/jsx(Box$1, {
2105
2122
  style: imageDivStyle,
2106
2123
  className: classes.imageContainer,
2107
2124
  title: props.title,
@@ -2111,8 +2128,15 @@ const ContentBox = props => {
2111
2128
  component: "img",
2112
2129
  alt: "",
2113
2130
  image: props.image
2114
- }), props.title && /*#__PURE__*/jsx(CardHeader, _extends({}, headerProps)), props.formatContent && /*#__PURE__*/jsx(CardContent, {
2131
+ }), props.title && /*#__PURE__*/jsx(CardHeader, _extends({}, headerProps, {
2132
+ sx: {
2133
+ padding: props.dense ? 1 : 2
2134
+ }
2135
+ })), props.formatContent && /*#__PURE__*/jsx(CardContent, {
2115
2136
  className: !props.title ? classes.cardContentWithoutTitle : classes.cardContent,
2137
+ sx: _extends({
2138
+ padding: props.dense ? 1 : 2
2139
+ }, otherSx),
2116
2140
  children: /*#__PURE__*/jsxs(React.Fragment, {
2117
2141
  children: [props.description && /*#__PURE__*/jsx(Typography, {
2118
2142
  variant: "body2",
@@ -2136,6 +2160,9 @@ const ContentBox = props => {
2136
2160
  }), renderChildren()]
2137
2161
  }), props.actions && /*#__PURE__*/jsx(CardActions, {
2138
2162
  disableSpacing: true,
2163
+ sx: {
2164
+ paddingTop: props.dense ? 0 : 1
2165
+ },
2139
2166
  children: props.actions
2140
2167
  }), props.afterActionContent]
2141
2168
  })]
@@ -2147,7 +2174,10 @@ ContentBox.defaultProps = {
2147
2174
  imageHeight: 150,
2148
2175
  hasGutter: true,
2149
2176
  imageBackgroundColor: "transparent",
2150
- titleComponent: "div"
2177
+ titleComponent: "div",
2178
+ wrapTitle: false,
2179
+ wrapSubtitle: false,
2180
+ dense: false
2151
2181
  };
2152
2182
  ContentBox.propTypes = {
2153
2183
  /** Content of the content box */
@@ -2162,6 +2192,10 @@ ContentBox.propTypes = {
2162
2192
  subtitle: PropTypes.any,
2163
2193
  /** Main title of the content box. Can be a string or any component. */
2164
2194
  title: PropTypes.any,
2195
+ /** Wrap the title? */
2196
+ wrapTitle: PropTypes.bool,
2197
+ /** Wrap the subtitle? */
2198
+ wrapSubtitle: PropTypes.bool,
2165
2199
  /** Add a badge to the title of the content box. */
2166
2200
  titleBadge: PropTypes.number,
2167
2201
  /** The component to use to render the title. */
@@ -2195,7 +2229,9 @@ ContentBox.propTypes = {
2195
2229
  /** Additional styles for the content box container */
2196
2230
  containerStyle: PropTypes.any,
2197
2231
  /** Additional styles to apply */
2198
- sx: PropTypes.object
2232
+ sx: PropTypes.object,
2233
+ /** Compact display? */
2234
+ dense: PropTypes.bool
2199
2235
  };
2200
2236
 
2201
2237
  const defaultColorPalette = {
@@ -2249,10 +2285,10 @@ ClickWrapper.propTypes = {
2249
2285
  const Chip = ({
2250
2286
  id,
2251
2287
  colorPalette,
2252
- size,
2288
+ size: _size2 = "medium",
2253
2289
  icon,
2254
2290
  label,
2255
- displayType,
2291
+ displayType: _displayType = "default",
2256
2292
  deleteIcon,
2257
2293
  onDelete,
2258
2294
  canDelete,
@@ -2260,7 +2296,7 @@ const Chip = ({
2260
2296
  }) => {
2261
2297
  const keyValue = useUID();
2262
2298
  const colors = _extends({}, defaultColorPalette, colorPalette);
2263
- const _size = size === "medium" || size === "large" ? "medium" : size;
2299
+ const _size = _size2 === "medium" || _size2 === "large" ? "medium" : _size2;
2264
2300
  const styles = {
2265
2301
  outlined: {
2266
2302
  borderWidth: 2,
@@ -2280,14 +2316,14 @@ const Chip = ({
2280
2316
  }
2281
2317
  };
2282
2318
  let chipStyles = styles.chip;
2283
- if (displayType === "outlined") chipStyles = styles.outlined;
2284
- if (displayType === "withOutline") chipStyles = styles.withOutline;
2319
+ if (_displayType === "outlined") chipStyles = styles.outlined;
2320
+ if (_displayType === "withOutline") chipStyles = styles.withOutline;
2285
2321
  const chipProps = {
2286
2322
  key: id || keyValue,
2287
2323
  icon,
2288
2324
  label,
2289
2325
  sx: chipStyles,
2290
- variant: displayType === "withOutline" ? "default" : displayType,
2326
+ variant: _displayType === "withOutline" ? "default" : _displayType,
2291
2327
  size: _size,
2292
2328
  deleteIcon: deleteIcon || /*#__PURE__*/jsx(ClickWrapper, {
2293
2329
  label: label,
@@ -2304,12 +2340,21 @@ const Chip = ({
2304
2340
  })
2305
2341
  })
2306
2342
  };
2307
- const Chip = () => /*#__PURE__*/jsx(Chip$1, _extends({
2308
- role: role || "presentation",
2309
- "aria-label": label
2310
- }, chipProps, canDelete && {
2311
- onDelete
2312
- }));
2343
+
2344
+ // TODO: create FormChip (or similar) and use contextful version there. Pure
2345
+ // and Contextful component should be seperated
2346
+ const formControl = useFormControl();
2347
+ const _canDelete = canDelete && !(formControl != null && formControl.disabled);
2348
+ const Chip = () => {
2349
+ return /*#__PURE__*/jsx(Chip$1, _extends({
2350
+ role: role || "presentation",
2351
+ "aria-label": label
2352
+ }, chipProps, _canDelete && {
2353
+ onDelete
2354
+ }, {
2355
+ disabled: formControl == null ? void 0 : formControl.disabled
2356
+ }));
2357
+ };
2313
2358
 
2314
2359
  /**return tooltipText ? (
2315
2360
  <Tooltip title={tooltipText}>
@@ -2349,12 +2394,6 @@ Chip.propTypes = {
2349
2394
  /** ARIA Role attribute */
2350
2395
  role: PropTypes.string
2351
2396
  };
2352
- Chip.defaultProps = {
2353
- size: "medium",
2354
- variant: "default",
2355
- canRemove: false,
2356
- displayType: "default"
2357
- };
2358
2397
 
2359
2398
  const colorPalette$v = {
2360
2399
  light: grey[200],
@@ -3296,12 +3335,12 @@ const outcomeConfiguration = {
3296
3335
  // about solution: https://stackoverflow.com/questions/22820162/mustache-js-escaping
3297
3336
  mustache.escape = _ => _;
3298
3337
  function compile() {}
3299
- function render$2(template, data, defaultValue) {
3338
+ function render$1(template, data, defaultValue) {
3300
3339
  return template ? mustache.render(template, data) : defaultValue;
3301
3340
  }
3302
3341
  var template = {
3303
3342
  compile,
3304
- render: render$2
3343
+ render: render$1
3305
3344
  };
3306
3345
 
3307
3346
  // Copyright (c) 2020 AEFIS, all rights reserved.
@@ -3432,7 +3471,7 @@ CardSectionTitle$1.propTypes = {
3432
3471
  title: PropTypes.string
3433
3472
  };
3434
3473
 
3435
- const _excluded$i = ["title", "children", "height", "titleComponent"];
3474
+ const _excluded$k = ["title", "children", "height", "titleComponent"];
3436
3475
  const CardSection$1 = _ref => {
3437
3476
  let {
3438
3477
  title,
@@ -3440,7 +3479,7 @@ const CardSection$1 = _ref => {
3440
3479
  height,
3441
3480
  titleComponent
3442
3481
  } = _ref,
3443
- props = _objectWithoutPropertiesLoose(_ref, _excluded$i);
3482
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$k);
3444
3483
  return /*#__PURE__*/jsxs(Box$1, _extends({
3445
3484
  sx: {
3446
3485
  height: height || "inherit"
@@ -3540,7 +3579,7 @@ SvgImage.propTypes = {
3540
3579
  width: PropTypes.any
3541
3580
  };
3542
3581
 
3543
- const _excluded$h = ["source", "description", "width", "height", "decorative", "showSkeleton", "fallbackImage"],
3582
+ const _excluded$j = ["source", "description", "width", "height", "decorative", "showSkeleton", "fallbackImage"],
3544
3583
  _excluded2$1 = ["src", "extension"];
3545
3584
  const RenderImage = _ref => {
3546
3585
  let {
@@ -3552,7 +3591,7 @@ const RenderImage = _ref => {
3552
3591
  showSkeleton,
3553
3592
  fallbackImage
3554
3593
  } = _ref,
3555
- other = _objectWithoutPropertiesLoose(_ref, _excluded$h);
3594
+ other = _objectWithoutPropertiesLoose(_ref, _excluded$j);
3556
3595
  const altText = decorative ? "" : description;
3557
3596
  const role = decorative ? "presentation" : "img";
3558
3597
  const hidden = !!decorative;
@@ -3630,7 +3669,7 @@ Image.propTypes = {
3630
3669
  extension: PropTypes.string
3631
3670
  };
3632
3671
 
3633
- const _excluded$g = ["type"];
3672
+ const _excluded$i = ["type"];
3634
3673
  const imageProps = {
3635
3674
  award: Award,
3636
3675
  building: Building,
@@ -3656,7 +3695,7 @@ const IsometricImage = _ref => {
3656
3695
  let {
3657
3696
  type
3658
3697
  } = _ref,
3659
- other = _objectWithoutPropertiesLoose(_ref, _excluded$g);
3698
+ other = _objectWithoutPropertiesLoose(_ref, _excluded$i);
3660
3699
  const image = getIsometricImage(type);
3661
3700
  return /*#__PURE__*/jsx(Image, _extends({
3662
3701
  src: image
@@ -4339,6 +4378,9 @@ const RenderCard = props => {
4339
4378
  configuration: props.actionsConfiguration,
4340
4379
  data: props.data
4341
4380
  }) : undefined,
4381
+ cardStyle: props.cardStyle || undefined,
4382
+ containerStyle: props.containerStyle || undefined,
4383
+ sx: props.sx || undefined,
4342
4384
  children: /*#__PURE__*/jsxs(Fragment, {
4343
4385
  children: [props.description && /*#__PURE__*/jsx(CardSection, {
4344
4386
  sx: descriptionContainerStyle,
@@ -4372,7 +4414,10 @@ RenderCard.propTypes = {
4372
4414
  avatarIconColor: PropTypes.string,
4373
4415
  gradientColorHeaderImageId: PropTypes.any,
4374
4416
  autoTruncateDescription: PropTypes.bool,
4375
- avatar: PropTypes.any
4417
+ avatar: PropTypes.any,
4418
+ cardStyle: PropTypes.any,
4419
+ containerStyle: PropTypes.any,
4420
+ sx: PropTypes.object
4376
4421
  };
4377
4422
  const BusinessObjectCard = props => {
4378
4423
  return props.displayType === "skeleton" ? /*#__PURE__*/jsx(RenderSkeleton, {
@@ -4417,16 +4462,22 @@ BusinessObjectCard.propTypes = {
4417
4462
  /** Override the avatar with provided avatar object. */
4418
4463
  avatar: PropTypes.any,
4419
4464
  /** Automatically truncate the description. For consistency, this should nearly always be set to "true" */
4420
- autoTruncateDescription: PropTypes.bool
4465
+ autoTruncateDescription: PropTypes.bool,
4466
+ /** Additional styles for the card */
4467
+ cardStyle: PropTypes.any,
4468
+ /** Additional styles for the content box container */
4469
+ containerStyle: PropTypes.any,
4470
+ /** Additional styles to apply */
4471
+ sx: PropTypes.object
4421
4472
  };
4422
4473
 
4423
- const _excluded$f = ["enableScrollTop", "containerProps"];
4474
+ const _excluded$h = ["enableScrollTop", "containerProps"];
4424
4475
  const SwipeableViews = _ref => {
4425
4476
  let {
4426
4477
  enableScrollTop = true,
4427
4478
  containerProps = {}
4428
4479
  } = _ref,
4429
- props = _objectWithoutPropertiesLoose(_ref, _excluded$f);
4480
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$h);
4430
4481
  const containerRef = containerProps.ref || useRef();
4431
4482
  useEffect(() => {
4432
4483
  if (enableScrollTop) {
@@ -4722,19 +4773,26 @@ SwipeableTabPanel.propTypes = {
4722
4773
  appBarComponent: PropTypes.string
4723
4774
  };
4724
4775
 
4725
- const List = props => {
4776
+ const List = ({
4777
+ children,
4778
+ containerStyle,
4779
+ transparentBackground: _transparentBackground = false,
4780
+ display: _display = "vertical",
4781
+ animate: _animate = true,
4782
+ sx
4783
+ }) => {
4726
4784
  const theme = useTheme$1();
4727
4785
  const rootStyle = _extends({
4728
- backgroundColor: props.transparentBackground ? "transparent" : theme.palette.background.paper,
4786
+ backgroundColor: _transparentBackground ? "transparent" : theme.palette.background.paper,
4729
4787
  width: "100%"
4730
- }, props.containerStyle);
4731
- const listStyle = {
4788
+ }, containerStyle);
4789
+ const listStyle = _extends({
4732
4790
  margin: 0,
4733
4791
  padding: 0,
4734
4792
  flexWrap: "wrap"
4735
- };
4793
+ }, sx);
4736
4794
  const listProps = {};
4737
- if (props.display === "horizontal") {
4795
+ if (_display === "horizontal") {
4738
4796
  listStyle["display"] = "flex";
4739
4797
  listStyle["flexDirection"] = "row";
4740
4798
  listProps["dense"] = true;
@@ -4742,25 +4800,20 @@ const List = props => {
4742
4800
  }
4743
4801
  return /*#__PURE__*/jsx(Box$1, {
4744
4802
  sx: rootStyle,
4745
- children: props.animate ? /*#__PURE__*/jsx(FadeIn, {
4803
+ children: _animate ? /*#__PURE__*/jsx(FadeIn, {
4746
4804
  in: true,
4747
4805
  children: /*#__PURE__*/jsx(List$2, _extends({
4748
4806
  sx: listStyle
4749
4807
  }, listProps, {
4750
- children: props.children
4808
+ children: children
4751
4809
  }))
4752
4810
  }) : /*#__PURE__*/jsx(List$2, _extends({
4753
4811
  sx: listStyle
4754
4812
  }, listProps, {
4755
- children: props.children
4813
+ children: children
4756
4814
  }))
4757
4815
  });
4758
4816
  };
4759
- List.defaultProps = {
4760
- transparentBackground: false,
4761
- display: "vertical",
4762
- animate: true
4763
- };
4764
4817
  List.propTypes = {
4765
4818
  /** Children of the list. Children should be the ListItem component. */
4766
4819
  children: PropTypes.any.isRequired,
@@ -4771,7 +4824,9 @@ List.propTypes = {
4771
4824
  /** List display type */
4772
4825
  display: PropTypes.oneOf(["horizontal", "vertical"]),
4773
4826
  /** Show the animation? */
4774
- animate: PropTypes.bool
4827
+ animate: PropTypes.bool,
4828
+ /** Style to apply */
4829
+ sx: PropTypes.any
4775
4830
  };
4776
4831
 
4777
4832
  const StyledMuiListItemButton = withStyles$1({
@@ -4779,38 +4834,53 @@ const StyledMuiListItemButton = withStyles$1({
4779
4834
  "&:hover": {
4780
4835
  backgroundColor: "rgba(0, 0, 0, 0.02) !important"
4781
4836
  }
4782
- },
4783
- selected: {
4784
- backgroundColor: "#f5fbfe !important"
4785
- }
4786
- })(ListItem$2);
4787
- const StyledMuiListItem = withStyles$1({
4788
- selected: {
4789
- backgroundColor: "#f5fbfe !important"
4790
4837
  }
4791
4838
  })(ListItem$2);
4839
+ const StyledMuiListItem = withStyles$1({})(ListItem$2);
4792
4840
 
4793
4841
  /** List Item component to be used with List component. Displays items in a list. */
4794
4842
 
4795
- const ListItem = props => {
4796
- const listItemStyle = {};
4843
+ const ListItem = ({
4844
+ displayType: _displayType = "default",
4845
+ avatar,
4846
+ icon,
4847
+ title,
4848
+ subtitle,
4849
+ hasBorder: _hasBorder = false,
4850
+ borderStyle: _borderStyle = "2px solid",
4851
+ canClick: _canClick = false,
4852
+ onClick,
4853
+ children,
4854
+ id,
4855
+ disabled: _disabled = false,
4856
+ dense: _dense = false,
4857
+ hasGutter: _hasGutter = true,
4858
+ selected: _selected = false,
4859
+ selectedType: _selectedType = "background",
4860
+ display: _display = "vertical",
4861
+ sx
4862
+ }) => {
4797
4863
  const keyValue = useUID();
4798
- if (!props.hasGutter) {
4864
+ const listItemStyle = {
4865
+ backgroundColor: _selected && _selectedType === "background" ? "#f5fbfe" : "#ffffff",
4866
+ border: _selected && _selectedType === "outlined" ? "2px solid #2295f2" : "none"
4867
+ };
4868
+ if (!_hasGutter) {
4799
4869
  listItemStyle.padding = 0;
4800
4870
  }
4801
- if (props.hasBorder) {
4802
- listItemStyle.borderBottom = props.borderStyle;
4871
+ if (_hasBorder) {
4872
+ listItemStyle.borderBottom = _borderStyle;
4803
4873
  listItemStyle.borderColor = grey[200];
4804
4874
  }
4805
4875
  const listItemArgs = {
4806
- key: props.id ? props.id : keyValue,
4876
+ key: id ? id : keyValue,
4807
4877
  style: listItemStyle,
4808
- disabled: props.disabled,
4809
- dense: props.dense,
4810
- selected: props.selected,
4878
+ disabled: _disabled,
4879
+ dense: _dense,
4880
+ selected: _selected,
4811
4881
  component: "li"
4812
4882
  };
4813
- if (props.display === "horizontal") {
4883
+ if (_display === "horizontal") {
4814
4884
  listItemArgs["sx"] = {
4815
4885
  marginRight: "2px",
4816
4886
  marginBottom: "2px",
@@ -4820,51 +4890,42 @@ const ListItem = props => {
4820
4890
  listItemArgs["disablePadding"] = true;
4821
4891
  listItemArgs["disableGutters"] = true;
4822
4892
  }
4823
- if (props.canClick) {
4893
+ if (_canClick) {
4824
4894
  listItemArgs.button = true;
4825
- listItemArgs.onClick = props.onClick;
4895
+ listItemArgs.onClick = onClick;
4826
4896
  }
4827
- return props.displayType === "default" && props.canClick && /*#__PURE__*/jsxs(StyledMuiListItemButton, _extends({}, listItemArgs, {
4828
- children: [props.title && props.title !== "" && props.avatar && /*#__PURE__*/jsx(ListItemAvatar, {
4829
- children: props.avatar
4830
- }), props.title && props.title !== "" && props.icon && /*#__PURE__*/jsx(ListItemIcon, {
4831
- children: props.icon
4832
- }), props.title && props.title !== "" && /*#__PURE__*/jsx(ListItemText, {
4833
- primary: props.title,
4834
- secondary: props.subtitle
4835
- }), !props.title && props.children && /*#__PURE__*/jsx(React.Fragment, {
4836
- children: props.children
4897
+ return _displayType === "default" && _canClick && /*#__PURE__*/jsxs(StyledMuiListItemButton, _extends({}, listItemArgs, {
4898
+ children: [title && title !== "" && avatar && /*#__PURE__*/jsx(ListItemAvatar, {
4899
+ children: avatar
4900
+ }), title && title !== "" && icon && /*#__PURE__*/jsx(ListItemIcon, {
4901
+ children: icon
4902
+ }), title && title !== "" && /*#__PURE__*/jsx(ListItemText, {
4903
+ primary: title,
4904
+ secondary: subtitle
4905
+ }), !title && children && /*#__PURE__*/jsx(React.Fragment, {
4906
+ children: children
4837
4907
  })]
4838
- })) || props.displayType === "default" && !props.canClick && /*#__PURE__*/jsxs(StyledMuiListItem, _extends({}, listItemArgs, {
4839
- children: [props.title && props.title !== "" && props.avatar && /*#__PURE__*/jsx(ListItemAvatar, {
4840
- children: props.avatar
4841
- }), props.title && props.title !== "" && props.icon && /*#__PURE__*/jsx(ListItemIcon, {
4842
- children: props.icon
4843
- }), props.title && props.title !== "" && /*#__PURE__*/jsx(ListItemText, {
4844
- primary: props.title,
4845
- secondary: props.subtitle
4846
- }), !props.title && props.children && /*#__PURE__*/jsx(React.Fragment, {
4847
- children: props.children
4908
+ })) || _displayType === "default" && !_canClick && /*#__PURE__*/jsxs(StyledMuiListItem, _extends({}, listItemArgs, {
4909
+ sx: sx,
4910
+ children: [title && title !== "" && avatar && /*#__PURE__*/jsx(ListItemAvatar, {
4911
+ children: avatar
4912
+ }), title && title !== "" && icon && /*#__PURE__*/jsx(ListItemIcon, {
4913
+ children: icon
4914
+ }), title && title !== "" && /*#__PURE__*/jsx(ListItemText, {
4915
+ primary: title,
4916
+ secondary: subtitle
4917
+ }), !title && children && /*#__PURE__*/jsx(React.Fragment, {
4918
+ children: children
4848
4919
  })]
4849
- })) || props.displayType === "skeleton" && /*#__PURE__*/jsx(StyledMuiListItem, {
4920
+ })) || _displayType === "skeleton" && /*#__PURE__*/jsx(StyledMuiListItem, {
4850
4921
  style: listItemStyle,
4922
+ sx: sx,
4851
4923
  children: /*#__PURE__*/jsx(SkeletonContent, {
4852
4924
  displayType: "listItem",
4853
4925
  withAvatar: true
4854
4926
  })
4855
4927
  }, keyValue);
4856
4928
  };
4857
- ListItem.defaultProps = {
4858
- displayType: "default",
4859
- hasBorder: false,
4860
- disabled: false,
4861
- dense: false,
4862
- canClick: false,
4863
- borderStyle: "2px solid",
4864
- hasGutter: true,
4865
- selected: false,
4866
- display: "vertical"
4867
- };
4868
4929
  ListItem.propTypes = {
4869
4930
  /** The display type of the list item. */
4870
4931
  displayType: PropTypes.oneOf(["default", "skeleton"]),
@@ -4896,8 +4957,12 @@ ListItem.propTypes = {
4896
4957
  hasGutter: PropTypes.bool,
4897
4958
  /** Is the item selected? If selected, the list item will display a background color */
4898
4959
  selected: PropTypes.bool,
4960
+ /** When the list item is selected, use background color or outline. */
4961
+ selectedType: PropTypes.oneOf(["background", "outlined"]),
4899
4962
  /** List display type */
4900
- display: PropTypes.oneOf(["horizontal", "vertical"])
4963
+ display: PropTypes.oneOf(["horizontal", "vertical"]),
4964
+ /** Styles to apply */
4965
+ sx: PropTypes.any
4901
4966
  };
4902
4967
 
4903
4968
  const useStyles$z = makeStyles(theme => ({
@@ -5065,7 +5130,7 @@ SectionTitle.propTypes = {
5065
5130
  component: PropTypes.string
5066
5131
  };
5067
5132
 
5068
- const _excluded$e = ["title", "subtitle", "children", "display", "format", "renderList", "titleComponent"];
5133
+ const _excluded$g = ["title", "subtitle", "children", "display", "format", "renderList", "titleComponent"];
5069
5134
  const Section = _ref => {
5070
5135
  let {
5071
5136
  title,
@@ -5076,7 +5141,7 @@ const Section = _ref => {
5076
5141
  renderList,
5077
5142
  titleComponent
5078
5143
  } = _ref,
5079
- props = _objectWithoutPropertiesLoose(_ref, _excluded$e);
5144
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$g);
5080
5145
  const containerStyle = {
5081
5146
  boxSizing: "border-box",
5082
5147
  width: "100%",
@@ -5713,7 +5778,7 @@ FullPageViewer.propTypes = {
5713
5778
  onMessage: PropTypes.func
5714
5779
  };
5715
5780
 
5716
- const _excluded$d = ["height", "children", "onScroll", "showTopFade", "showBottomFade", "component", "onScrollReachStart", "onScrollReachEnd"];
5781
+ const _excluded$f = ["height", "children", "onScroll", "showTopFade", "showBottomFade", "component", "onScrollReachStart", "onScrollReachEnd"];
5717
5782
  const useStyles$w = makeStyles(() => ({
5718
5783
  scroller: {
5719
5784
  position: "relative",
@@ -5786,7 +5851,7 @@ const ScrollingContainer = _ref => {
5786
5851
  onScrollReachStart,
5787
5852
  onScrollReachEnd
5788
5853
  } = _ref,
5789
- props = _objectWithoutPropertiesLoose(_ref, _excluded$d);
5854
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$f);
5790
5855
  const classes = useStyles$w();
5791
5856
  const [scrolled, setScrolled] = useState(false);
5792
5857
  const rootStyle = {
@@ -6829,7 +6894,7 @@ DataTable.propTypes = {
6829
6894
  };
6830
6895
 
6831
6896
  const options = {
6832
- arrayFormat: "index"
6897
+ arrayFormat: "bracket"
6833
6898
  };
6834
6899
  const setQueryStringWithoutPageReload = qsValue => {
6835
6900
  const {
@@ -7537,7 +7602,7 @@ var dataSourceManager = {
7537
7602
  getDataSourceUrl: getDataSourceUrl
7538
7603
  };
7539
7604
 
7540
- const _excluded$c = ["clearOnChange", "minimumLength"];
7605
+ const _excluded$e = ["clearOnChange", "minimumLength"];
7541
7606
  const WAIT_INTERVAL = 1000;
7542
7607
  const ENTER_KEY = 13;
7543
7608
  const TextSearch$1 = _ref => {
@@ -7545,7 +7610,7 @@ const TextSearch$1 = _ref => {
7545
7610
  clearOnChange,
7546
7611
  minimumLength
7547
7612
  } = _ref,
7548
- props = _objectWithoutPropertiesLoose(_ref, _excluded$c);
7613
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$e);
7549
7614
  const [value, setValue] = useState("");
7550
7615
  const [timer, setTimer] = useState(null);
7551
7616
  const handleChange = e => {
@@ -7580,13 +7645,13 @@ const TextSearch$1 = _ref => {
7580
7645
  value: value,
7581
7646
  onKeyDown: handleKeyDown,
7582
7647
  placeholder: props.placeholder,
7583
- sx: {
7648
+ sx: _extends({
7584
7649
  input: {
7585
7650
  "&::placeholder": {
7586
7651
  opacity: 0.7
7587
7652
  }
7588
7653
  }
7589
- }
7654
+ }, props.sx)
7590
7655
  }, props, {
7591
7656
  inputProps: _extends({}, props.inputProps, {
7592
7657
  "aria-label": props.placeholder
@@ -7659,69 +7724,6 @@ TextSearch.propTypes = {
7659
7724
  bottomGutter: PropTypes.number
7660
7725
  };
7661
7726
 
7662
- const {
7663
- render: render$1
7664
- } = template;
7665
-
7666
- /**
7667
- * This function returns unique field inside filter item using render.
7668
- *
7669
- * @param {object} item
7670
- * @param {object} filter
7671
- * @returns {string}
7672
- */
7673
- const getFilterItemId = (item, configItem = {}) => {
7674
- var _item$data;
7675
- if (item.id) {
7676
- return item.id;
7677
- }
7678
- const template = configItem.idTemplate || configItem.template || configItem.optionTemplate;
7679
- if (template) {
7680
- return render$1(template, item.data || item);
7681
- }
7682
- if ((_item$data = item.data) != null && _item$data.id) {
7683
- return item.data.id;
7684
- }
7685
- };
7686
-
7687
- /**
7688
- * This function checks filter items; if index and id fields are missing then
7689
- * try to sets them with possible ways.
7690
- *
7691
- * @param {array} filters
7692
- * @param {array} configuration
7693
- * @returns {array}
7694
- */
7695
- const formatFilters = (filters = [], configuration = []) => filters.map(filter => {
7696
- var _ref, _filter$index, _filter$id, _configuration$index, _configuration$index2, _configuration$index3, _configuration$index4, _configuration$index5;
7697
- // TODO: index should be defined on filters. There should not be need of
7698
- // search of index value throught type or map values.
7699
- const index = (_ref = (_filter$index = filter == null ? void 0 : filter.index) != null ? _filter$index : findIndexByType(filter, configuration)) != null ? _ref : findIndexByMap(filter, configuration);
7700
- const id = (_filter$id = filter == null ? void 0 : filter.id) != null ? _filter$id : getFilterItemId(filter, configuration[index]);
7701
-
7702
- // TODO: These properties should ONLY be defined either in configuration
7703
- // or filters; currently data can be defined from both sources. Filter
7704
- // data prioritised over configuratuon.
7705
- const {
7706
- map = (_configuration$index = configuration[index]) == null ? void 0 : _configuration$index.map,
7707
- type = (_configuration$index2 = configuration[index]) == null ? void 0 : _configuration$index2.type,
7708
- template = (_configuration$index3 = configuration[index]) == null ? void 0 : _configuration$index3.template,
7709
- idTemplate = (_configuration$index4 = configuration[index]) == null ? void 0 : _configuration$index4.idTemplate,
7710
- optionTemplate = (_configuration$index5 = configuration[index]) == null ? void 0 : _configuration$index5.optionTemplate
7711
- } = filter;
7712
- return _extends({}, filter, {
7713
- template,
7714
- idTemplate,
7715
- optionTemplate,
7716
- type,
7717
- map,
7718
- index,
7719
- id
7720
- });
7721
- });
7722
- const findIndexByType = (filter, configuration) => filter.type !== undefined ? configuration.findIndex(config => config.type === filter.type) : undefined;
7723
- const findIndexByMap = (filter, configuration) => filter.map !== undefined ? configuration.findIndex(config => config.map === filter.map) : undefined;
7724
-
7725
7727
  const mapFilters = newFilters => {
7726
7728
  const mappedFilters = {};
7727
7729
  newFilters.map(filter => {
@@ -7737,7 +7739,7 @@ const mapFilters = newFilters => {
7737
7739
  return mappedFilters;
7738
7740
  };
7739
7741
 
7740
- const _excluded$b = ["parentMenuOpen", "label", "rightIcon", "leftIcon", "children", "className", "tabIndex", "ContainerProps"];
7742
+ const _excluded$d = ["parentMenuOpen", "label", "rightIcon", "leftIcon", "children", "className", "tabIndex", "ContainerProps"];
7741
7743
  const useMenuItemStyles = makeStyles(theme => ({
7742
7744
  root: props => ({
7743
7745
  backgroundColor: props.open ? theme.palette.action.hover : "rgba(0,0,0,0)"
@@ -7758,7 +7760,7 @@ const NestedMenuItem = /*#__PURE__*/React.forwardRef(function NestedMenuItem(pro
7758
7760
  tabIndex: tabIndexProp,
7759
7761
  ContainerProps: ContainerPropsProp = {}
7760
7762
  } = props,
7761
- MenuItemProps = _objectWithoutPropertiesLoose(props, _excluded$b);
7763
+ MenuItemProps = _objectWithoutPropertiesLoose(props, _excluded$d);
7762
7764
  const {
7763
7765
  ref: containerRefProp
7764
7766
  } = ContainerPropsProp,
@@ -8096,7 +8098,8 @@ const FilterChips = ({
8096
8098
  const Filters = useMemo(() => {
8097
8099
  return /*#__PURE__*/jsx(Box$1, {
8098
8100
  sx: {
8099
- display: "flex"
8101
+ display: "flex",
8102
+ flexFlow: "wrap"
8100
8103
  },
8101
8104
  children: _filters.map(filter => /*#__PURE__*/jsx(Grow, {
8102
8105
  in: true,
@@ -8111,7 +8114,7 @@ const FilterChips = ({
8111
8114
  displayOptions: {
8112
8115
  hasIcon: filter.type !== "keyword"
8113
8116
  },
8114
- type: "businessObject",
8117
+ type: filter.type || "businessObject",
8115
8118
  template: filter.template,
8116
8119
  data: filter.data,
8117
8120
  onDelete: () => {
@@ -8122,7 +8125,11 @@ const FilterChips = ({
8122
8125
  }, `filterPanelFilter-${filter.index}-${filter.id}`))
8123
8126
  });
8124
8127
  }, [_filters]);
8125
- const SortItems = useMemo(() => /*#__PURE__*/jsx(Fragment, {
8128
+ const SortItems = useMemo(() => /*#__PURE__*/jsx(Box$1, {
8129
+ sx: {
8130
+ display: "flex",
8131
+ flexFlow: "wrap"
8132
+ },
8126
8133
  children: _sort.map(sortItem => /*#__PURE__*/jsx(Grow, {
8127
8134
  in: true,
8128
8135
  children: /*#__PURE__*/jsx("div", {
@@ -8360,6 +8367,36 @@ PanelDisplay.propTypes = {
8360
8367
  renderFilterSelection: PropTypes.bool
8361
8368
  };
8362
8369
 
8370
+ const usePrevState = (callback, current) => {
8371
+ const [prev, setPrev] = useState(current);
8372
+ if (prev !== current) {
8373
+ callback(prev, current);
8374
+ setPrev(current);
8375
+ }
8376
+ };
8377
+
8378
+ const useFilterState = filtersProp => {
8379
+ const [filters, _setFilters] = useState(filtersProp);
8380
+ const setFilters = useCallback((filters = []) => {
8381
+ const sorted = filters.sort((a, b) => a.index - b.index);
8382
+ _setFilters(sorted);
8383
+ }, []);
8384
+ usePrevState(() => {
8385
+ setFilters(filtersProp);
8386
+ }, filtersProp);
8387
+ return [filters, setFilters];
8388
+ };
8389
+
8390
+ const getItemId = (item, filter) => item.id || template.render(filter.idTemplate || filter.optionTemplate, item);
8391
+ const formatFilterItem = (index, filter, data) => ({
8392
+ index: index,
8393
+ id: getItemId(data, filter),
8394
+ type: filter.type,
8395
+ template: filter.optionTemplate,
8396
+ idTemplate: filter.idTemplate,
8397
+ map: filter.map,
8398
+ data
8399
+ });
8363
8400
  const mapSort = value => value.map(i => i.map);
8364
8401
  const getSearchFilter = newFilters => (newFilters == null ? void 0 : newFilters.filter(filter => (filter == null ? void 0 : filter.type) === "keyword").map(item => item.data.id)) || [];
8365
8402
 
@@ -8378,7 +8415,7 @@ const FilterPanel = props => {
8378
8415
  searchTooltip,
8379
8416
  searchPlaceHolderText,
8380
8417
  configuration,
8381
- filters: filtersProp,
8418
+ filters: filtersProp = [],
8382
8419
  displayType,
8383
8420
  limitTags,
8384
8421
  bottomGutter,
@@ -8388,14 +8425,10 @@ const FilterPanel = props => {
8388
8425
  sort: sortProp
8389
8426
  } = props;
8390
8427
  const [menuPosition, setMenuPosition] = useState(null);
8391
- const [filters, setFilters] = useState([]);
8428
+ const [filters, setFilters] = useFilterState(filtersProp);
8392
8429
  const [sort, setSort] = useState(sortProp || []);
8393
8430
  const [panelSearch, setPanelSearch] = useState([]);
8394
8431
  const [pickerFilters, setPickerFilters] = useState([]);
8395
- useEffect(() => {
8396
- const formattedFilters = formatFilters(filtersProp, configuration);
8397
- setFilters(formattedFilters);
8398
- }, [filtersProp]);
8399
8432
 
8400
8433
  // TODO: replace it with useMemo
8401
8434
  useEffect(() => {
@@ -8421,9 +8454,8 @@ const FilterPanel = props => {
8421
8454
  onDataChange(filteredData, filterParameters, filters);
8422
8455
  }
8423
8456
  }, [filters, sort]);
8424
- const removeFilter = filter => {
8425
- console.log("remove filter ", filter);
8426
- const newFilterArray = filters == null ? void 0 : filters.filter(i => i.index !== filter.index || filter.id !== i.id);
8457
+ const removeFilter = (filter = []) => {
8458
+ const newFilterArray = filters.filter(i => i.index !== filter.index || filter.id !== i.id);
8427
8459
  setFilters(newFilterArray);
8428
8460
  if (!onApplyFilters) {
8429
8461
  if ((filter == null ? void 0 : filter.type) === "keyword" && onSearchChange) {
@@ -8460,69 +8492,14 @@ const FilterPanel = props => {
8460
8492
  onChange(mapFilters(newFilterArray), newFilterArray);
8461
8493
  }
8462
8494
  };
8463
- /** Had to revert this function as filters were not working properly
8464
- const handleSetFilterType = (inputIndex, configItem, data = []) => {
8465
- const newFiltersByUpdatedIndex = data.map((filterItem) => {
8466
- return {
8467
- index: inputIndex,
8468
- id: filterItem.id || getFilterItemId(configItem, filterItem),
8469
- type: configItem.type,
8470
- template: configItem.optionTemplate,
8471
- idTemplate: configItem.idTemplate,
8472
- map: configItem.map,
8473
- data: filterItem
8474
- };
8475
- });
8476
- const filtersByUnupdatedIndex = filters.filter((i) => i.index !== inputIndex);
8477
- const newFilters = [...filtersByUnupdatedIndex, ...newFiltersByUpdatedIndex];
8478
- setFilters(newFilters);
8479
- if (onChange) {
8480
- // TO-CHECK: what does mapFilters do?
8481
- onChange(mapFilters(newFilters), newFilters);
8482
- }
8483
- }; */
8484
-
8485
8495
  const handleSetFilterType = (index, filter, data) => {
8486
- const getItemId = item => item.id || template.render(filter.idTemplate || filter.optionTemplate, item);
8487
- if (!Array.isArray(data)) {
8488
- const _newFilterArray = filters.filter(i => index !== i.index);
8489
- if (data) {
8490
- const newItemId = getItemId(data);
8491
- _newFilterArray.push({
8492
- index: index,
8493
- id: newItemId,
8494
- type: filter.type,
8495
- template: filter.optionTemplate,
8496
- idTemplate: filter.idTemplate,
8497
- map: filter.map,
8498
- data: data
8499
- });
8500
- }
8501
- setFilters(_newFilterArray);
8502
- if (onChange && !onApplyFilters) {
8503
- onChange(mapFilters(_newFilterArray), _newFilterArray);
8504
- }
8505
- return;
8506
- }
8507
- data.map(item => {
8508
- const newItemId = getItemId(item);
8509
- if (!filters.find(i => i.index === index && i.id === newItemId)) {
8510
- filters.push({
8511
- index: index,
8512
- id: newItemId,
8513
- type: filter.type,
8514
- template: filter.optionTemplate,
8515
- idTemplate: filter.idTemplate,
8516
- map: filter.map,
8517
- data: item
8518
- });
8519
- }
8520
- });
8521
- const newFilterArray = filters.filter(i => index !== i.index || index === i.index && data.find(d => i.data.id === d.id));
8522
- setFilters(newFilterArray);
8523
- if (onChange && !onApplyFilters) {
8524
- onChange(mapFilters(newFilterArray), newFilterArray);
8525
- }
8496
+ let _data = data;
8497
+ if (!Array.isArray(data)) _data = data ? [data] : [];
8498
+ const filtersWithoutUpdatedField = filters.filter(filter => index !== filter.index);
8499
+ const newUpdatedFilters = _data.map(d => formatFilterItem(index, filter, d));
8500
+ const newFilters = filtersWithoutUpdatedField.concat(newUpdatedFilters);
8501
+ setFilters(newFilters);
8502
+ if (!onApplyFilters) onChange == null ? void 0 : onChange(mapFilters(newFilters), newFilters);
8526
8503
  };
8527
8504
  const handleSortChange = value => {
8528
8505
  setSort(value);
@@ -9045,12 +9022,12 @@ Actions.propTypes = {
9045
9022
  onAction: PropTypes.func
9046
9023
  };
9047
9024
 
9048
- const _excluded$a = ["hasFilters"];
9025
+ const _excluded$c = ["hasFilters"];
9049
9026
  const RenderFilterButton = /*#__PURE__*/React.forwardRef(function RenderFilterButton(_ref, ref) {
9050
9027
  let {
9051
9028
  hasFilters
9052
9029
  } = _ref,
9053
- props = _objectWithoutPropertiesLoose(_ref, _excluded$a);
9030
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$c);
9054
9031
  return /*#__PURE__*/jsx(IconButton$1, _extends({}, props, {
9055
9032
  ref: ref,
9056
9033
  children: /*#__PURE__*/jsx(Badge, {
@@ -9143,7 +9120,7 @@ DefaultIconButton.propTypes = {
9143
9120
  onClick: PropTypes.func
9144
9121
  };
9145
9122
 
9146
- const _excluded$9 = ["filterSet", "onClick", "disableSetDefault", "index"];
9123
+ const _excluded$b = ["filterSet", "onClick", "disableSetDefault", "index"];
9147
9124
  const useStyles$m = makeStyles(theme => ({
9148
9125
  operations: {
9149
9126
  display: "flex",
@@ -9215,7 +9192,7 @@ const Item$1 = /*#__PURE__*/React.forwardRef((_ref, ref) => {
9215
9192
  disableSetDefault,
9216
9193
  index
9217
9194
  } = _ref,
9218
- props = _objectWithoutPropertiesLoose(_ref, _excluded$9);
9195
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$b);
9219
9196
  const {
9220
9197
  id,
9221
9198
  disabled,
@@ -9271,7 +9248,7 @@ const renderUserDefinedFilters = ({
9271
9248
  index: index
9272
9249
  }, `user-defined-filters-${index}`));
9273
9250
 
9274
- const _excluded$8 = ["filterSet", "onClick", "disableSetDefault", "index"];
9251
+ const _excluded$a = ["filterSet", "onClick", "disableSetDefault", "index"];
9275
9252
  const useStyles$l = makeStyles(() => ({
9276
9253
  operations: {
9277
9254
  display: "flex",
@@ -9313,7 +9290,7 @@ const Item = /*#__PURE__*/React.forwardRef((_ref, ref) => {
9313
9290
  disableSetDefault,
9314
9291
  index
9315
9292
  } = _ref,
9316
- props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
9293
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$a);
9317
9294
  const {
9318
9295
  id,
9319
9296
  disabled,
@@ -9958,13 +9935,13 @@ const Drawer = props => {
9958
9935
  };
9959
9936
  const theme = useTheme$1();
9960
9937
  const appBarStyle = {
9961
- primary: {
9938
+ primary: _extends({
9962
9939
  color: "#ffffff"
9963
- },
9964
- secondary: {
9940
+ }, props.appBarStyle),
9941
+ secondary: _extends({
9965
9942
  backgroundColor: "#ffffff",
9966
9943
  color: "#333333"
9967
- }
9944
+ }, props.appBarStyle)
9968
9945
  };
9969
9946
  const closeDrawerIconStyle = {
9970
9947
  color: props.headerColor === "secondary" ? "rgba(0, 0, 0, 0.54)" : "#ffffff",
@@ -10172,6 +10149,8 @@ Drawer.propTypes = {
10172
10149
  menuPositionOffset: PropTypes.oneOf(["none", "primaryMenu", "secondaryMenu"]),
10173
10150
  /** Additional styles to apply to the drawer paper. */
10174
10151
  paperStyle: PropTypes.any,
10152
+ /** Additional styles to apply to the appbar. */
10153
+ appBarStyle: PropTypes.any,
10175
10154
  /** Whether or not to show the header divider */
10176
10155
  headerDivider: PropTypes.bool,
10177
10156
  /** The component to use while rendering the drawer title */
@@ -10465,7 +10444,7 @@ const getInfoTextByFilterAndSortingCount = (filterCount, sortCount) => {
10465
10444
  return `${appliedText} applied to the data`;
10466
10445
  };
10467
10446
 
10468
- const _excluded$7 = ["status", "data", "isFetching", "fetchNextPage", "hasNextPage", "refetch"];
10447
+ const _excluded$9 = ["status", "data", "isFetching", "fetchNextPage", "hasNextPage", "refetch"];
10469
10448
  const useDidMount = () => {
10470
10449
  const didMountRef = useRef(false);
10471
10450
  useEffect(() => {
@@ -10580,7 +10559,7 @@ const RichDataTable = /*#__PURE__*/forwardRef(function RichDatatable(props, ref)
10580
10559
  hasNextPage,
10581
10560
  refetch
10582
10561
  } = _useDataSourceInfinit;
10583
- _objectWithoutPropertiesLoose(_useDataSourceInfinit, _excluded$7);
10562
+ _objectWithoutPropertiesLoose(_useDataSourceInfinit, _excluded$9);
10584
10563
  const isError = useIsError(status);
10585
10564
  const renderReTryButton = useCallback(status => /*#__PURE__*/jsx(Button, {
10586
10565
  onClick: () => refetch(),
@@ -10962,7 +10941,7 @@ const {
10962
10941
  withEvent: withBOPEvent
10963
10942
  } = createComponentEvent();
10964
10943
 
10965
- const _excluded$6 = ["onSubmit", "value", "columns", "filterPanelConfig", "multiple", "dataSource", "confirmButtonText"];
10944
+ const _excluded$8 = ["onSubmit", "value", "columns", "filterPanelConfig", "multiple", "dataSource", "confirmButtonText"];
10966
10945
  const useDialogOpenEventListener$1 = cb => useBOPEventlistener(event => {
10967
10946
  if (event.name === events.OPEN_ENHANCED_SEARCH_DIALOG) cb(event.payload);
10968
10947
  });
@@ -10976,7 +10955,7 @@ const EnhancedSearchDialog = _ref => {
10976
10955
  dataSource,
10977
10956
  confirmButtonText
10978
10957
  } = _ref,
10979
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
10958
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
10980
10959
  const [selection, setSelection] = useState([]);
10981
10960
  const [open, setOpen] = useState(false);
10982
10961
  useDialogOpenEventListener$1(isOpen => setOpen(isOpen));
@@ -11078,9 +11057,7 @@ const useAutoCompleteValue = (propValue, multiple) => {
11078
11057
  const useSkipOnMount = (fn, deps) => {
11079
11058
  const didMountRef = useRef();
11080
11059
  useEffect(() => {
11081
- if (didMountRef.current) {
11082
- fn();
11083
- }
11060
+ if (didMountRef.current) fn();
11084
11061
  didMountRef.current = true;
11085
11062
  }, deps);
11086
11063
  };
@@ -11093,7 +11070,7 @@ const useDependencyChange = (callback, currentState) => {
11093
11070
  }
11094
11071
  };
11095
11072
 
11096
- 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"];
11073
+ 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"];
11097
11074
  const useStyles$f = makeStyles(theme => ({
11098
11075
  menu: {
11099
11076
  textDecoration: "none",
@@ -11155,9 +11132,10 @@ const BusinessObjectPicker = _ref => {
11155
11132
  enableInfinteScroll,
11156
11133
  renderAddItemForm,
11157
11134
  AddItemFormModalComponent,
11158
- autoCompleteProps = {}
11135
+ autoCompleteProps = {},
11136
+ preventHorizontalExpand = false
11159
11137
  } = _ref,
11160
- props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
11138
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
11161
11139
  const classes = useStyles$f();
11162
11140
  // TODO: implement controlled behaviour
11163
11141
  const [value, setValue] = useAutoCompleteValue(props.value, multiple);
@@ -11360,7 +11338,8 @@ const BusinessObjectPicker = _ref => {
11360
11338
  tooltipText: option.description,
11361
11339
  size: props.size === "medium" || props.size === "small" ? "small" : "large",
11362
11340
  onDelete: () => handleTagDelete(option),
11363
- canDelete: true
11341
+ canDelete: true,
11342
+ displayType: "default"
11364
11343
  })
11365
11344
  }, getKey(option))), [props.size, getKey, getLabel, handleTagDelete]);
11366
11345
  const renderTypeTags = useCallback(value => value.map(option => /*#__PURE__*/jsx(Box$1, {
@@ -11409,7 +11388,11 @@ const BusinessObjectPicker = _ref => {
11409
11388
  value: value,
11410
11389
  renderOption: renderOptionProp || (props.type ? renderBusinessObject : renderOption),
11411
11390
  noOptionsText: status === "error" ? "Error loading options" : "No options",
11412
- getOptionDisabled: optionItem => (optionItem == null ? void 0 : optionItem.__type) === "loadMore" || (optionItem == null ? void 0 : optionItem.__type) === "noOption",
11391
+ getOptionDisabled: optionItem => {
11392
+ if (props.disabled) return true;
11393
+ const type = optionItem == null ? void 0 : optionItem.__type;
11394
+ return type === "loadMore" || type === "noOption";
11395
+ },
11413
11396
  handleHomeEndKeys: true
11414
11397
  // INFO: freeSolo prevents warning:
11415
11398
  // https://stackoverflow.com/questions/61947941/material-ui-autocomplete-warning-the-value-provided-to-autocomplete-is-invalid
@@ -11419,7 +11402,12 @@ const BusinessObjectPicker = _ref => {
11419
11402
  selectOnFocus: false,
11420
11403
  renderTags: renderTags || (props.type ? renderTypeTags : renderCustomTags),
11421
11404
  renderInput: params => /*#__PURE__*/jsx(TextSearch$1, _extends({}, params, props, {
11422
- type: "text",
11405
+ sx: _extends({}, preventHorizontalExpand && {
11406
+ "&>div.MuiInputBase-root": {
11407
+ flexWrap: "nowrap !important"
11408
+ }
11409
+ }),
11410
+ type: "text",
11423
11411
  inputProps: _extends({}, params.inputProps, {
11424
11412
  "data-testid": "content-input"
11425
11413
  }),
@@ -11437,7 +11425,7 @@ const BusinessObjectPicker = _ref => {
11437
11425
  style: {
11438
11426
  color: red[500]
11439
11427
  }
11440
- }), listSelect !== true && /*#__PURE__*/jsx(IconButton$1, {
11428
+ }), listSelect !== true && /*#__PURE__*/jsx(IconButton, {
11441
11429
  "aria-label": open ? `hide options` : "show options",
11442
11430
  size: "small",
11443
11431
  onClick: () => {
@@ -11450,7 +11438,7 @@ const BusinessObjectPicker = _ref => {
11450
11438
  [classes.expandOpen]: open
11451
11439
  })
11452
11440
  })
11453
- }), enhancedSearch && /*#__PURE__*/jsx(IconButton$1, {
11441
+ }), enhancedSearch && /*#__PURE__*/jsx(IconButton, {
11454
11442
  "aria-label": "search",
11455
11443
  size: "small",
11456
11444
  onKeyDown: handleKeyDown,
@@ -11458,6 +11446,7 @@ const BusinessObjectPicker = _ref => {
11458
11446
  name: events.OPEN_ENHANCED_SEARCH_DIALOG,
11459
11447
  payload: true
11460
11448
  }),
11449
+ disabled: props.disabled,
11461
11450
  children: /*#__PURE__*/jsx(Search, {})
11462
11451
  })]
11463
11452
  })
@@ -11480,13 +11469,14 @@ const BusinessObjectPicker = _ref => {
11480
11469
  flexDirection: "column",
11481
11470
  padding: 1
11482
11471
  },
11483
- children: /*#__PURE__*/jsx(IconButton$1, {
11472
+ children: /*#__PURE__*/jsx(IconButton, {
11484
11473
  onClick: () => {
11485
11474
  eventDispatch({
11486
11475
  name: events.OPEN_ADD_ITEM_DIALOG,
11487
11476
  payload: true
11488
11477
  });
11489
11478
  },
11479
+ disabled: props.disabled,
11490
11480
  children: /*#__PURE__*/jsx(AddIcon, {
11491
11481
  sx: {
11492
11482
  color: "grey"
@@ -11586,7 +11576,9 @@ BusinessObjectPicker.propTypes = {
11586
11576
  /** render prop to handle form content, render function provided onSubmit callback function */
11587
11577
  renderAddItemForm: PropTypes.func,
11588
11578
  /** override props of MUI's AutoComplete components */
11589
- autoCompleteProps: PropTypes.object
11579
+ autoCompleteProps: PropTypes.object,
11580
+ /** preventHorizontalExpand */
11581
+ preventHorizontalExpand: PropTypes.bool
11590
11582
  };
11591
11583
  BusinessObjectPicker.defaultProps = {
11592
11584
  multiple: false,
@@ -12548,7 +12540,7 @@ CurriculumChart.propTypes = {
12548
12540
  onLoad: PropTypes.func
12549
12541
  };
12550
12542
 
12551
- const _excluded$4 = ["error", "inputFormat", "value", "isControlled", "onChange", "clearable", "disabled", "required", "showButton", "minimumDate", "maximumDate", "inputEndAdornmentText"];
12543
+ const _excluded$6 = ["error", "inputFormat", "value", "isControlled", "onChange", "clearable", "disabled", "required", "showButton", "minimumDate", "maximumDate", "inputEndAdornmentText"];
12552
12544
  const MuiDatePicker = props => {
12553
12545
  const isMobile = useMediaQuery$1(theme => theme.breakpoints.down("md"));
12554
12546
  if (props.type) {
@@ -12588,7 +12580,7 @@ const DatePickerBase = _ref => {
12588
12580
  maximumDate,
12589
12581
  inputEndAdornmentText
12590
12582
  } = _ref,
12591
- props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
12583
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
12592
12584
  const [value, setValue] = useFormItemState(propsValue, isControlled);
12593
12585
  const handleChange = newValue => {
12594
12586
  !isControlled && setValue(newValue);
@@ -15284,6 +15276,539 @@ RubricDistributionChart.propTypes = {
15284
15276
  titleComponent: PropTypes.oneOf(["h1", "h2", "h3", "h4", "div", "p"])
15285
15277
  };
15286
15278
 
15279
+ const _excluded$5 = ["rules"];
15280
+ const FieldWrapper = ({
15281
+ children
15282
+ }) => {
15283
+ return /*#__PURE__*/jsx(Box$1, {
15284
+ sx: {
15285
+ paddingTop: 1,
15286
+ overflow: "auto"
15287
+ },
15288
+ children: children
15289
+ });
15290
+ };
15291
+ const TemplateField = ({
15292
+ templateSelectionCode,
15293
+ templateOptions,
15294
+ templateInputMap,
15295
+ onChange
15296
+ }) => {
15297
+ const data = useMemo(() => templateOptions.map(({
15298
+ label,
15299
+ code: value
15300
+ }) => ({
15301
+ label,
15302
+ value
15303
+ }), [templateOptions]));
15304
+ const value = useMemo(() => {
15305
+ if (!templateSelectionCode) return undefined;
15306
+ return {
15307
+ value: templateSelectionCode,
15308
+ label: templateInputMap[templateSelectionCode].label
15309
+ };
15310
+ }, [templateSelectionCode]);
15311
+ return /*#__PURE__*/jsx(BusinessObjectPicker$1, {
15312
+ multiple: false,
15313
+ data: data,
15314
+ value: value,
15315
+ onChange: onChange,
15316
+ optionTemplate: "{{label}}",
15317
+ preventHorizontalExpand: true
15318
+ });
15319
+ };
15320
+ function Row({
15321
+ groupId,
15322
+ index,
15323
+ ruleId,
15324
+ ruleIndex,
15325
+ name: templateSelectionCode,
15326
+ // template selection
15327
+ value: ruleValue,
15328
+ // rule value
15329
+ template: ruleTemplate,
15330
+ onRuleDelete,
15331
+ onRuleMoveUp,
15332
+ onRuleMoveDown,
15333
+ onCreateRuleBelow,
15334
+ onTemplateSelect,
15335
+ onTemplateValueChange,
15336
+ templateInputMap,
15337
+ templateOptions
15338
+ }) {
15339
+ const handleChange = useDebounceCallback((value, template) => {
15340
+ onTemplateValueChange({
15341
+ value,
15342
+ template,
15343
+ // TODO: send these as 2nd argument
15344
+ groupId,
15345
+ ruleId
15346
+ // TODO: fix index and ruleIndex lot of re-rendering
15347
+ // index,
15348
+ // ruleIndex
15349
+ });
15350
+ }, 200);
15351
+ const templateValueField = useMemo(() => {
15352
+ if (!templateSelectionCode) return null;
15353
+ const TemplateInputField = templateInputMap[templateSelectionCode].component;
15354
+ return /*#__PURE__*/jsx(TemplateInputField, {
15355
+ value: ruleValue,
15356
+ template: ruleTemplate
15357
+ // TODO: add debouncer
15358
+ ,
15359
+ onChange: handleChange
15360
+ });
15361
+
15362
+ // TODO: take out index from here together with onChange handler
15363
+ // index, ruleIndex,
15364
+ }, [groupId, ruleId, templateSelectionCode, ruleValue, ruleTemplate, handleChange]);
15365
+ return /*#__PURE__*/jsxs(Box$1, {
15366
+ sx: {
15367
+ display: "flex",
15368
+ flexWrap: "no-wrap",
15369
+ paddingTop: 1
15370
+ },
15371
+ children: [/*#__PURE__*/jsxs(Grid, {
15372
+ sx: {
15373
+ flex: 1,
15374
+ backgroundColor: "#f9f9f9",
15375
+ marginLeft: 1,
15376
+ paddingTop: 1,
15377
+ paddingLeft: 2,
15378
+ paddingBottom: 1,
15379
+ paddingRight: 2,
15380
+ borderRadius: "8px",
15381
+ marginBottom: "4px"
15382
+ } // this is for grow
15383
+ ,
15384
+ container: true,
15385
+ rowSpacing: 0.5,
15386
+ columnSpacing: 2,
15387
+ direction: "row",
15388
+ children: [/*#__PURE__*/jsx(Grid, {
15389
+ item: true,
15390
+ xs: 12,
15391
+ sm: 12,
15392
+ md: 4,
15393
+ style: {
15394
+ paddingLeft: 0
15395
+ },
15396
+ children: /*#__PURE__*/jsx(FieldWrapper, {
15397
+ children: /*#__PURE__*/jsx(TemplateField, {
15398
+ templateSelectionCode: templateSelectionCode,
15399
+ templateInputMap: templateInputMap,
15400
+ templateOptions: templateOptions,
15401
+ onChange: valueFieldCode => {
15402
+ onTemplateSelect({
15403
+ templateCode: (valueFieldCode == null ? void 0 : valueFieldCode.value) || null,
15404
+ groupId,
15405
+ ruleId,
15406
+ index,
15407
+ ruleIndex
15408
+ });
15409
+ }
15410
+ })
15411
+ })
15412
+ }), /*#__PURE__*/jsx(Grid, {
15413
+ item: true,
15414
+ xs: 12,
15415
+ sm: 12,
15416
+ md: 8,
15417
+ children: /*#__PURE__*/jsx(FieldWrapper, {
15418
+ children: templateValueField
15419
+ })
15420
+ })]
15421
+ }), /*#__PURE__*/jsx(Box$1, {
15422
+ sx: {
15423
+ width: "48px",
15424
+ marginTop: "22px"
15425
+ },
15426
+ children: /*#__PURE__*/jsx(MenuButton, {
15427
+ name: "rule operation",
15428
+ displayType: "icon",
15429
+ menuConfiguration: [{
15430
+ name: "Move Up",
15431
+ icon: /*#__PURE__*/jsx(KeyboardArrowUpIcon, {}),
15432
+ onClick: function () {
15433
+ onRuleMoveUp({
15434
+ ruleId,
15435
+ index,
15436
+ ruleIndex,
15437
+ groupId
15438
+ });
15439
+ }
15440
+ }, {
15441
+ name: "Move Down",
15442
+ icon: /*#__PURE__*/jsx(KeyboardArrowDownIcon, {}),
15443
+ onClick: () => {
15444
+ onRuleMoveDown({
15445
+ ruleId,
15446
+ index,
15447
+ ruleIndex,
15448
+ groupId
15449
+ });
15450
+ }
15451
+ }, {
15452
+ name: "Add Rule Below",
15453
+ icon: /*#__PURE__*/jsx(AddIcon, {}),
15454
+ onClick: () => {
15455
+ onCreateRuleBelow({
15456
+ ruleId,
15457
+ index,
15458
+ ruleIndex,
15459
+ groupId
15460
+ });
15461
+ }
15462
+ }, {
15463
+ name: "Delete",
15464
+ icon: /*#__PURE__*/jsx(DeleteOutlineOutlinedIcon, {}),
15465
+ onClick: () => {
15466
+ onRuleDelete({
15467
+ ruleId,
15468
+ index,
15469
+ ruleIndex,
15470
+ groupId
15471
+ });
15472
+ }
15473
+ }]
15474
+ })
15475
+ })]
15476
+ });
15477
+ }
15478
+ const RuleGroup = /*#__PURE__*/memo(_ref => {
15479
+ let {
15480
+ rules
15481
+ } = _ref,
15482
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
15483
+ return /*#__PURE__*/jsx(Box$1, {
15484
+ sx: {
15485
+ paddingBottom: 1
15486
+ },
15487
+ children: rules.map(({
15488
+ id,
15489
+ name,
15490
+ value,
15491
+ template
15492
+ }, ruleIndex) => /*#__PURE__*/jsx(Row, _extends({
15493
+ name: name,
15494
+ value: value,
15495
+ template: template,
15496
+ ruleIndex: ruleIndex,
15497
+ ruleId: id
15498
+ }, rest), id))
15499
+ });
15500
+ });
15501
+
15502
+ const RuleGroupFooter = /*#__PURE__*/memo(({
15503
+ groupId,
15504
+ onGroupDelete,
15505
+ onRuleAdd
15506
+ }) => /*#__PURE__*/jsx(Box$1, {
15507
+ sx: {
15508
+ display: "flex",
15509
+ justifyContent: "end",
15510
+ marginRight: 6
15511
+ },
15512
+ children: /*#__PURE__*/jsxs(Box$1, {
15513
+ sx: {
15514
+ display: "flex",
15515
+ flexDirection: "row"
15516
+ },
15517
+ children: [/*#__PURE__*/jsx(Button
15518
+ // onClick={onGroupDelete}
15519
+ , {
15520
+ onClick: () => onGroupDelete({
15521
+ groupId
15522
+ }),
15523
+ startIcon: /*#__PURE__*/jsx(DeleteOutlineOutlinedIcon, {}),
15524
+ children: "Delete Group"
15525
+ }), /*#__PURE__*/jsx(Button, {
15526
+ onClick: () => onRuleAdd({
15527
+ groupId
15528
+ })
15529
+ // onClick={onRuleAdd}
15530
+ ,
15531
+ startIcon: /*#__PURE__*/jsx(AddIcon, {}),
15532
+ children: "Add Rule"
15533
+ })]
15534
+ })
15535
+ }));
15536
+
15537
+ const BuilderHeader = /*#__PURE__*/memo(({
15538
+ onAdd,
15539
+ children
15540
+ }) => /*#__PURE__*/jsxs(Box$1, {
15541
+ sx: {
15542
+ display: "flex"
15543
+ },
15544
+ children: [/*#__PURE__*/jsx(Box$1, {
15545
+ sx: {
15546
+ flex: 1
15547
+ },
15548
+ children: children
15549
+ }), /*#__PURE__*/jsx(Box$1, {
15550
+ sx: {
15551
+ display: "flex",
15552
+ justifyContent: "end",
15553
+ paddingBottom: 1
15554
+ },
15555
+ children: /*#__PURE__*/jsx(Button, {
15556
+ startIcon: /*#__PURE__*/jsx(AddIcon, {}),
15557
+ onClick: onAdd,
15558
+ children: "Add Group"
15559
+ })
15560
+ })]
15561
+ }));
15562
+
15563
+ const RuleGroupIndex = /*#__PURE__*/memo(({
15564
+ onMovePosition,
15565
+ groupId,
15566
+ index,
15567
+ isFirst,
15568
+ isLast
15569
+ }) => /*#__PURE__*/jsx(Box$1, {
15570
+ sx: {
15571
+ width: "40px",
15572
+ height: "88px"
15573
+ },
15574
+ children: /*#__PURE__*/jsxs(Box$1, {
15575
+ sx: {
15576
+ display: "flex",
15577
+ flexDirection: "column",
15578
+ alignItems: "center",
15579
+ position: "relative",
15580
+ top: "0px",
15581
+ width: "20px"
15582
+ },
15583
+ children: [/*#__PURE__*/jsx(IconButton$1, {
15584
+ sx: {
15585
+ visibility: isFirst ? "hidden" : "none"
15586
+ },
15587
+ "aria-label": "move up",
15588
+ onClick: () => onMovePosition({
15589
+ groupId,
15590
+ index
15591
+ }, true),
15592
+ children: /*#__PURE__*/jsx(KeyboardArrowUpIcon, {
15593
+ sx: {
15594
+ color: "grey"
15595
+ }
15596
+ })
15597
+ }), /*#__PURE__*/jsx(Typography, {
15598
+ variant: "body1",
15599
+ color: "#727373",
15600
+ sx: {
15601
+ fontWeight: "500"
15602
+ },
15603
+ children: index + 1
15604
+ }), /*#__PURE__*/jsx(IconButton$1, {
15605
+ "aria-label": "move down",
15606
+ sx: {
15607
+ visibility: isLast ? "hidden" : "none"
15608
+ },
15609
+ onClick: () => onMovePosition({
15610
+ groupId,
15611
+ index
15612
+ }, false),
15613
+ children: /*#__PURE__*/jsx(KeyboardArrowDownIcon, {
15614
+ sx: {
15615
+ color: "grey"
15616
+ }
15617
+ })
15618
+ })]
15619
+ })
15620
+ }));
15621
+
15622
+ const _excluded$4 = ["code"];
15623
+ const TextBuilder = /*#__PURE__*/memo(({
15624
+ renderHeader,
15625
+ templateOptions,
15626
+ value: _value = [],
15627
+ onChange: _onChange = () => {},
15628
+ defaultRule
15629
+ }) => {
15630
+ const templateInputMap = useMemo(() => templateOptions.reduce((obj, _ref) => {
15631
+ let {
15632
+ code
15633
+ } = _ref,
15634
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
15635
+ return _extends({}, obj, {
15636
+ [code]: rest
15637
+ });
15638
+ }, {}), [templateOptions]);
15639
+
15640
+ // TODO: change rows => RuleGroups
15641
+ const [rows, setRows] = useState(_value);
15642
+
15643
+ // TODO: think on better implementation
15644
+ useSkipOnMount(() => {
15645
+ _onChange(rows);
15646
+ }, [rows]);
15647
+ const setMutatableRows = useCallback(setterFn => {
15648
+ setRows(rows => {
15649
+ const res = produce(rows, setterFn);
15650
+ return res;
15651
+ });
15652
+ }, []);
15653
+ const handleAddGroup = () => {
15654
+ // TODO use setMutatableRows
15655
+ setRows([...rows, {
15656
+ index: rows.length,
15657
+ groupId: v4(),
15658
+ rules: [_extends({
15659
+ id: v4()
15660
+ }, defaultRule)]
15661
+ }]);
15662
+ };
15663
+ const handleGroupDelete = ({
15664
+ groupId
15665
+ }) => {
15666
+ const newRows = rows.filter(row => row.groupId !== groupId);
15667
+ setRows(newRows);
15668
+ };
15669
+ const handleRuleDelete = ({
15670
+ index,
15671
+ ruleId
15672
+ }) => {
15673
+ setMutatableRows(groups => {
15674
+ groups[index].rules = groups[index].rules.filter(rule => rule.id !== ruleId);
15675
+ });
15676
+ };
15677
+ const handleRuleMoveUp = ({
15678
+ index,
15679
+ ruleIndex
15680
+ }) => {
15681
+ setMutatableRows(groups => {
15682
+ if (ruleIndex === 0) return;
15683
+ const nextRow = ruleIndex - 1 ;
15684
+ [groups[index].rules[ruleIndex], groups[index].rules[nextRow]] = [groups[index].rules[nextRow], groups[index].rules[ruleIndex]];
15685
+ });
15686
+ };
15687
+ const handleRuleMoveDown = ({
15688
+ index,
15689
+ ruleIndex
15690
+ }) => {
15691
+ setMutatableRows(groups => {
15692
+ if (groups[index].rules.length - 1 === ruleIndex) return;
15693
+ const nextRow = ruleIndex + 1;
15694
+ [groups[index].rules[ruleIndex], groups[index].rules[nextRow]] = [groups[index].rules[nextRow], groups[index].rules[ruleIndex]];
15695
+ });
15696
+ };
15697
+ const handleCreateRuleBelow = ({
15698
+ index,
15699
+ ruleIndex,
15700
+ templateCode
15701
+ }) => {
15702
+ setMutatableRows(groups => {
15703
+ const newRule = _extends({
15704
+ id: v4()
15705
+ }, defaultRule);
15706
+ groups[index].rules = [...groups[index].rules.slice(0, ruleIndex + 1), newRule, ...groups[index].rules.slice(ruleIndex + 1)];
15707
+ });
15708
+ };
15709
+
15710
+ // TODO change name
15711
+ const handleRuleTemplateSelect = ({
15712
+ index,
15713
+ ruleIndex,
15714
+ templateCode
15715
+ }) => {
15716
+ setMutatableRows(groups => {
15717
+ groups[index].rules[ruleIndex].name = templateCode || null;
15718
+ groups[index].rules[ruleIndex].value = null;
15719
+ groups[index].rules[ruleIndex].template = null;
15720
+ });
15721
+ };
15722
+ const handleRuleTemplateValueChange = ({
15723
+ value,
15724
+ template,
15725
+ groupId,
15726
+ ruleId
15727
+ }) => {
15728
+ setMutatableRows(groups => {
15729
+ const rule = groups.find(group => group.groupId === groupId).rules.find(rule => rule.id === ruleId);
15730
+ rule.value = value;
15731
+ rule.template = template;
15732
+ });
15733
+ };
15734
+ const moveGroupPosition = ({
15735
+ index
15736
+ }, isUp) => {
15737
+ const newRows = rows.slice();
15738
+ const nextRow = isUp ? index - 1 : index + 1;
15739
+ [newRows[index], newRows[nextRow]] = [newRows[nextRow], newRows[index]];
15740
+ setRows(newRows);
15741
+ };
15742
+ const handleAddRule = ({
15743
+ groupId
15744
+ }) => {
15745
+ const newRules = rows.map(row => {
15746
+ if (row.groupId !== groupId) return row;
15747
+ return _extends({}, row, {
15748
+ rules: [...row.rules, _extends({
15749
+ id: v4()
15750
+ }, defaultRule)]
15751
+ });
15752
+ });
15753
+ setRows(newRules);
15754
+ };
15755
+ return /*#__PURE__*/jsxs(ContentBox, {
15756
+ sx: {
15757
+ ".MuiFormControl-root": {
15758
+ background: "white"
15759
+ }
15760
+ },
15761
+ children: [/*#__PURE__*/jsx(BuilderHeader, {
15762
+ onAdd: handleAddGroup,
15763
+ children: renderHeader()
15764
+ }), rows.map(({
15765
+ groupId,
15766
+ rules
15767
+ }, index) => /*#__PURE__*/jsx(ContentBox, {
15768
+ displayType: "outlined",
15769
+ sx: {
15770
+ paddingBottom: 2
15771
+ },
15772
+ children: /*#__PURE__*/jsxs(Box$1, {
15773
+ sx: {
15774
+ display: "flex",
15775
+ flexWrap: "no-wrap",
15776
+ border: "1px solid transparent"
15777
+ },
15778
+ children: [/*#__PURE__*/jsx(RuleGroupIndex, {
15779
+ onMovePosition: moveGroupPosition,
15780
+ isFirst: index === 0,
15781
+ isLast: index === rows.length - 1,
15782
+ index: index,
15783
+ groupId: groupId
15784
+ }), /*#__PURE__*/jsxs(Box$1, {
15785
+ sx: {
15786
+ flex: 1
15787
+ },
15788
+ children: [/*#__PURE__*/jsx(RuleGroup, {
15789
+ index: index,
15790
+ rules: rules,
15791
+ groupId: groupId,
15792
+ templateOptions: templateOptions,
15793
+ templateInputMap: templateInputMap,
15794
+ onRuleDelete: handleRuleDelete,
15795
+ onRuleMoveUp: handleRuleMoveUp,
15796
+ onRuleMoveDown: handleRuleMoveDown,
15797
+ onCreateRuleBelow: handleCreateRuleBelow,
15798
+ onTemplateSelect: handleRuleTemplateSelect,
15799
+ onTemplateValueChange: handleRuleTemplateValueChange
15800
+ }), /*#__PURE__*/jsx(RuleGroupFooter, {
15801
+ groupIndex: index,
15802
+ groupId: groupId,
15803
+ onGroupDelete: handleGroupDelete,
15804
+ onRuleAdd: handleAddRule
15805
+ })]
15806
+ })]
15807
+ })
15808
+ }, groupId))]
15809
+ });
15810
+ });
15811
+
15287
15812
  const moreThan = ruleValue => ({
15288
15813
  fieldValue
15289
15814
  }) => {
@@ -16652,14 +17177,6 @@ const render = (value, formState) => {
16652
17177
  }
16653
17178
  return mustache.render(value, formState);
16654
17179
  };
16655
- const renderUrl = (value, formState) => {
16656
- if (value === undefined || value === null) {
16657
- return value;
16658
- }
16659
- return decodeHtml$2(mustache.render(value, formState));
16660
- };
16661
- const useRenderUrl = template => useSelectFormState(state => renderUrl(template, state));
16662
- const useRender = template => useSelectFormState(state => render(template, state));
16663
17180
 
16664
17181
  const useQueryTemplateParam = queryTemplate => {
16665
17182
  const selector = useCallback(state => {
@@ -16946,7 +17463,7 @@ const DateSelectReadOnly$1 = ({
16946
17463
  schema
16947
17464
  }) => {
16948
17465
  const value = useMemo(() => {
16949
- if (formData == undefined) return null;
17466
+ if (!(formData != null && formData.date)) return null;
16950
17467
  const date = new Date(formData.date);
16951
17468
  const options = _extends({}, formData.type === "y" && {
16952
17469
  year: "numeric"
@@ -16996,30 +17513,37 @@ const DateSelect = props => {
16996
17513
  rawErrors,
16997
17514
  disabled
16998
17515
  } = props;
16999
- const [selectedDate, setSelectedDate] = useState(null);
17000
- const [dateType, setDateType] = useState(dateTypes.day);
17001
17516
  const serverSideDateFormat = "MM-dd-yyyy";
17002
- useEffect(() => {
17517
+ const [{
17518
+ selectedDate,
17519
+ dateType
17520
+ }, setFieldValue] = useState(() => {
17003
17521
  if (formData && typeof formData === "object" && formData.date != undefined) {
17004
- let obj = formData;
17005
- setDateType(findDateType(obj.type));
17006
- setSelectedDate(parse$1(obj.date, serverSideDateFormat, new Date()));
17522
+ return {
17523
+ selectedDate: parse$1(formData.date, serverSideDateFormat, new Date()),
17524
+ dateType: findDateType(formData.type)
17525
+ };
17007
17526
  } else {
17008
- setDateType(dateTypes.day);
17009
- setSelectedDate(null);
17527
+ return {
17528
+ selectedDate: null,
17529
+ dateType: formData != null && formData.type ? findDateType(formData.type) : dateTypes.day
17530
+ };
17010
17531
  }
17011
- }, [formData]);
17532
+ });
17012
17533
  const handleDateTypeChange = (event, newDateType) => {
17013
- if (newDateType != null) {
17014
- setDateType(newDateType);
17015
- if (typeof selectedDate !== "undefined" && selectedDate != null) {
17016
- format$1(selectedDate, serverSideDateFormat);
17017
- onChange({
17018
- date: format$1(selectedDate, serverSideDateFormat),
17019
- type: newDateType.type
17020
- });
17021
- }
17534
+ // INFO: toggle sends null value on double click
17535
+ if (!newDateType) return;
17536
+ let newDate = null;
17537
+ if (typeof selectedDate !== "undefined" && selectedDate != null) {
17538
+ newDate = format(selectedDate, serverSideDateFormat);
17022
17539
  }
17540
+ setFieldValue(prev => _extends({}, prev, {
17541
+ dateType: newDateType
17542
+ }));
17543
+ onChange({
17544
+ date: newDate,
17545
+ type: newDateType.type
17546
+ });
17023
17547
  };
17024
17548
  const handleDateChange = newDate => {
17025
17549
  if (newDate != null) {
@@ -17029,13 +17553,17 @@ const DateSelect = props => {
17029
17553
  newDate = setDate(newDate, 1);
17030
17554
  newDate = setMonth(newDate, 0);
17031
17555
  }
17032
- setSelectedDate(newDate);
17556
+ setFieldValue(prev => _extends({}, prev, {
17557
+ selectedDate: newDate
17558
+ }));
17033
17559
  onChange({
17034
- date: format$1(newDate, serverSideDateFormat),
17560
+ date: format(newDate, serverSideDateFormat),
17035
17561
  type: dateType.type
17036
17562
  });
17037
17563
  } else {
17038
- setSelectedDate(newDate);
17564
+ setFieldValue(prev => _extends({}, prev, {
17565
+ selectedDate: null
17566
+ }));
17039
17567
  onChange({
17040
17568
  date: null,
17041
17569
  type: dateType.type
@@ -17105,7 +17633,7 @@ const DateSelect = props => {
17105
17633
  inputVariant: "outlined",
17106
17634
  inputFormat: dateType.format,
17107
17635
  views: dateType.views,
17108
- value: typeof selectedDate === "undefined" ? null : selectedDate,
17636
+ value: selectedDate || null,
17109
17637
  onChange: handleDateChange,
17110
17638
  disabled: disabled,
17111
17639
  renderInput: params => /*#__PURE__*/jsx(TextField, _extends({}, params, {
@@ -17115,7 +17643,12 @@ const DateSelect = props => {
17115
17643
  sx: dateInputStyles
17116
17644
  })),
17117
17645
  minDate: minDate,
17118
- maxDate: maxDate
17646
+ maxDate: maxDate,
17647
+ componentsProps: {
17648
+ actionBar: {
17649
+ actions: ["cancel", "clear", "accept"]
17650
+ }
17651
+ }
17119
17652
  })
17120
17653
  })]
17121
17654
  });
@@ -17155,49 +17688,6 @@ const DisableWrapper = ({
17155
17688
  }));
17156
17689
  };
17157
17690
 
17158
- const ImageUploadReadOnly = ({
17159
- formData,
17160
- schema,
17161
- uiSchema: _uiSchema = {
17162
- "ui:options": {}
17163
- }
17164
- }) => {
17165
- const {
17166
- downloadUrl: downloadUrlTemplate,
17167
- extension: extensionTemplate
17168
- } = _uiSchema["ui:options"];
17169
- const downloadUrl = useRenderUrl(downloadUrlTemplate);
17170
- const extension = useRender(extensionTemplate);
17171
- return /*#__PURE__*/jsxs(Fragment, {
17172
- children: [/*#__PURE__*/jsx(Typography, {
17173
- gutterBottom: true,
17174
- variant: "subtitle2",
17175
- children: schema.title
17176
- }), /*#__PURE__*/jsx(Paper, {
17177
- sx: {
17178
- height: 185,
17179
- justifyContent: "center",
17180
- display: "flex",
17181
- padding: 2,
17182
- overflow: "hidden"
17183
- },
17184
- variant: "outlined",
17185
- children: /*#__PURE__*/jsx(Image, {
17186
- src: downloadUrl,
17187
- style: {
17188
- height: "100%",
17189
- width: "auto"
17190
- },
17191
- extension: extension
17192
- })
17193
- })]
17194
- });
17195
- };
17196
- ImageUploadReadOnly.propTypes = {
17197
- schema: PropTypes.any,
17198
- renderedValues: PropTypes.any
17199
- };
17200
-
17201
17691
  const FieldContainer = props => {
17202
17692
  return /*#__PURE__*/jsx(Box$2, _extends({}, props, {
17203
17693
  sx: _extends({}, props.sx, {
@@ -17209,7 +17699,30 @@ const FieldContainer = props => {
17209
17699
  };
17210
17700
  FieldContainer.propTypes = Box$2.propTypes;
17211
17701
 
17212
- registerPlugin(FilePondPluginFileValidateType, FilePondPluginImageExifOrientation, FilePondPluginImagePreview, FilePondPluginGetFile);
17702
+ registerPlugin(FilePondPluginFileValidateType, FilePondPluginFileValidateSize, FilePondPluginImageExifOrientation, FilePondPluginImagePreview, FilePondPluginGetFile);
17703
+
17704
+ // Check enums below
17705
+ // source:https://github.com/pqina/filepond-docs/blob/master/content/patterns/API/filepond-object.md#filepond-status
17706
+ const FILE_STATUS = {
17707
+ INIT: 1,
17708
+ IDLE: 2,
17709
+ PROCESSING_QUEUED: 9,
17710
+ PROCESSING: 3,
17711
+ PROCESSING_COMPLETE: 5,
17712
+ // upload complete
17713
+ PROCESSING_ERROR: 6,
17714
+ PROCESSING_REVERT_ERROR: 10,
17715
+ LOADING: 7,
17716
+ LOAD_ERROR: 8
17717
+ };
17718
+ const FILE_ORIGIN = {
17719
+ INPUT: 1,
17720
+ // add by user
17721
+ LIMBO: 2,
17722
+ // temp file
17723
+ LOCAL: 3 // pre-loaded files
17724
+ };
17725
+
17213
17726
  const Upload = props => {
17214
17727
  const {
17215
17728
  schema,
@@ -17218,67 +17731,108 @@ const Upload = props => {
17218
17731
  "ui:options": {}
17219
17732
  },
17220
17733
  onChange,
17221
- disabled,
17222
- required
17734
+ disabled
17223
17735
  } = props;
17736
+ const emptyValue = uiSchema["ui:emptyValue"] || null;
17224
17737
  const isReadOnly = useReadOnly();
17225
17738
  const {
17226
- documentName: documentNameTemplate,
17227
- downloadUrl: downloadUrlTemplate,
17228
- extension: extensionTemplate,
17229
17739
  uploadDataSource,
17230
- mapUploadResponse,
17231
17740
  acceptedFileTypes,
17232
17741
  message,
17233
- isImage
17234
- } = uiSchema["ui:options"];
17235
- const inputProps = uiSchema == null ? void 0 : uiSchema["ui:props"];
17236
- const documentName = useRender(documentNameTemplate);
17237
- const downloadUrl = useRenderUrl(downloadUrlTemplate);
17238
- useRender(extensionTemplate);
17239
- const [files, setFiles] = useState([]);
17240
- const uploadUrl = useMemo(() => getDataSourceUrl(uploadDataSource), [uploadDataSource]);
17742
+ // TODO: can be handled generic way with HOC
17743
+ isImage = true,
17744
+ // multiple = true, // change to false
17241
17745
 
17242
- // INFO: this state is needed to prevent re-load of file during submit
17243
- const [currentFileId, setCurrentFileId] = useState();
17746
+ isPreviewHidden = false,
17747
+ idTemplate,
17748
+ downloadUrlTemplate,
17749
+ nameTemplate,
17750
+ mapUploadResponseToIdTemplate,
17751
+ maxFiles = 1,
17752
+ maxFileSize = null,
17753
+ maxTotalFileSize = null
17754
+ } = uiSchema["ui:options"];
17244
17755
 
17245
- // TODO: change this to useMemo with help of useLastestDeps
17246
- useEffect(() => {
17247
- if (formData === currentFileId) return;
17248
- const files = [{
17249
- source: documentName || "File",
17250
- options: {
17251
- type: "local",
17252
- metadata: {
17253
- url: downloadUrl
17756
+ // TODO: implement single vs multipe mode, currently only multiple is active
17757
+ // let _formData = formData; if (multiple && (formData === null ||
17758
+ // formData === undefined)) { _formData = [];
17759
+ // }
17760
+ const _formData = formData || [];
17761
+ const initialFiles = useMemo(() => {
17762
+ return _formData.map(({
17763
+ data
17764
+ }) => {
17765
+ const id = mustache.render(idTemplate, data);
17766
+ const downloadUrl = downloadUrlTemplate ? decodeHtml$2(mustache.render(downloadUrlTemplate, data)) : downloadUrlTemplate;
17767
+ const name = mustache.render(nameTemplate, data);
17768
+ return {
17769
+ // INFO: source appears in preview but also needed to identify
17770
+ // the download URL. Check issue:
17771
+ // https://github.com/pqina/filepond/issues/284
17772
+ source: `${name} id:${id}`,
17773
+ options: {
17774
+ type: "local",
17775
+ origin: downloadUrl,
17776
+ // INFO: id is used in getFileIds function
17777
+ metadata: {
17778
+ url: downloadUrl,
17779
+ id
17780
+ }
17254
17781
  }
17255
- }
17256
- }];
17257
- if (formData != undefined) setFiles(files);
17258
- }, [formData]);
17259
- const handleLoad = (source, load, error) => {
17260
- fetch(downloadUrl).then(res => res.blob()).then(res => {
17782
+ };
17783
+ });
17784
+ }, []);
17785
+ const inputProps = uiSchema == null ? void 0 : uiSchema["ui:props"];
17786
+ const filePondRef = useRef();
17787
+ const getFileIds = () => {
17788
+ var _filePondRef$current;
17789
+ return ((_filePondRef$current = filePondRef.current) == null ? void 0 : _filePondRef$current.getFiles().filter(file => {
17790
+ const {
17791
+ origin,
17792
+ status
17793
+ } = file;
17794
+ if (origin === FILE_ORIGIN.LOCAL) return true;
17795
+ if (origin === FILE_ORIGIN.INPUT && status === FILE_STATUS.PROCESSING_COMPLETE) return true;
17796
+ }).map(file => {
17797
+ if (file.origin === FILE_ORIGIN.LOCAL) return file.getMetadata().id;
17798
+ return file.serverId;
17799
+ }).map(i => i.toString())) || [];
17800
+ };
17801
+ const uploadUrl = useMemo(() => getDataSourceUrl(uploadDataSource), [uploadDataSource]);
17802
+ const handleLoad = (source, load, error, progress, abort, headers) => {
17803
+ // INFO: source appears in preview but also needed to identify
17804
+ // the download URL. Check issue:
17805
+ // https://github.com/pqina/filepond/issues/284
17806
+ const file = initialFiles.find(item => item.source === source);
17807
+ const loadUrl = file.options.origin;
17808
+ fetch(loadUrl).then(res => res.blob()).then(res => {
17261
17809
  const file = res.type === "jpeg/jfif" || !res.type ? new Blob([res], {
17262
17810
  type: "image/jpeg"
17263
17811
  }) : res;
17264
- load(file);
17812
+ const preview = isPreviewHidden ? res : file;
17813
+ load(preview);
17265
17814
  }).catch(error);
17815
+
17816
+ // Should expose an abort method so the request can be cancelled
17817
+ return {
17818
+ abort: () => abort()
17819
+ };
17266
17820
  };
17267
17821
  const handleUploadResponse = res => {
17268
17822
  try {
17269
17823
  const jsonRes = JSON.parse(res);
17270
- const fileUuid = mapUploadResponse ? mustache.render(mapUploadResponse.fileUuid, jsonRes) : jsonRes.DATA.fileUuid;
17271
- setCurrentFileId(fileUuid);
17272
- onChange(fileUuid);
17824
+ const id = mustache.render(mapUploadResponseToIdTemplate, jsonRes);
17825
+ return id;
17273
17826
  } catch (err) {
17274
- console.log(err);
17827
+ var _window$logger;
17828
+ (_window$logger = window.logger) == null ? void 0 : _window$logger.sendLog({
17829
+ name: `Upload response could not be parsed. ${err}`,
17830
+ data: res
17831
+ });
17275
17832
  }
17276
17833
  };
17277
- const handleDelete = () => {
17278
- setCurrentFileId();
17279
- setFiles([]);
17280
- onChange();
17281
- };
17834
+
17835
+ // TODO: move to message HOC
17282
17836
  const messageProps = {
17283
17837
  title: (message == null ? void 0 : message.title) || undefined,
17284
17838
  description: (message == null ? void 0 : message.description) || undefined,
@@ -17288,48 +17842,91 @@ const Upload = props => {
17288
17842
  const {
17289
17843
  error
17290
17844
  } = useNotify();
17291
- const filePondProps = {
17292
- acceptedFileTypes: acceptedFileTypes ? acceptedFileTypes : isImage ? ["image/*"] : null,
17293
- files,
17294
- allowMultiple: false,
17295
- server: {
17296
- url: uploadUrl,
17297
- process: {
17298
- method: "POST",
17299
- headers: {
17300
- Methods: "POST"
17301
- },
17302
- onload: handleUploadResponse,
17303
- onerror: e => {
17304
- var _window$logger;
17305
- const message = `The image could not be uploaded.`;
17306
- error(message);
17307
- (_window$logger = window.logger) == null ? void 0 : _window$logger.sendLog({
17308
- name: message,
17309
- data: e
17310
- });
17311
- }
17845
+ const handleFileChange = () => {
17846
+ const ids = getFileIds();
17847
+
17848
+ // TODO: fill the data
17849
+ const value = ids.map(id => ({
17850
+ value: id,
17851
+ data: {}
17852
+ }));
17853
+ if (value.length === 0) onChange(emptyValue);else onChange(value);
17854
+ };
17855
+
17856
+ // TODO: move to memo component
17857
+ const FileUpload = useMemo(() => {
17858
+ const styles = isReadOnly ? {
17859
+ // INFO: hide drop panel and drop panel
17860
+ "div>div>div.filepond--drop-label": {
17861
+ display: "none"
17312
17862
  },
17313
- load: handleLoad,
17314
- revert: handleDelete
17315
- },
17316
- onupdatefiles: files => {
17317
- if (files.length === 0) {
17318
- onChange(undefined);
17863
+ "button.filepond--action-remove-item": {
17864
+ display: "none"
17319
17865
  }
17320
- setFiles(files);
17321
- },
17322
- allowProcess: false,
17323
- disabled: isReadOnly,
17324
- allowDownloadByUrl: true
17325
- };
17326
- const overrideProps = typeof inputProps === "function" ? inputProps(filePondProps) : inputProps;
17866
+ } : null;
17867
+ const getAcceptedFileTypes = () => {
17868
+ if (acceptedFileTypes) return acceptedFileTypes;
17869
+ if (isImage) return ["image/*"];
17870
+ return null;
17871
+ };
17872
+ const filePondProps = {
17873
+ acceptedFileTypes: getAcceptedFileTypes(),
17874
+ files: initialFiles,
17875
+ // files: undefined,
17876
+ allowMultiple: true,
17877
+ server: {
17878
+ url: uploadUrl,
17879
+ process: {
17880
+ method: "POST",
17881
+ headers: {
17882
+ Methods: "POST"
17883
+ },
17884
+ onload: handleUploadResponse,
17885
+ onerror: e => {
17886
+ var _window$logger2;
17887
+ const message = `The image could not be uploaded.`;
17888
+ error(message);
17889
+ (_window$logger2 = window.logger) == null ? void 0 : _window$logger2.sendLog({
17890
+ name: message,
17891
+ data: e
17892
+ });
17893
+ }
17894
+ },
17895
+ load: handleLoad
17896
+ },
17897
+ onprocessfile: () => handleFileChange(),
17898
+ onremovefile: () => handleFileChange(),
17899
+ maxParallelUploads: 3,
17900
+ allowProcess: false,
17901
+ disabled: isReadOnly,
17902
+ allowDownloadByUrl: true,
17903
+ maxFiles: maxFiles,
17904
+ maxFileSize,
17905
+ maxTotalFileSize,
17906
+ // INFO: allowDrop create problem on file type validation //
17907
+ // (check badge form), for preview image allowDrop: false, //
17908
+ // labelIdle: "Click Here to Browse File(s)" //
17909
+ allowFileTypeValidation: false
17910
+ };
17911
+ const overrideProps = typeof inputProps === "function" ? inputProps(filePondProps) : inputProps;
17912
+ return /*#__PURE__*/jsx(Box$1, {
17913
+ sx: styles,
17914
+ children: /*#__PURE__*/jsx(FilePond, _extends({
17915
+ ref: filePondRef
17916
+ }, filePondProps, overrideProps))
17917
+ });
17918
+ }, []);
17919
+
17920
+ // TODO: better implementation
17327
17921
  if (isReadOnly) {
17328
17922
  if (formData == undefined) return /*#__PURE__*/jsx(ReadOnlyView, {
17329
17923
  label: schema.title,
17330
17924
  emptyViewText: "No file uploaded"
17331
17925
  });
17332
- if (isImage) return /*#__PURE__*/jsx(ImageUploadReadOnly, _extends({}, props));
17926
+ return /*#__PURE__*/jsx(ReadOnlyView, {
17927
+ label: schema.title,
17928
+ renderValue: () => FileUpload
17929
+ });
17333
17930
  }
17334
17931
  return /*#__PURE__*/jsxs(FieldContainer, {
17335
17932
  children: [/*#__PURE__*/jsxs(DisableWrapper, {
@@ -17346,7 +17943,7 @@ const Upload = props => {
17346
17943
  sx: {
17347
17944
  marginTop: 1
17348
17945
  },
17349
- children: /*#__PURE__*/jsx(FilePond, _extends({}, filePondProps, overrideProps))
17946
+ children: FileUpload
17350
17947
  })]
17351
17948
  }), message && /*#__PURE__*/jsx(Alert, _extends({}, messageProps))]
17352
17949
  });
@@ -18433,7 +19030,13 @@ const DateWidgetRaw = ({
18433
19030
  required: required,
18434
19031
  onChange: handleChange,
18435
19032
  disabled: disabled
18436
- }, uiSchema == null ? void 0 : uiSchema["ui:props"]));
19033
+ }, uiSchema == null ? void 0 : uiSchema["ui:props"], {
19034
+ componentsProps: {
19035
+ actionBar: {
19036
+ actions: ["cancel", "clear", "accept"]
19037
+ }
19038
+ }
19039
+ }));
18437
19040
  };
18438
19041
  DateWidgetRaw.propTypes = {
18439
19042
  onChange: PropTypes.func,
@@ -18568,1003 +19171,6 @@ const PhoneWidgetReadOnly = props => {
18568
19171
  const HOCs$5 = [...commonWidgetHOCs, withReadyOnly(PhoneWidgetReadOnly)];
18569
19172
  var PhoneWidget$1 = compose(HOCs$5)(PhoneWidget);
18570
19173
 
18571
- /**
18572
- * react-number-format - 5.1.3
18573
- * Author : Sudhanshu Yadav
18574
- * Copyright (c) 2016, 2023 to Sudhanshu Yadav, released under the MIT license.
18575
- * https://github.com/s-yadav/react-number-format
18576
- */
18577
-
18578
- /******************************************************************************
18579
- Copyright (c) Microsoft Corporation.
18580
-
18581
- Permission to use, copy, modify, and/or distribute this software for any
18582
- purpose with or without fee is hereby granted.
18583
-
18584
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
18585
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18586
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
18587
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18588
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18589
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18590
- PERFORMANCE OF THIS SOFTWARE.
18591
- ***************************************************************************** */
18592
-
18593
- function __rest(s, e) {
18594
- var t = {};
18595
- for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
18596
- { t[p] = s[p]; } }
18597
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18598
- { for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18599
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18600
- { t[p[i]] = s[p[i]]; }
18601
- } }
18602
- return t;
18603
- }
18604
-
18605
- var SourceType;
18606
- (function (SourceType) {
18607
- SourceType["event"] = "event";
18608
- SourceType["props"] = "prop";
18609
- })(SourceType || (SourceType = {}));
18610
-
18611
- // basic noop function
18612
- function noop() { }
18613
- function charIsNumber(char) {
18614
- return !!(char || '').match(/\d/);
18615
- }
18616
- function isNil(val) {
18617
- return val === null || val === undefined;
18618
- }
18619
- function isNanValue(val) {
18620
- return typeof val === 'number' && isNaN(val);
18621
- }
18622
- function escapeRegExp(str) {
18623
- return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
18624
- }
18625
- function getThousandsGroupRegex(thousandsGroupStyle) {
18626
- switch (thousandsGroupStyle) {
18627
- case 'lakh':
18628
- return /(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/g;
18629
- case 'wan':
18630
- return /(\d)(?=(\d{4})+(?!\d))/g;
18631
- case 'thousand':
18632
- default:
18633
- return /(\d)(?=(\d{3})+(?!\d))/g;
18634
- }
18635
- }
18636
- function applyThousandSeparator(str, thousandSeparator, thousandsGroupStyle) {
18637
- var thousandsGroupRegex = getThousandsGroupRegex(thousandsGroupStyle);
18638
- var index = str.search(/[1-9]/);
18639
- index = index === -1 ? str.length : index;
18640
- return (str.substring(0, index) +
18641
- str.substring(index, str.length).replace(thousandsGroupRegex, '$1' + thousandSeparator));
18642
- }
18643
- function usePersistentCallback(cb) {
18644
- var callbackRef = useRef(cb);
18645
- // keep the callback ref upto date
18646
- callbackRef.current = cb;
18647
- /**
18648
- * initialize a persistent callback which never changes
18649
- * through out the component lifecycle
18650
- */
18651
- var persistentCbRef = useRef(function () {
18652
- var args = [], len = arguments.length;
18653
- while ( len-- ) args[ len ] = arguments[ len ];
18654
-
18655
- return callbackRef.current.apply(callbackRef, args);
18656
- });
18657
- return persistentCbRef.current;
18658
- }
18659
- //spilt a float number into different parts beforeDecimal, afterDecimal, and negation
18660
- function splitDecimal(numStr, allowNegative) {
18661
- if ( allowNegative === void 0 ) allowNegative = true;
18662
-
18663
- var hasNegation = numStr[0] === '-';
18664
- var addNegation = hasNegation && allowNegative;
18665
- numStr = numStr.replace('-', '');
18666
- var parts = numStr.split('.');
18667
- var beforeDecimal = parts[0];
18668
- var afterDecimal = parts[1] || '';
18669
- return {
18670
- beforeDecimal: beforeDecimal,
18671
- afterDecimal: afterDecimal,
18672
- hasNegation: hasNegation,
18673
- addNegation: addNegation,
18674
- };
18675
- }
18676
- function fixLeadingZero(numStr) {
18677
- if (!numStr)
18678
- { return numStr; }
18679
- var isNegative = numStr[0] === '-';
18680
- if (isNegative)
18681
- { numStr = numStr.substring(1, numStr.length); }
18682
- var parts = numStr.split('.');
18683
- var beforeDecimal = parts[0].replace(/^0+/, '') || '0';
18684
- var afterDecimal = parts[1] || '';
18685
- return ("" + (isNegative ? '-' : '') + beforeDecimal + (afterDecimal ? ("." + afterDecimal) : ''));
18686
- }
18687
- /**
18688
- * limit decimal numbers to given scale
18689
- * Not used .fixedTo because that will break with big numbers
18690
- */
18691
- function limitToScale(numStr, scale, fixedDecimalScale) {
18692
- var str = '';
18693
- var filler = fixedDecimalScale ? '0' : '';
18694
- for (var i = 0; i <= scale - 1; i++) {
18695
- str += numStr[i] || filler;
18696
- }
18697
- return str;
18698
- }
18699
- function repeat(str, count) {
18700
- return Array(count + 1).join(str);
18701
- }
18702
- function toNumericString(num) {
18703
- var _num = num + ''; // typecast number to string
18704
- // store the sign and remove it from the number.
18705
- var sign = _num[0] === '-' ? '-' : '';
18706
- if (sign)
18707
- { _num = _num.substring(1); }
18708
- // split the number into cofficient and exponent
18709
- var ref = _num.split(/[eE]/g);
18710
- var coefficient = ref[0];
18711
- var exponent = ref[1];
18712
- // covert exponent to number;
18713
- exponent = Number(exponent);
18714
- // if there is no exponent part or its 0, return the coffiecient with sign
18715
- if (!exponent)
18716
- { return sign + coefficient; }
18717
- coefficient = coefficient.replace('.', '');
18718
- /**
18719
- * for scientific notation the current decimal index will be after first number (index 0)
18720
- * So effective decimal index will always be 1 + exponent value
18721
- */
18722
- var decimalIndex = 1 + exponent;
18723
- var coffiecientLn = coefficient.length;
18724
- if (decimalIndex < 0) {
18725
- // if decimal index is less then 0 add preceding 0s
18726
- // add 1 as join will have
18727
- coefficient = '0.' + repeat('0', Math.abs(decimalIndex)) + coefficient;
18728
- }
18729
- else if (decimalIndex >= coffiecientLn) {
18730
- // if decimal index is less then 0 add leading 0s
18731
- coefficient = coefficient + repeat('0', decimalIndex - coffiecientLn);
18732
- }
18733
- else {
18734
- // else add decimal point at proper index
18735
- coefficient =
18736
- (coefficient.substring(0, decimalIndex) || '0') + '.' + coefficient.substring(decimalIndex);
18737
- }
18738
- return sign + coefficient;
18739
- }
18740
- /**
18741
- * This method is required to round prop value to given scale.
18742
- * Not used .round or .fixedTo because that will break with big numbers
18743
- */
18744
- function roundToPrecision(numStr, scale, fixedDecimalScale) {
18745
- //if number is empty don't do anything return empty string
18746
- if (['', '-'].indexOf(numStr) !== -1)
18747
- { return numStr; }
18748
- var shouldHaveDecimalSeparator = (numStr.indexOf('.') !== -1 || fixedDecimalScale) && scale;
18749
- var ref = splitDecimal(numStr);
18750
- var beforeDecimal = ref.beforeDecimal;
18751
- var afterDecimal = ref.afterDecimal;
18752
- var hasNegation = ref.hasNegation;
18753
- var floatValue = parseFloat(("0." + (afterDecimal || '0')));
18754
- var floatValueStr = afterDecimal.length <= scale ? ("0." + afterDecimal) : floatValue.toFixed(scale);
18755
- var roundedDecimalParts = floatValueStr.split('.');
18756
- var intPart = beforeDecimal
18757
- .split('')
18758
- .reverse()
18759
- .reduce(function (roundedStr, current, idx) {
18760
- if (roundedStr.length > idx) {
18761
- return ((Number(roundedStr[0]) + Number(current)).toString() +
18762
- roundedStr.substring(1, roundedStr.length));
18763
- }
18764
- return current + roundedStr;
18765
- }, roundedDecimalParts[0]);
18766
- var decimalPart = limitToScale(roundedDecimalParts[1] || '', scale, fixedDecimalScale);
18767
- var negation = hasNegation ? '-' : '';
18768
- var decimalSeparator = shouldHaveDecimalSeparator ? '.' : '';
18769
- return ("" + negation + intPart + decimalSeparator + decimalPart);
18770
- }
18771
- /** set the caret positon in an input field **/
18772
- function setCaretPosition(el, caretPos) {
18773
- el.value = el.value;
18774
- // ^ this is used to not only get 'focus', but
18775
- // to make sure we don't have it everything -selected-
18776
- // (it causes an issue in chrome, and having it doesn't hurt any other browser)
18777
- if (el !== null) {
18778
- /* @ts-ignore */
18779
- if (el.createTextRange) {
18780
- /* @ts-ignore */
18781
- var range = el.createTextRange();
18782
- range.move('character', caretPos);
18783
- range.select();
18784
- return true;
18785
- }
18786
- // (el.selectionStart === 0 added for Firefox bug)
18787
- if (el.selectionStart || el.selectionStart === 0) {
18788
- el.focus();
18789
- el.setSelectionRange(caretPos, caretPos);
18790
- return true;
18791
- }
18792
- // fail city, fortunately this never happens (as far as I've tested) :)
18793
- el.focus();
18794
- return false;
18795
- }
18796
- }
18797
- function findChangeRange(prevValue, newValue) {
18798
- var i = 0, j = 0;
18799
- var prevLength = prevValue.length;
18800
- var newLength = newValue.length;
18801
- while (prevValue[i] === newValue[i] && i < prevLength)
18802
- { i++; }
18803
- //check what has been changed from last
18804
- while (prevValue[prevLength - 1 - j] === newValue[newLength - 1 - j] &&
18805
- newLength - j > i &&
18806
- prevLength - j > i) {
18807
- j++;
18808
- }
18809
- return {
18810
- from: { start: i, end: prevLength - j },
18811
- to: { start: i, end: newLength - j },
18812
- };
18813
- }
18814
- /*
18815
- Returns a number whose value is limited to the given range
18816
- */
18817
- function clamp(num, min, max) {
18818
- return Math.min(Math.max(num, min), max);
18819
- }
18820
- function geInputCaretPosition(el) {
18821
- /*Max of selectionStart and selectionEnd is taken for the patch of pixel and other mobile device caret bug*/
18822
- return Math.max(el.selectionStart, el.selectionEnd);
18823
- }
18824
- function addInputMode() {
18825
- return (typeof navigator !== 'undefined' &&
18826
- !(navigator.platform && /iPhone|iPod/.test(navigator.platform)));
18827
- }
18828
- function getDefaultChangeMeta(value) {
18829
- return {
18830
- from: {
18831
- start: 0,
18832
- end: 0,
18833
- },
18834
- to: {
18835
- start: 0,
18836
- end: value.length,
18837
- },
18838
- lastValue: '',
18839
- };
18840
- }
18841
- function getCaretPosition(newFormattedValue, lastFormattedValue, curValue, curCaretPos, boundary, isValidInputCharacter) {
18842
- /**
18843
- * if something got inserted on empty value, add the formatted character before the current value,
18844
- * This is to avoid the case where typed character is present on format characters
18845
- */
18846
- var firstAllowedPosition = boundary.findIndex(function (b) { return b; });
18847
- var prefixFormat = newFormattedValue.slice(0, firstAllowedPosition);
18848
- if (!lastFormattedValue && !curValue.startsWith(prefixFormat)) {
18849
- curValue = prefixFormat + curValue;
18850
- curCaretPos = curCaretPos + prefixFormat.length;
18851
- }
18852
- var curValLn = curValue.length;
18853
- var formattedValueLn = newFormattedValue.length;
18854
- // create index map
18855
- var addedIndexMap = {};
18856
- var indexMap = new Array(curValLn);
18857
- for (var i = 0; i < curValLn; i++) {
18858
- indexMap[i] = -1;
18859
- for (var j = 0, jLn = formattedValueLn; j < jLn; j++) {
18860
- if (curValue[i] === newFormattedValue[j] && addedIndexMap[j] !== true) {
18861
- indexMap[i] = j;
18862
- addedIndexMap[j] = true;
18863
- break;
18864
- }
18865
- }
18866
- }
18867
- /**
18868
- * For current caret position find closest characters (left and right side)
18869
- * which are properly mapped to formatted value.
18870
- * The idea is that the new caret position will exist always in the boundary of
18871
- * that mapped index
18872
- */
18873
- var pos = curCaretPos;
18874
- while (pos < curValLn && (indexMap[pos] === -1 || !isValidInputCharacter(curValue[pos]))) {
18875
- pos++;
18876
- }
18877
- // if the caret position is on last keep the endIndex as last for formatted value
18878
- var endIndex = pos === curValLn || indexMap[pos] === -1 ? formattedValueLn : indexMap[pos];
18879
- pos = curCaretPos - 1;
18880
- while (pos > 0 && indexMap[pos] === -1)
18881
- { pos--; }
18882
- var startIndex = pos === -1 || indexMap[pos] === -1 ? 0 : indexMap[pos] + 1;
18883
- /**
18884
- * case where a char is added on suffix and removed from middle, example 2sq345 becoming $2,345 sq
18885
- * there is still a mapping but the order of start index and end index is changed
18886
- */
18887
- if (startIndex > endIndex)
18888
- { return endIndex; }
18889
- /**
18890
- * given the current caret position if it closer to startIndex
18891
- * keep the new caret position on start index or keep it closer to endIndex
18892
- */
18893
- return curCaretPos - startIndex < endIndex - curCaretPos ? startIndex : endIndex;
18894
- }
18895
- /* This keeps the caret within typing area so people can't type in between prefix or suffix or format characters */
18896
- function getCaretPosInBoundary(value, caretPos, boundary, direction) {
18897
- var valLn = value.length;
18898
- // clamp caret position to [0, value.length]
18899
- caretPos = clamp(caretPos, 0, valLn);
18900
- if (direction === 'left') {
18901
- while (caretPos >= 0 && !boundary[caretPos])
18902
- { caretPos--; }
18903
- // if we don't find any suitable caret position on left, set it on first allowed position
18904
- if (caretPos === -1)
18905
- { caretPos = boundary.indexOf(true); }
18906
- }
18907
- else {
18908
- while (caretPos <= valLn && !boundary[caretPos])
18909
- { caretPos++; }
18910
- // if we don't find any suitable caret position on right, set it on last allowed position
18911
- if (caretPos > valLn)
18912
- { caretPos = boundary.lastIndexOf(true); }
18913
- }
18914
- // if we still don't find caret position, set it at the end of value
18915
- if (caretPos === -1)
18916
- { caretPos = valLn; }
18917
- return caretPos;
18918
- }
18919
- function caretUnknownFormatBoundary(formattedValue) {
18920
- var boundaryAry = Array.from({ length: formattedValue.length + 1 }).map(function () { return true; });
18921
- for (var i = 0, ln = boundaryAry.length; i < ln; i++) {
18922
- // consider caret to be in boundary if it is before or after numeric value
18923
- boundaryAry[i] = Boolean(charIsNumber(formattedValue[i]) || charIsNumber(formattedValue[i - 1]));
18924
- }
18925
- return boundaryAry;
18926
- }
18927
- function useInternalValues(value, defaultValue, valueIsNumericString, format, removeFormatting, onValueChange) {
18928
- if ( onValueChange === void 0 ) onValueChange = noop;
18929
-
18930
- var propValues = useRef();
18931
- var getValues = usePersistentCallback(function (value) {
18932
- var formattedValue, numAsString;
18933
- if (isNil(value) || isNanValue(value)) {
18934
- numAsString = '';
18935
- formattedValue = '';
18936
- }
18937
- else if (typeof value === 'number' || valueIsNumericString) {
18938
- numAsString = typeof value === 'number' ? toNumericString(value) : value;
18939
- formattedValue = format(numAsString);
18940
- }
18941
- else {
18942
- numAsString = removeFormatting(value, undefined);
18943
- formattedValue = value;
18944
- }
18945
- return { formattedValue: formattedValue, numAsString: numAsString };
18946
- });
18947
- var ref = useState(function () {
18948
- return getValues(defaultValue);
18949
- });
18950
- var values = ref[0];
18951
- var setValues = ref[1];
18952
- var _onValueChange = function (values, sourceInfo) {
18953
- setValues({
18954
- formattedValue: values.formattedValue,
18955
- numAsString: values.value,
18956
- });
18957
- onValueChange(values, sourceInfo);
18958
- };
18959
- useMemo(function () {
18960
- //if element is moved to uncontrolled mode, don't reset the value
18961
- if (!isNil(value)) {
18962
- propValues.current = getValues(value);
18963
- setValues(propValues.current);
18964
- }
18965
- else {
18966
- propValues.current = undefined;
18967
- }
18968
- }, [value, getValues]);
18969
- return [values, _onValueChange];
18970
- }
18971
-
18972
- function defaultRemoveFormatting(value) {
18973
- return value.replace(/[^0-9]/g, '');
18974
- }
18975
- function defaultFormat(value) {
18976
- return value;
18977
- }
18978
- function NumberFormatBase(props) {
18979
- var type = props.type; if ( type === void 0 ) type = 'text';
18980
- var displayType = props.displayType; if ( displayType === void 0 ) displayType = 'input';
18981
- var customInput = props.customInput;
18982
- var renderText = props.renderText;
18983
- var getInputRef = props.getInputRef;
18984
- var format = props.format; if ( format === void 0 ) format = defaultFormat;
18985
- var removeFormatting = props.removeFormatting; if ( removeFormatting === void 0 ) removeFormatting = defaultRemoveFormatting;
18986
- var defaultValue = props.defaultValue;
18987
- var valueIsNumericString = props.valueIsNumericString;
18988
- var onValueChange = props.onValueChange;
18989
- var isAllowed = props.isAllowed;
18990
- var onChange = props.onChange; if ( onChange === void 0 ) onChange = noop;
18991
- var onKeyDown = props.onKeyDown; if ( onKeyDown === void 0 ) onKeyDown = noop;
18992
- var onMouseUp = props.onMouseUp; if ( onMouseUp === void 0 ) onMouseUp = noop;
18993
- var onFocus = props.onFocus; if ( onFocus === void 0 ) onFocus = noop;
18994
- var onBlur = props.onBlur; if ( onBlur === void 0 ) onBlur = noop;
18995
- var propValue = props.value;
18996
- var getCaretBoundary = props.getCaretBoundary; if ( getCaretBoundary === void 0 ) getCaretBoundary = caretUnknownFormatBoundary;
18997
- var isValidInputCharacter = props.isValidInputCharacter; if ( isValidInputCharacter === void 0 ) isValidInputCharacter = charIsNumber;
18998
- var otherProps = __rest(props, ["type", "displayType", "customInput", "renderText", "getInputRef", "format", "removeFormatting", "defaultValue", "valueIsNumericString", "onValueChange", "isAllowed", "onChange", "onKeyDown", "onMouseUp", "onFocus", "onBlur", "value", "getCaretBoundary", "isValidInputCharacter"]);
18999
- var ref = useInternalValues(propValue, defaultValue, Boolean(valueIsNumericString), format, removeFormatting, onValueChange);
19000
- var ref_0 = ref[0];
19001
- var formattedValue = ref_0.formattedValue;
19002
- var numAsString = ref_0.numAsString;
19003
- var onFormattedValueChange = ref[1];
19004
- var lastUpdatedValue = useRef();
19005
- var _onValueChange = function (values, source) {
19006
- lastUpdatedValue.current = values.formattedValue;
19007
- onFormattedValueChange(values, source);
19008
- };
19009
- // check if there is any change in the value due to props change
19010
- useEffect(function () {
19011
- var newFormattedValue = format(numAsString);
19012
- // if the formatted value is not synced to parent, or if the formatted value is different
19013
- if (lastUpdatedValue.current === undefined || newFormattedValue !== lastUpdatedValue.current) {
19014
- var input = focusedElm.current;
19015
- // formatting can remove some of the number chars, so we need to fine number string again
19016
- var _numAsString = removeFormatting(newFormattedValue, undefined);
19017
- updateValue({
19018
- formattedValue: newFormattedValue,
19019
- numAsString: _numAsString,
19020
- input: input,
19021
- setCaretPosition: true,
19022
- source: SourceType.props,
19023
- event: undefined,
19024
- });
19025
- }
19026
- });
19027
- var ref$1 = useState(false);
19028
- var mounted = ref$1[0];
19029
- var setMounted = ref$1[1];
19030
- var focusedElm = useRef(null);
19031
- var timeout = useRef({
19032
- setCaretTimeout: null,
19033
- focusTimeout: null,
19034
- });
19035
- useEffect(function () {
19036
- setMounted(true);
19037
- return function () {
19038
- clearTimeout(timeout.current.setCaretTimeout);
19039
- clearTimeout(timeout.current.focusTimeout);
19040
- };
19041
- }, []);
19042
- var _format = format;
19043
- var getValueObject = function (formattedValue, numAsString) {
19044
- var floatValue = parseFloat(numAsString);
19045
- return {
19046
- formattedValue: formattedValue,
19047
- value: numAsString,
19048
- floatValue: isNaN(floatValue) ? undefined : floatValue,
19049
- };
19050
- };
19051
- var setPatchedCaretPosition = function (el, caretPos, currentValue) {
19052
- /* setting caret position within timeout of 0ms is required for mobile chrome,
19053
- otherwise browser resets the caret position after we set it
19054
- We are also setting it without timeout so that in normal browser we don't see the flickering */
19055
- setCaretPosition(el, caretPos);
19056
- timeout.current.setCaretTimeout = setTimeout(function () {
19057
- if (el.value === currentValue)
19058
- { setCaretPosition(el, caretPos); }
19059
- }, 0);
19060
- };
19061
- /* This keeps the caret within typing area so people can't type in between prefix or suffix */
19062
- var correctCaretPosition = function (value, caretPos, direction) {
19063
- return getCaretPosInBoundary(value, caretPos, getCaretBoundary(value), direction);
19064
- };
19065
- var getNewCaretPosition = function (inputValue, newFormattedValue, caretPos) {
19066
- var caretBoundary = getCaretBoundary(newFormattedValue);
19067
- var updatedCaretPos = getCaretPosition(newFormattedValue, formattedValue, inputValue, caretPos, caretBoundary, isValidInputCharacter);
19068
- //correct caret position if its outside of editable area
19069
- updatedCaretPos = getCaretPosInBoundary(newFormattedValue, updatedCaretPos, caretBoundary);
19070
- return updatedCaretPos;
19071
- };
19072
- var updateValue = function (params) {
19073
- var newFormattedValue = params.formattedValue; if ( newFormattedValue === void 0 ) newFormattedValue = '';
19074
- var input = params.input;
19075
- var setCaretPosition = params.setCaretPosition; if ( setCaretPosition === void 0 ) setCaretPosition = true;
19076
- var source = params.source;
19077
- var event = params.event;
19078
- var numAsString = params.numAsString;
19079
- var caretPos = params.caretPos;
19080
- if (input) {
19081
- //calculate caret position if not defined
19082
- if (caretPos === undefined && setCaretPosition) {
19083
- var inputValue = params.inputValue || input.value;
19084
- var currentCaretPosition = geInputCaretPosition(input);
19085
- /**
19086
- * set the value imperatively, this is required for IE fix
19087
- * This is also required as if new caret position is beyond the previous value.
19088
- * Caret position will not be set correctly
19089
- */
19090
- input.value = newFormattedValue;
19091
- //get the caret position
19092
- caretPos = getNewCaretPosition(inputValue, newFormattedValue, currentCaretPosition);
19093
- }
19094
- /**
19095
- * set the value imperatively, as we set the caret position as well imperatively.
19096
- * This is to keep value and caret position in sync
19097
- */
19098
- input.value = newFormattedValue;
19099
- //set caret position, and value imperatively when element is provided
19100
- if (setCaretPosition && caretPos !== undefined) {
19101
- //set caret position
19102
- setPatchedCaretPosition(input, caretPos, newFormattedValue);
19103
- }
19104
- }
19105
- if (newFormattedValue !== formattedValue) {
19106
- // trigger onValueChange synchronously, so parent is updated along with the number format. Fix for #277, #287
19107
- _onValueChange(getValueObject(newFormattedValue, numAsString), { event: event, source: source });
19108
- }
19109
- };
19110
- var formatInputValue = function (inputValue, event, source) {
19111
- var changeRange = findChangeRange(formattedValue, inputValue);
19112
- var changeMeta = Object.assign(Object.assign({}, changeRange), { lastValue: formattedValue });
19113
- var _numAsString = removeFormatting(inputValue, changeMeta);
19114
- var _formattedValue = _format(_numAsString);
19115
- // formatting can remove some of the number chars, so we need to fine number string again
19116
- _numAsString = removeFormatting(_formattedValue, undefined);
19117
- if (isAllowed && !isAllowed(getValueObject(_formattedValue, _numAsString))) {
19118
- //reset the caret position
19119
- var input = event.target;
19120
- var currentCaretPosition = geInputCaretPosition(input);
19121
- var caretPos = getNewCaretPosition(inputValue, formattedValue, currentCaretPosition);
19122
- setPatchedCaretPosition(input, caretPos, formattedValue);
19123
- return false;
19124
- }
19125
- updateValue({
19126
- formattedValue: _formattedValue,
19127
- numAsString: _numAsString,
19128
- inputValue: inputValue,
19129
- event: event,
19130
- source: source,
19131
- setCaretPosition: true,
19132
- input: event.target,
19133
- });
19134
- return true;
19135
- };
19136
- var _onChange = function (e) {
19137
- var el = e.target;
19138
- var inputValue = el.value;
19139
- var changed = formatInputValue(inputValue, e, SourceType.event);
19140
- if (changed)
19141
- { onChange(e); }
19142
- };
19143
- var _onKeyDown = function (e) {
19144
- var el = e.target;
19145
- var key = e.key;
19146
- var selectionStart = el.selectionStart;
19147
- var selectionEnd = el.selectionEnd;
19148
- var value = el.value; if ( value === void 0 ) value = '';
19149
- var expectedCaretPosition;
19150
- //Handle backspace and delete against non numerical/decimal characters or arrow keys
19151
- if (key === 'ArrowLeft' || key === 'Backspace') {
19152
- expectedCaretPosition = Math.max(selectionStart - 1, 0);
19153
- }
19154
- else if (key === 'ArrowRight') {
19155
- expectedCaretPosition = Math.min(selectionStart + 1, value.length);
19156
- }
19157
- else if (key === 'Delete') {
19158
- expectedCaretPosition = selectionStart;
19159
- }
19160
- //if expectedCaretPosition is not set it means we don't want to Handle keyDown
19161
- // also if multiple characters are selected don't handle
19162
- if (expectedCaretPosition === undefined || selectionStart !== selectionEnd) {
19163
- onKeyDown(e);
19164
- return;
19165
- }
19166
- var newCaretPosition = expectedCaretPosition;
19167
- if (key === 'ArrowLeft' || key === 'ArrowRight') {
19168
- var direction = key === 'ArrowLeft' ? 'left' : 'right';
19169
- newCaretPosition = correctCaretPosition(value, expectedCaretPosition, direction);
19170
- }
19171
- else if (key === 'Delete' && !isValidInputCharacter(value[expectedCaretPosition])) {
19172
- // in case of delete go to closest caret boundary on the right side
19173
- newCaretPosition = correctCaretPosition(value, expectedCaretPosition, 'right');
19174
- }
19175
- else if (key === 'Backspace' && !isValidInputCharacter(value[expectedCaretPosition])) {
19176
- // in case of backspace go to closest caret boundary on the left side
19177
- newCaretPosition = correctCaretPosition(value, expectedCaretPosition, 'left');
19178
- }
19179
- if (newCaretPosition !== expectedCaretPosition) {
19180
- setPatchedCaretPosition(el, newCaretPosition, value);
19181
- }
19182
- /* NOTE: this is just required for unit test as we need to get the newCaretPosition,
19183
- Remove this when you find different solution */
19184
- /* @ts-ignore */
19185
- if (e.isUnitTestRun) {
19186
- setPatchedCaretPosition(el, newCaretPosition, value);
19187
- }
19188
- onKeyDown(e);
19189
- };
19190
- /** required to handle the caret position when click anywhere within the input **/
19191
- var _onMouseUp = function (e) {
19192
- var el = e.target;
19193
- /**
19194
- * NOTE: we have to give default value for value as in case when custom input is provided
19195
- * value can come as undefined when nothing is provided on value prop.
19196
- */
19197
- var selectionStart = el.selectionStart;
19198
- var selectionEnd = el.selectionEnd;
19199
- var value = el.value; if ( value === void 0 ) value = '';
19200
- if (selectionStart === selectionEnd) {
19201
- var caretPosition = correctCaretPosition(value, selectionStart);
19202
- if (caretPosition !== selectionStart) {
19203
- setPatchedCaretPosition(el, caretPosition, value);
19204
- }
19205
- }
19206
- onMouseUp(e);
19207
- };
19208
- var _onFocus = function (e) {
19209
- // Workaround Chrome and Safari bug https://bugs.chromium.org/p/chromium/issues/detail?id=779328
19210
- // (onFocus event target selectionStart is always 0 before setTimeout)
19211
- if (e.persist)
19212
- { e.persist(); }
19213
- var el = e.target;
19214
- focusedElm.current = el;
19215
- timeout.current.focusTimeout = setTimeout(function () {
19216
- var selectionStart = el.selectionStart;
19217
- var selectionEnd = el.selectionEnd;
19218
- var value = el.value; if ( value === void 0 ) value = '';
19219
- var caretPosition = correctCaretPosition(value, selectionStart);
19220
- //setPatchedCaretPosition only when everything is not selected on focus (while tabbing into the field)
19221
- if (caretPosition !== selectionStart &&
19222
- !(selectionStart === 0 && selectionEnd === value.length)) {
19223
- setPatchedCaretPosition(el, caretPosition, value);
19224
- }
19225
- onFocus(e);
19226
- }, 0);
19227
- };
19228
- var _onBlur = function (e) {
19229
- focusedElm.current = null;
19230
- clearTimeout(timeout.current.focusTimeout);
19231
- clearTimeout(timeout.current.setCaretTimeout);
19232
- onBlur(e);
19233
- };
19234
- // add input mode on element based on format prop and device once the component is mounted
19235
- var inputMode = mounted && addInputMode() ? 'numeric' : undefined;
19236
- var inputProps = Object.assign({ inputMode: inputMode }, otherProps, {
19237
- type: type,
19238
- value: formattedValue,
19239
- onChange: _onChange,
19240
- onKeyDown: _onKeyDown,
19241
- onMouseUp: _onMouseUp,
19242
- onFocus: _onFocus,
19243
- onBlur: _onBlur,
19244
- });
19245
- if (displayType === 'text') {
19246
- return renderText ? (React.createElement(React.Fragment, null, renderText(formattedValue, otherProps) || null)) : (React.createElement("span", Object.assign({}, otherProps, { ref: getInputRef }), formattedValue));
19247
- }
19248
- else if (customInput) {
19249
- var CustomInput = customInput;
19250
- /* @ts-ignore */
19251
- return React.createElement(CustomInput, Object.assign({}, inputProps, { ref: getInputRef }));
19252
- }
19253
- return React.createElement("input", Object.assign({}, inputProps, { ref: getInputRef }));
19254
- }
19255
-
19256
- function format(numStr, props) {
19257
- var decimalScale = props.decimalScale;
19258
- var fixedDecimalScale = props.fixedDecimalScale;
19259
- var prefix = props.prefix; if ( prefix === void 0 ) prefix = '';
19260
- var suffix = props.suffix; if ( suffix === void 0 ) suffix = '';
19261
- var allowNegative = props.allowNegative; if ( allowNegative === void 0 ) allowNegative = true;
19262
- var thousandsGroupStyle = props.thousandsGroupStyle; if ( thousandsGroupStyle === void 0 ) thousandsGroupStyle = 'thousand';
19263
- // don't apply formatting on empty string or '-'
19264
- if (numStr === '' || numStr === '-') {
19265
- return numStr;
19266
- }
19267
- var ref = getSeparators(props);
19268
- var thousandSeparator = ref.thousandSeparator;
19269
- var decimalSeparator = ref.decimalSeparator;
19270
- /**
19271
- * Keep the decimal separator
19272
- * when decimalScale is not defined or non zero and the numStr has decimal in it
19273
- * Or if decimalScale is > 0 and fixeDecimalScale is true (even if numStr has no decimal)
19274
- */
19275
- var hasDecimalSeparator = (decimalScale !== 0 && numStr.indexOf('.') !== -1) || (decimalScale && fixedDecimalScale);
19276
- var ref$1 = splitDecimal(numStr, allowNegative);
19277
- var beforeDecimal = ref$1.beforeDecimal;
19278
- var afterDecimal = ref$1.afterDecimal;
19279
- var addNegation = ref$1.addNegation; // eslint-disable-line prefer-const
19280
- //apply decimal precision if its defined
19281
- if (decimalScale !== undefined) {
19282
- afterDecimal = limitToScale(afterDecimal, decimalScale, !!fixedDecimalScale);
19283
- }
19284
- if (thousandSeparator) {
19285
- beforeDecimal = applyThousandSeparator(beforeDecimal, thousandSeparator, thousandsGroupStyle);
19286
- }
19287
- //add prefix and suffix when there is a number present
19288
- if (prefix)
19289
- { beforeDecimal = prefix + beforeDecimal; }
19290
- if (suffix)
19291
- { afterDecimal = afterDecimal + suffix; }
19292
- //restore negation sign
19293
- if (addNegation)
19294
- { beforeDecimal = '-' + beforeDecimal; }
19295
- numStr = beforeDecimal + ((hasDecimalSeparator && decimalSeparator) || '') + afterDecimal;
19296
- return numStr;
19297
- }
19298
- function getSeparators(props) {
19299
- var decimalSeparator = props.decimalSeparator; if ( decimalSeparator === void 0 ) decimalSeparator = '.';
19300
- var thousandSeparator = props.thousandSeparator;
19301
- var allowedDecimalSeparators = props.allowedDecimalSeparators;
19302
- if (thousandSeparator === true) {
19303
- thousandSeparator = ',';
19304
- }
19305
- if (!allowedDecimalSeparators) {
19306
- allowedDecimalSeparators = [decimalSeparator, '.'];
19307
- }
19308
- return {
19309
- decimalSeparator: decimalSeparator,
19310
- thousandSeparator: thousandSeparator,
19311
- allowedDecimalSeparators: allowedDecimalSeparators,
19312
- };
19313
- }
19314
- function handleNegation(value, allowNegative) {
19315
- if ( value === void 0 ) value = '';
19316
-
19317
- var negationRegex = new RegExp('(-)');
19318
- var doubleNegationRegex = new RegExp('(-)(.)*(-)');
19319
- // Check number has '-' value
19320
- var hasNegation = negationRegex.test(value);
19321
- // Check number has 2 or more '-' values
19322
- var removeNegation = doubleNegationRegex.test(value);
19323
- //remove negation
19324
- value = value.replace(/-/g, '');
19325
- if (hasNegation && !removeNegation && allowNegative) {
19326
- value = '-' + value;
19327
- }
19328
- return value;
19329
- }
19330
- function getNumberRegex(decimalSeparator, global) {
19331
- return new RegExp(("(^-)|[0-9]|" + (escapeRegExp(decimalSeparator))), global ? 'g' : undefined);
19332
- }
19333
- function removeFormatting(value, changeMeta, props) {
19334
- if ( changeMeta === void 0 ) changeMeta = getDefaultChangeMeta(value);
19335
-
19336
- var allowNegative = props.allowNegative; if ( allowNegative === void 0 ) allowNegative = true;
19337
- var prefix = props.prefix; if ( prefix === void 0 ) prefix = '';
19338
- var suffix = props.suffix; if ( suffix === void 0 ) suffix = '';
19339
- var decimalScale = props.decimalScale;
19340
- var from = changeMeta.from;
19341
- var to = changeMeta.to;
19342
- var start = to.start;
19343
- var end = to.end;
19344
- var ref = getSeparators(props);
19345
- var allowedDecimalSeparators = ref.allowedDecimalSeparators;
19346
- var decimalSeparator = ref.decimalSeparator;
19347
- var isBeforeDecimalSeparator = value[end] === decimalSeparator;
19348
- /** Check for any allowed decimal separator is added in the numeric format and replace it with decimal separator */
19349
- if (end - start === 1 && allowedDecimalSeparators.indexOf(value[start]) !== -1) {
19350
- var separator = decimalScale === 0 ? '' : decimalSeparator;
19351
- value = value.substring(0, start) + separator + value.substring(start + 1, value.length);
19352
- }
19353
- var hasNegation = false;
19354
- /**
19355
- * if prefix starts with - the number hast to have two - at the start
19356
- * if suffix starts with - and the value length is same as suffix length, then the - sign is from the suffix
19357
- * In other cases, if the value starts with - then it is a negation
19358
- */
19359
- if (prefix.startsWith('-'))
19360
- { hasNegation = value.startsWith('--'); }
19361
- else if (suffix.startsWith('-') && value.length === suffix.length)
19362
- { hasNegation = false; }
19363
- else if (value[0] === '-')
19364
- { hasNegation = true; }
19365
- // remove negation from start to simplify prefix logic as negation comes before prefix
19366
- if (hasNegation) {
19367
- value = value.substring(1);
19368
- // account for the removal of the negation for start and end index
19369
- start -= 1;
19370
- end -= 1;
19371
- }
19372
- /**
19373
- * remove prefix
19374
- * Remove whole prefix part if its present on the value
19375
- * If the prefix is partially deleted (in which case change start index will be less the prefix length)
19376
- * Remove only partial part of prefix.
19377
- */
19378
- var startIndex = 0;
19379
- if (value.startsWith(prefix))
19380
- { startIndex += prefix.length; }
19381
- else if (start < prefix.length)
19382
- { startIndex = start; }
19383
- value = value.substring(startIndex);
19384
- // account for deleted prefix for end index
19385
- end -= startIndex;
19386
- /**
19387
- * Remove suffix
19388
- * Remove whole suffix part if its present on the value
19389
- * If the suffix is partially deleted (in which case change end index will be greater than the suffixStartIndex)
19390
- * remove the partial part of suffix
19391
- */
19392
- var endIndex = value.length;
19393
- var suffixStartIndex = value.length - suffix.length;
19394
- if (value.endsWith(suffix))
19395
- { endIndex = suffixStartIndex; }
19396
- else if (end > value.length - suffix.length)
19397
- { endIndex = end; }
19398
- value = value.substring(0, endIndex);
19399
- // add the negation back and handle for double negation
19400
- value = handleNegation(hasNegation ? ("-" + value) : value, allowNegative);
19401
- // remove non numeric characters
19402
- value = (value.match(getNumberRegex(decimalSeparator, true)) || []).join('');
19403
- // replace the decimalSeparator with ., and only keep the first separator, ignore following ones
19404
- var firstIndex = value.indexOf(decimalSeparator);
19405
- value = value.replace(new RegExp(escapeRegExp(decimalSeparator), 'g'), function (match, index) {
19406
- return index === firstIndex ? '.' : '';
19407
- });
19408
- //check if beforeDecimal got deleted and there is nothing after decimal,
19409
- //clear all numbers in such case while keeping the - sign
19410
- var ref$1 = splitDecimal(value, allowNegative);
19411
- var beforeDecimal = ref$1.beforeDecimal;
19412
- var afterDecimal = ref$1.afterDecimal;
19413
- var addNegation = ref$1.addNegation; // eslint-disable-line prefer-const
19414
- //clear only if something got deleted before decimal (cursor is before decimal)
19415
- if (to.end - to.start < from.end - from.start &&
19416
- beforeDecimal === '' &&
19417
- isBeforeDecimalSeparator &&
19418
- !parseFloat(afterDecimal)) {
19419
- value = addNegation ? '-' : '';
19420
- }
19421
- return value;
19422
- }
19423
- function getCaretBoundary(formattedValue, props) {
19424
- var prefix = props.prefix; if ( prefix === void 0 ) prefix = '';
19425
- var suffix = props.suffix; if ( suffix === void 0 ) suffix = '';
19426
- var boundaryAry = Array.from({ length: formattedValue.length + 1 }).map(function () { return true; });
19427
- var hasNegation = formattedValue[0] === '-';
19428
- // fill for prefix and negation
19429
- boundaryAry.fill(false, 0, prefix.length + (hasNegation ? 1 : 0));
19430
- // fill for suffix
19431
- var valLn = formattedValue.length;
19432
- boundaryAry.fill(false, valLn - suffix.length + 1, valLn + 1);
19433
- return boundaryAry;
19434
- }
19435
- function validateProps(props) {
19436
- var ref = getSeparators(props);
19437
- var thousandSeparator = ref.thousandSeparator;
19438
- var decimalSeparator = ref.decimalSeparator;
19439
- if (thousandSeparator === decimalSeparator) {
19440
- 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 "));
19441
- }
19442
- }
19443
- function useNumericFormat(props) {
19444
- var decimalSeparator = props.decimalSeparator; if ( decimalSeparator === void 0 ) decimalSeparator = '.';
19445
- var allowLeadingZeros = props.allowLeadingZeros;
19446
- var onKeyDown = props.onKeyDown; if ( onKeyDown === void 0 ) onKeyDown = noop;
19447
- var onBlur = props.onBlur; if ( onBlur === void 0 ) onBlur = noop;
19448
- var thousandSeparator = props.thousandSeparator;
19449
- var decimalScale = props.decimalScale;
19450
- var fixedDecimalScale = props.fixedDecimalScale;
19451
- var prefix = props.prefix; if ( prefix === void 0 ) prefix = '';
19452
- var defaultValue = props.defaultValue;
19453
- var value = props.value;
19454
- var valueIsNumericString = props.valueIsNumericString;
19455
- var onValueChange = props.onValueChange;
19456
- var restProps = __rest(props, ["decimalSeparator", "allowedDecimalSeparators", "thousandsGroupStyle", "suffix", "allowNegative", "allowLeadingZeros", "onKeyDown", "onBlur", "thousandSeparator", "decimalScale", "fixedDecimalScale", "prefix", "defaultValue", "value", "valueIsNumericString", "onValueChange"]);
19457
- // validate props
19458
- validateProps(props);
19459
- var _format = function (numStr) { return format(numStr, props); };
19460
- var _removeFormatting = function (inputValue, changeMeta) { return removeFormatting(inputValue, changeMeta, props); };
19461
- var _valueIsNumericString = valueIsNumericString;
19462
- if (!isNil(value)) {
19463
- _valueIsNumericString = valueIsNumericString !== null && valueIsNumericString !== void 0 ? valueIsNumericString : typeof value === 'number';
19464
- }
19465
- else if (!isNil(defaultValue)) {
19466
- _valueIsNumericString = valueIsNumericString !== null && valueIsNumericString !== void 0 ? valueIsNumericString : typeof defaultValue === 'number';
19467
- }
19468
- var roundIncomingValueToPrecision = function (value) {
19469
- if (isNil(value) || isNanValue(value))
19470
- { return value; }
19471
- if (typeof value === 'number') {
19472
- value = toNumericString(value);
19473
- }
19474
- /**
19475
- * only round numeric or float string values coming through props,
19476
- * we don't need to do it for onChange events, as we want to prevent typing there
19477
- */
19478
- if (_valueIsNumericString && typeof decimalScale === 'number') {
19479
- return roundToPrecision(value, decimalScale, Boolean(fixedDecimalScale));
19480
- }
19481
- return value;
19482
- };
19483
- var ref = useInternalValues(roundIncomingValueToPrecision(value), roundIncomingValueToPrecision(defaultValue), Boolean(_valueIsNumericString), _format, _removeFormatting, onValueChange);
19484
- var ref_0 = ref[0];
19485
- var numAsString = ref_0.numAsString;
19486
- var formattedValue = ref_0.formattedValue;
19487
- var _onValueChange = ref[1];
19488
- var _onKeyDown = function (e) {
19489
- var el = e.target;
19490
- var key = e.key;
19491
- var selectionStart = el.selectionStart;
19492
- var selectionEnd = el.selectionEnd;
19493
- var value = el.value; if ( value === void 0 ) value = '';
19494
- // if multiple characters are selected and user hits backspace, no need to handle anything manually
19495
- if (selectionStart !== selectionEnd) {
19496
- onKeyDown(e);
19497
- return;
19498
- }
19499
- // if user hits backspace, while the cursor is before prefix, and the input has negation, remove the negation
19500
- if (key === 'Backspace' && value[0] === '-' && selectionStart === prefix.length + 1) {
19501
- // bring the cursor to after negation
19502
- setCaretPosition(el, 1);
19503
- }
19504
- // don't allow user to delete decimal separator when decimalScale and fixedDecimalScale is set
19505
- var ref = getSeparators(props);
19506
- var decimalSeparator = ref.decimalSeparator;
19507
- var allowedDecimalSeparators = ref.allowedDecimalSeparators;
19508
- if (key === 'Backspace' &&
19509
- value[selectionStart - 1] === decimalSeparator &&
19510
- decimalScale &&
19511
- fixedDecimalScale) {
19512
- setCaretPosition(el, selectionStart - 1);
19513
- e.preventDefault();
19514
- }
19515
- // if user presses the allowed decimal separator before the separator, move the cursor after the separator
19516
- if ((allowedDecimalSeparators === null || allowedDecimalSeparators === void 0 ? void 0 : allowedDecimalSeparators.includes(key)) && value[selectionStart] === decimalSeparator) {
19517
- setCaretPosition(el, selectionStart + 1);
19518
- }
19519
- var _thousandSeparator = thousandSeparator === true ? ',' : thousandSeparator;
19520
- // move cursor when delete or backspace is pressed before/after thousand separator
19521
- if (key === 'Backspace' && value[selectionStart - 1] === _thousandSeparator) {
19522
- setCaretPosition(el, selectionStart - 1);
19523
- }
19524
- if (key === 'Delete' && value[selectionStart] === _thousandSeparator) {
19525
- setCaretPosition(el, selectionStart + 1);
19526
- }
19527
- onKeyDown(e);
19528
- };
19529
- var _onBlur = function (e) {
19530
- var _value = numAsString;
19531
- // if there no no numeric value, clear the input
19532
- if (!_value.match(/\d/g)) {
19533
- _value = '';
19534
- }
19535
- // clear leading 0s
19536
- if (!allowLeadingZeros) {
19537
- _value = fixLeadingZero(_value);
19538
- }
19539
- // apply fixedDecimalScale on blur event
19540
- if (fixedDecimalScale && decimalScale) {
19541
- _value = roundToPrecision(_value, decimalScale, fixedDecimalScale);
19542
- }
19543
- if (_value !== numAsString) {
19544
- var formattedValue = format(_value, props);
19545
- _onValueChange({
19546
- formattedValue: formattedValue,
19547
- value: _value,
19548
- floatValue: parseFloat(_value),
19549
- }, {
19550
- event: e,
19551
- source: SourceType.event,
19552
- });
19553
- }
19554
- onBlur(e);
19555
- };
19556
- var isValidInputCharacter = function (inputChar) {
19557
- if (inputChar === decimalSeparator)
19558
- { return true; }
19559
- return charIsNumber(inputChar);
19560
- };
19561
- 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 });
19562
- }
19563
- function NumericFormat(props) {
19564
- var numericFormatProps = useNumericFormat(props);
19565
- return React.createElement(NumberFormatBase, Object.assign({}, numericFormatProps));
19566
- }
19567
-
19568
19174
  const TextWidgetBase = ({
19569
19175
  id,
19570
19176
  onChange,
@@ -20375,5 +19981,5 @@ const DynamicFormHooks = {
20375
19981
  useReadOnly
20376
19982
  };
20377
19983
 
20378
- 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 };
19984
+ 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 };
20379
19985
  //# sourceMappingURL=index.modern.js.map