@unicef/material-ui 0.8.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/prod.js CHANGED
@@ -11082,6 +11082,65 @@ var debounce = function debounce(func, wait, immediate) {
11082
11082
  return debounced;
11083
11083
  };
11084
11084
 
11085
+ /**
11086
+ *
11087
+ * @param {String} value Value text to be validated
11088
+ * @returns {Boolean} Whether the given value string is a phone number
11089
+ */
11090
+ function isPhoneNumberText(value) {
11091
+ var valueToTest = value || '';
11092
+ var phoneRegexp = new RegExp(/^[0-9.,+-;()\/\extEXT+# ]*$/i);
11093
+ if (!phoneRegexp.test(valueToTest)) {
11094
+ return false;
11095
+ }
11096
+ return true;
11097
+ }
11098
+
11099
+ /**
11100
+ *
11101
+ * @param {String} value Value text to be validated
11102
+ * @returns {Boolean} Whether the given value string contains safe text (no html tags)
11103
+ */
11104
+ function isSafeText(value) {
11105
+ var valueToTest = value || '';
11106
+ var htmlRegexp = new RegExp(/<\/?[a-z][\s\S]*>/i);
11107
+ if (htmlRegexp.test(valueToTest)) {
11108
+ return false;
11109
+ }
11110
+ return true;
11111
+ }
11112
+
11113
+ /**
11114
+ *
11115
+ * @param {String} value Value text to be validated
11116
+ * @returns {Boolean} Whether the given value string is an acceptable alphanumeric text in any language (also spaces are accepted)
11117
+ */
11118
+ function isAlphanumericText(value) {
11119
+ var valueToTest = value || '';
11120
+ // With Unicode Property Escapes, we can match a letter from any language with the following simple regular expression (https://javascript.info/regexp-unicode) => /\p{Letter}/u
11121
+ // Unicode Property Escapes can be transpiled down to ES5 with a tool called regexpu. OR it can be taken from the lib Steve Levithan's XRegExp package with Unicode add-on (https://xregexp.com/plugins/)
11122
+ // The following is transpiled code for all language char with space and numbers
11123
+ // ( taken from https://stackoverflow.com/a/15861883/1874080 with some modifications) :
11124
+
11125
+ var wordsInAllLanguages = /^[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC\ \0|0-9\0|1-9]*$/;
11126
+
11127
+ return wordsInAllLanguages.test(valueToTest);
11128
+ }
11129
+
11130
+ /**
11131
+ *
11132
+ * @param {String} value Value text to be validated
11133
+ * @returns {Boolean} Whether the given value string is an acceptable url
11134
+ */
11135
+ function isUrlText(value) {
11136
+ var valueToTest = value || '';
11137
+ var urlRegexp = new RegExp('^http(s?)://[0-9a-zA-Z]([-.w]*[0-9a-zA-Z])*?[a-z0-9][-a-z0-9]{0,61}[a-z0-9]\\.[a-z]{2,6}(/[\\w\\s-\\w@\\+\\.~#\\?&/=%]*)?$');
11138
+ if (valueToTest && !urlRegexp.test(valueToTest)) {
11139
+ return false;
11140
+ }
11141
+ return true;
11142
+ }
11143
+
11085
11144
  // It should to be noted that this function isn't equivalent to `text-transform: capitalize`.
11086
11145
  //
11087
11146
  // A strict capitalization should uppercase the first letter of each word a the sentence.
@@ -33877,7 +33936,8 @@ function PositiveNumberFormat(_ref) {
33877
33936
  isNumericString = _ref.isNumericString,
33878
33937
  allowNegative = _ref.allowNegative,
33879
33938
  decimalScale = _ref.decimalScale,
33880
- other = objectWithoutProperties(_ref, ['inputRef', 'name', 'onChange', 'thousandSeparator', 'isNumericString', 'allowNegative', 'decimalScale']);
33939
+ fixedDecimalScale = _ref.fixedDecimalScale,
33940
+ other = objectWithoutProperties(_ref, ['inputRef', 'name', 'onChange', 'thousandSeparator', 'isNumericString', 'allowNegative', 'decimalScale', 'fixedDecimalScale']);
33881
33941
 
33882
33942
  return React__default.createElement(NumberFormat, _extends$1({}, other, {
33883
33943
  getInputRef: inputRef,
@@ -33892,7 +33952,8 @@ function PositiveNumberFormat(_ref) {
33892
33952
  thousandSeparator: thousandSeparator,
33893
33953
  isNumericString: isNumericString,
33894
33954
  allowNegative: allowNegative,
33895
- decimalScale: decimalScale
33955
+ decimalScale: decimalScale,
33956
+ fixedDecimalScale: fixedDecimalScale
33896
33957
  }));
33897
33958
  }
33898
33959
 
@@ -33908,14 +33969,17 @@ PositiveNumberFormat.propTypes = {
33908
33969
  // Is allow negative numbers
33909
33970
  allowNegative: PropTypes__default.bool,
33910
33971
  // No of decimal digits
33911
- decimalScale: PropTypes__default.number
33972
+ decimalScale: PropTypes__default.number,
33973
+ //If true it add 0s to match given decimalScale.
33974
+ fixedDecimalScale: PropTypes__default.bool
33912
33975
  };
33913
33976
 
33914
33977
  PositiveNumberFormat.defaultProps = {
33915
33978
  thousandSeparator: true,
33916
33979
  isNumericString: false,
33917
33980
  allowNegative: false,
33918
- decimalScale: 0
33981
+ decimalScale: 0,
33982
+ fixedDecimalScale: false
33919
33983
  };
33920
33984
 
33921
33985
  var HelpOutline = createCommonjsModule(function (module, exports) {
@@ -46296,7 +46360,10 @@ var defaultErrorMessages = {
46296
46360
  allowedExtensions: 'File type not allowed',
46297
46361
  isUrl: 'It should start with http:// or https://',
46298
46362
  isLatitude: 'It should be between -90 and 90',
46299
- isLongitude: 'It should be between -180 and 180'
46363
+ isLongitude: 'It should be between -180 and 180',
46364
+ isPhone: 'Only numbers,(,),-,.,# and (ext) are allowed',
46365
+ isSafeText: 'HTML not allowed',
46366
+ isAlphanumeric: 'Only letters and numbers are allowed'
46300
46367
  };
46301
46368
 
46302
46369
  /* eslint-disable */
@@ -46340,6 +46407,9 @@ var styles$13 = {
46340
46407
  * * isString
46341
46408
  * * maxFileSize
46342
46409
  * * allowedExtensions
46410
+ * * isPhone
46411
+ * * isAlphanumeric
46412
+ * * isSafeText
46343
46413
  *
46344
46414
  * It accepts all the props of Material-ui [TextField](https://material-ui.com/api/text-field/#textfield-api)
46345
46415
  */
@@ -46569,11 +46639,7 @@ function ForwardRefForm(props, ref) {
46569
46639
  };
46570
46640
 
46571
46641
  lib_2.addValidationRule('isUrl', function (value) {
46572
- var urlRegexp = new RegExp('^http(s?)://[0-9a-zA-Z]([-.w]*[0-9a-zA-Z])*?[a-z0-9][-a-z0-9]{0,61}[a-z0-9]\\.[a-z]{2,6}(/[\\w\\s-\\w@\\+\\.~#\\?&/=%]*)?$');
46573
- if (value != '' && !urlRegexp.test(value)) {
46574
- return false;
46575
- }
46576
- return true;
46642
+ return isUrlText(value);
46577
46643
  });
46578
46644
 
46579
46645
  lib_2.addValidationRule('isLatitude', function (value) {
@@ -46589,6 +46655,18 @@ function ForwardRefForm(props, ref) {
46589
46655
  return true;
46590
46656
  });
46591
46657
 
46658
+ lib_2.addValidationRule('isPhone', function (value) {
46659
+ return isPhoneNumberText(value);
46660
+ });
46661
+
46662
+ lib_2.addValidationRule('isSafeText', function (value) {
46663
+ return isSafeText(value);
46664
+ });
46665
+
46666
+ lib_2.addValidationRule('isAlphanumeric', function (value) {
46667
+ return isAlphanumericText(value);
46668
+ });
46669
+
46592
46670
  return React__default.createElement(lib_2, _extends$1({}, props, { ref: ref }));
46593
46671
  }
46594
46672
 
@@ -46901,6 +46979,67 @@ UPositiveInteger.propTypes = {
46901
46979
  withRequiredValidator: PropTypes__default.bool
46902
46980
  };
46903
46981
 
46982
+ function UCurrencyField(_ref) {
46983
+ var inputPrefix = _ref.inputPrefix,
46984
+ decimalScale = _ref.decimalScale,
46985
+ fixedDecimalScale = _ref.fixedDecimalScale,
46986
+ textAlign = _ref.textAlign,
46987
+ inputProps = _ref.inputProps,
46988
+ props = objectWithoutProperties(_ref, ['inputPrefix', 'decimalScale', 'fixedDecimalScale', 'textAlign', 'inputProps']);
46989
+
46990
+ return React__default.createElement(UPositiveInteger, _extends$1({
46991
+ variant: 'outlined',
46992
+ inputProps: _extends$1({
46993
+ decimalScale: decimalScale,
46994
+ fixedDecimalScale: fixedDecimalScale,
46995
+ prefix: inputPrefix,
46996
+ style: { textAlign: textAlign }
46997
+ }, inputProps)
46998
+ }, props));
46999
+ }
47000
+
47001
+ UCurrencyField.propTypes = {
47002
+ /** label */
47003
+ label: PropTypes__default.string,
47004
+ /** placeholder text*/
47005
+ placeholder: PropTypes__default.string,
47006
+ /**
47007
+ * Array of validators.See list of default validators above.
47008
+ *
47009
+ * Ex: `validators={['required', 'isEmail']}`
47010
+ */
47011
+ validators: PropTypes__default.array,
47012
+ /** Attributes applied to the input element. */
47013
+ inputProps: PropTypes__default.object,
47014
+ /** Props applied to the Input element. */
47015
+ InputProps: PropTypes__default.object,
47016
+ /** Prefix string for the input. */
47017
+ inputPrefix: PropTypes__default.string,
47018
+ /** Decimal digit number to be used as default. */
47019
+ decimalScale: PropTypes__default.number,
47020
+ /**
47021
+ * customErrorMessages is an object with key as validator and value as customised error message.
47022
+ *
47023
+ * Ex: `customErrorMessages={{required: 'This field is required'}`
47024
+ */
47025
+ customErrorMessages: PropTypes__default.object,
47026
+ /** To make the content readOnly */
47027
+ readOnly: PropTypes__default.bool,
47028
+ /** Name of input. */
47029
+ name: PropTypes__default.string,
47030
+ /** Input text align */
47031
+ textAlign: PropTypes__default.string,
47032
+ // If true it add 0s to match given decimalScale.
47033
+ fixedDecimalScale: PropTypes__default.bool
47034
+ };
47035
+
47036
+ UCurrencyField.defaultProps = {
47037
+ inputPrefix: '$ ',
47038
+ decimalScale: 2,
47039
+ fixedDecimalScale: true,
47040
+ textAlign: 'right'
47041
+ };
47042
+
46904
47043
  function ActiveFormPositiveInteger(_ref) {
46905
47044
  var InputProps = _ref.InputProps,
46906
47045
  props = objectWithoutProperties(_ref, ['InputProps']);
@@ -46949,6 +47088,75 @@ ActiveFormPositiveInteger.propTypes = {
46949
47088
  withRequiredValidator: PropTypes__default.bool
46950
47089
  };
46951
47090
 
47091
+ function ActiveCurrencyField(_ref) {
47092
+ var inputPrefix = _ref.inputPrefix,
47093
+ decimalScale = _ref.decimalScale,
47094
+ fixedDecimalScale = _ref.fixedDecimalScale,
47095
+ textAlign = _ref.textAlign,
47096
+ inputProps = _ref.inputProps,
47097
+ props = objectWithoutProperties(_ref, ['inputPrefix', 'decimalScale', 'fixedDecimalScale', 'textAlign', 'inputProps']);
47098
+
47099
+ return React__default.createElement(ActiveFormPositiveInteger, _extends$1({
47100
+ variant: 'outlined',
47101
+ inputProps: _extends$1({
47102
+ decimalScale: decimalScale,
47103
+ fixedDecimalScale: fixedDecimalScale,
47104
+ prefix: inputPrefix,
47105
+ style: { textAlign: textAlign }
47106
+ }, inputProps)
47107
+ }, props));
47108
+ }
47109
+
47110
+ ActiveCurrencyField.propTypes = {
47111
+ /** label */
47112
+ label: PropTypes__default.string,
47113
+ /** placeholder text*/
47114
+ placeholder: PropTypes__default.string,
47115
+ /** Typography for text inside the input (Ex: h1, div, etc.) */
47116
+ typographyVariant: PropTypes__default.string,
47117
+ /** Input has some default padding already, to make changes to it pass padding like `inputPadding='0px 2px'` */
47118
+ inputPadding: PropTypes__default.string,
47119
+ /** To hide or display the textfied border*/
47120
+ showBorder: PropTypes__default.bool,
47121
+ /**
47122
+ * Array of validators.See list of default validators above.
47123
+ *
47124
+ * Ex: `validators={['required', 'isEmail']}`
47125
+ */
47126
+ validators: PropTypes__default.array,
47127
+ /** Attributes applied to the input element. */
47128
+ inputProps: PropTypes__default.object,
47129
+ /** Props applied to the Input element. */
47130
+ InputProps: PropTypes__default.object,
47131
+ /** Prefix string for the input. */
47132
+ inputPrefix: PropTypes__default.string,
47133
+ /** Decimal digit number to be used as default. */
47134
+ decimalScale: PropTypes__default.number,
47135
+ /**
47136
+ * customErrorMessages is an object with key as validator and value as customised error message.
47137
+ *
47138
+ * Ex: `customErrorMessages={{required: 'This field is required'}`
47139
+ */
47140
+ customErrorMessages: PropTypes__default.object,
47141
+ /** To make the content readOnly */
47142
+ readOnly: PropTypes__default.bool,
47143
+ /** Name of input. */
47144
+ name: PropTypes__default.string,
47145
+ /** It triggers after each validation.It will return true or false. */
47146
+ validatorListener: PropTypes__default.func,
47147
+ /** Allow to use required validator in any validation trigger, not only form submit. */
47148
+ withRequiredValidator: PropTypes__default.bool,
47149
+ /** Input text align */
47150
+ textAlign: PropTypes__default.string
47151
+ };
47152
+
47153
+ ActiveCurrencyField.defaultProps = {
47154
+ inputPrefix: '$ ',
47155
+ decimalScale: 2,
47156
+ fixedDecimalScale: true,
47157
+ textAlign: 'right'
47158
+ };
47159
+
46952
47160
  var DeleteOutlined = createCommonjsModule(function (module, exports) {
46953
47161
 
46954
47162
 
@@ -49198,6 +49406,9 @@ function UAutoComplete(_ref) {
49198
49406
  maxLength = _ref.maxLength,
49199
49407
  usedItemIds = _ref.usedItemIds,
49200
49408
  allowContextSpecific = _ref.allowContextSpecific,
49409
+ counter = _ref.counter,
49410
+ placeholder = _ref.placeholder,
49411
+ InputLabelProps = _ref.InputLabelProps,
49201
49412
  props = _ref.props;
49202
49413
 
49203
49414
  var classes = useStyles$r();
@@ -49258,16 +49469,19 @@ function UAutoComplete(_ref) {
49258
49469
  var controlOptions = options && options.length > 0 ? options.filter(function (opt) {
49259
49470
  return !usedItemIds.includes(opt.id);
49260
49471
  }) : [];
49261
-
49262
49472
  return React__default.createElement(
49263
49473
  React__default.Fragment,
49264
49474
  null,
49265
49475
  readOnly ? React__default.createElement(ActiveFormTextField, {
49266
49476
  multiline: true,
49267
- label: label + '*',
49477
+ label: label,
49478
+ InputLabelProps: _extends$1({}, InputLabelProps, {
49479
+ required: isRequired
49480
+ }),
49268
49481
  variant: 'outlined',
49269
49482
  fullWidth: true,
49270
49483
  readOnly: readOnly,
49484
+ placeholder: placeholder,
49271
49485
  value: selectedValue && selectedValue.text
49272
49486
  }) : React__default.createElement(Autocomplete$1, {
49273
49487
  value: selectedValue,
@@ -49298,7 +49512,7 @@ function UAutoComplete(_ref) {
49298
49512
  renderInput: function renderInput(params) {
49299
49513
  return React__default.createElement(ActiveFormTextField, _extends$1({}, params, {
49300
49514
  multiline: true,
49301
- label: '' + label + (isRequired ? '*' : ''),
49515
+ label: label,
49302
49516
  variant: 'outlined',
49303
49517
  value: selectedValue && selectedValue.text || '',
49304
49518
  validators: isRequired ? ['required', 'trim'] : ['trim'],
@@ -49307,8 +49521,13 @@ function UAutoComplete(_ref) {
49307
49521
  minLength: minLength,
49308
49522
  maxLength: maxLength
49309
49523
  }),
49524
+ InputLabelProps: _extends$1({}, InputLabelProps, {
49525
+ required: isRequired
49526
+ }),
49310
49527
  maxLength: maxLength,
49311
- counter: true
49528
+ counter: counter,
49529
+ placeholder: placeholder,
49530
+ readOnly: readOnly
49312
49531
  }));
49313
49532
  }
49314
49533
  })
@@ -49339,11 +49558,18 @@ UAutoComplete.propTypes = {
49339
49558
  /** can create context specific item or not */
49340
49559
  allowContextSpecific: PropTypes__default.bool,
49341
49560
  /** used item id's from the options */
49342
- usedItemIds: PropTypes__default.array
49561
+ usedItemIds: PropTypes__default.array,
49562
+ /** To enable character counter */
49563
+ counter: PropTypes__default.bool,
49564
+ /** placeholder text*/
49565
+ placeholder: PropTypes__default.string,
49566
+ /** Label props applied to input field*/
49567
+ InputLabelProps: PropTypes__default.object
49343
49568
  };
49344
49569
 
49345
49570
  UAutoComplete.defaultProps = {
49346
49571
  allowContextSpecific: false,
49572
+ counter: false,
49347
49573
  usedItemIds: []
49348
49574
  };
49349
49575
 
@@ -50640,6 +50866,208 @@ ActiveKeyboardTimePicker.defaultProps = {
50640
50866
  variant: 'inline'
50641
50867
  };
50642
50868
 
50869
+ var filter$1 = createFilterOptions();
50870
+
50871
+ var useStyles$z = makeStyles$1(function (theme) {
50872
+ return {
50873
+ controlStyle: {
50874
+ marginTop: theme.spacing(2),
50875
+ width: '100%'
50876
+ }
50877
+ };
50878
+ });
50879
+ /**
50880
+ * ActiveAutoComplete is an editable dropdown component with interactive.
50881
+ * User can enter the text in order to find the value from the list of values
50882
+ * User can also add new value to the list as well.
50883
+ */
50884
+ function ActiveAutoComplete(_ref) {
50885
+ var value = _ref.value,
50886
+ label = _ref.label,
50887
+ onChange = _ref.onChange,
50888
+ isRequired = _ref.isRequired,
50889
+ onBlur = _ref.onBlur,
50890
+ name = _ref.name,
50891
+ options = _ref.options,
50892
+ readOnly = _ref.readOnly,
50893
+ minLength = _ref.minLength,
50894
+ maxLength = _ref.maxLength,
50895
+ usedItemIds = _ref.usedItemIds,
50896
+ allowContextSpecific = _ref.allowContextSpecific,
50897
+ interactiveMode = _ref.interactiveMode,
50898
+ counter = _ref.counter,
50899
+ placeholder = _ref.placeholder,
50900
+ InputLabelProps = _ref.InputLabelProps,
50901
+ props = _ref.props;
50902
+
50903
+ var classes = useStyles$z();
50904
+ //const dispatch = useDispatch()
50905
+
50906
+ var _useState = React.useState(value || null),
50907
+ _useState2 = slicedToArray(_useState, 2),
50908
+ selectedValue = _useState2[0],
50909
+ setSelectedValue = _useState2[1]; // for initialization: avoid the control to be a uncontrolled component with 'undefined'
50910
+
50911
+ var handleChange = function handleChange(event, newValue) {
50912
+ // Create a new value from the user input
50913
+ if (newValue && newValue.inputValue) {
50914
+ setSelectedValue({
50915
+ text: newValue.inputValue
50916
+ });
50917
+ onChange({
50918
+ text: newValue.inputValue
50919
+ });
50920
+ return;
50921
+ }
50922
+ setSelectedValue(newValue);
50923
+ onChange && onChange(newValue, name);
50924
+ };
50925
+
50926
+ var handleFilter = function handleFilter(options, params) {
50927
+ var filtered = filter$1(options, params);
50928
+ var labelForMessage = label && label.toLowerCase();
50929
+ // Suggest the creation of a new value
50930
+ if (params.inputValue !== '' && allowContextSpecific) {
50931
+ filtered.push({
50932
+ inputValue: params.inputValue,
50933
+ text: 'Use context-specific ' + (labelForMessage ? labelForMessage : '') + ' "' + params.inputValue + '"'
50934
+ });
50935
+ }
50936
+ return filtered;
50937
+ };
50938
+
50939
+ var handleGetOption = function handleGetOption(option) {
50940
+ // Value selected with enter, right from the input
50941
+ if (typeof option === 'string') {
50942
+ return option;
50943
+ }
50944
+ // Add "new" option created dynamically
50945
+ if (option.inputValue) {
50946
+ return option.inputValue;
50947
+ }
50948
+ // Regular option
50949
+ return option.text || '';
50950
+ };
50951
+
50952
+ var handleOnBlur = function handleOnBlur(e) {
50953
+ if (selectedValue && selectedValue.text && selectedValue.text.trim() !== '') {
50954
+ onBlur && onBlur(e, name);
50955
+ }
50956
+ };
50957
+
50958
+ var controlOptions = options && options.length > 0 ? options.filter(function (opt) {
50959
+ return !usedItemIds.includes(opt.id);
50960
+ }) : [];
50961
+ return React__default.createElement(
50962
+ React__default.Fragment,
50963
+ null,
50964
+ !interactiveMode && readOnly ? React__default.createElement(ActiveFormTextField, {
50965
+ multiline: true,
50966
+ label: label,
50967
+ InputLabelProps: _extends$1({}, InputLabelProps, {
50968
+ required: isRequired
50969
+ }),
50970
+ variant: 'outlined',
50971
+ fullWidth: true,
50972
+ readOnly: readOnly,
50973
+ placeholder: placeholder,
50974
+ value: selectedValue && selectedValue.text
50975
+ }) : React__default.createElement(Autocomplete$1, {
50976
+ value: selectedValue,
50977
+ getOptionSelected: function getOptionSelected(option) {
50978
+ return option.id === selectedValue.id;
50979
+ },
50980
+ onChange: function onChange(event, newValue) {
50981
+ return handleChange(event, newValue);
50982
+ },
50983
+ filterOptions: function filterOptions(options, params) {
50984
+ return handleFilter(options, params);
50985
+ },
50986
+ id: 'target-input',
50987
+ name: name,
50988
+ selectOnFocus: true,
50989
+ clearOnBlur: true,
50990
+ handleHomeEndKeys: true,
50991
+ options: controlOptions,
50992
+ getOptionLabel: function getOptionLabel(option) {
50993
+ return handleGetOption(option);
50994
+ },
50995
+ renderOption: function renderOption(option) {
50996
+ return option.text;
50997
+ },
50998
+ onBlur: handleOnBlur,
50999
+ className: classes.controlStyle,
51000
+ freeSolo: allowContextSpecific,
51001
+ renderInput: function renderInput(params) {
51002
+ return React__default.createElement(ActiveFormTextField, _extends$1({}, params, {
51003
+ multiline: true,
51004
+ label: label,
51005
+ variant: 'outlined',
51006
+ value: selectedValue && selectedValue.text || '',
51007
+ validators: isRequired ? ['required', 'trim'] : ['trim'],
51008
+ fullWidth: true,
51009
+ inputProps: _extends$1({}, params.inputProps, {
51010
+ minLength: minLength,
51011
+ maxLength: maxLength
51012
+ }),
51013
+ InputLabelProps: _extends$1({}, InputLabelProps, {
51014
+ required: isRequired
51015
+ }),
51016
+ maxLength: maxLength,
51017
+ counter: counter,
51018
+ interactiveMode: interactiveMode,
51019
+ placeholder: placeholder,
51020
+ readOnly: readOnly
51021
+ }));
51022
+ }
51023
+ })
51024
+ );
51025
+ }
51026
+
51027
+ ActiveAutoComplete.propTypes = {
51028
+ /** selected value of the dropdown */
51029
+ value: PropTypes__default.object,
51030
+ /** label */
51031
+ label: PropTypes__default.string,
51032
+ /** options to display */
51033
+ options: PropTypes__default.array,
51034
+ /** dropdown on change event */
51035
+ onChange: PropTypes__default.func,
51036
+ /** enable required validator */
51037
+ isRequired: PropTypes__default.bool,
51038
+ /** enable required error in dropdown */
51039
+ hasError: PropTypes__default.bool,
51040
+ /** onBlur event for dropdown */
51041
+ onBlur: PropTypes__default.func,
51042
+ /** name of the dropdown */
51043
+ name: PropTypes__default.string,
51044
+ /** max length text */
51045
+ maxLength: PropTypes__default.number,
51046
+ /** min length text */
51047
+ minLength: PropTypes__default.number,
51048
+ /** can create context specific item or not */
51049
+ allowContextSpecific: PropTypes__default.bool,
51050
+ /** used item id's from the options */
51051
+ usedItemIds: PropTypes__default.array,
51052
+ /** Change to write mode by hiding text field border and displays border on hover*/
51053
+ interactiveMode: PropTypes__default.bool,
51054
+ /** To enable character counter */
51055
+ counter: PropTypes__default.bool,
51056
+ /** placeholder text*/
51057
+ placeholder: PropTypes__default.string,
51058
+ /** Label props applied to input field*/
51059
+ InputLabelProps: PropTypes__default.object
51060
+ };
51061
+
51062
+ ActiveAutoComplete.defaultProps = {
51063
+ allowContextSpecific: false,
51064
+ interactiveMode: false,
51065
+ counter: false,
51066
+ usedItemIds: []
51067
+ };
51068
+
51069
+ exports.ActiveAutoComplete = ActiveAutoComplete;
51070
+ exports.ActiveCurrencyField = ActiveCurrencyField;
50643
51071
  exports.ActiveDatePicker = ActiveDatePicker;
50644
51072
  exports.ActiveFormCoordinateField = ActiveFormCoordinateField;
50645
51073
  exports.ActiveFormPositiveInteger = ActiveFormPositiveInteger;
@@ -50656,6 +51084,7 @@ exports.UButton = UButton;
50656
51084
  exports.UConfirmationButton = UConfirmationButton;
50657
51085
  exports.UContent = UContent;
50658
51086
  exports.UCoordinateField = UCoordinateField;
51087
+ exports.UCurrencyField = UCurrencyField;
50659
51088
  exports.UDatePicker = UDatePicker;
50660
51089
  exports.UDateTimePicker = UDateTimePicker;
50661
51090
  exports.UErrorAlert = UErrorAlert;