@vitrosoftware/common-ui-ts 1.1.14 → 1.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -58719,13 +58719,13 @@ var ActionHandler = function ActionHandler(props) {
58719
58719
  }, []);
58720
58720
  var data = React.useMemo(function () {
58721
58721
  return {
58722
- itemList: props.itemList || [props.item]
58722
+ itemList: props.itemList || [props.item],
58723
+ itemCount: props.itemList ? props.itemList.length : [props.item].length
58723
58724
  };
58724
58725
  }, []);
58725
58726
  var progressBarRef = React.useRef(null);
58726
58727
  var localeService = inversifyReact.useInjection(SERVICE.LOCALE);
58727
58728
  var action = props.actionText || localeService.create(LOCALE$1.ACTION + CTRL.DOT + props.actionCode);
58728
- var itemCount = data.itemList.length;
58729
58729
  React.useEffect(function () {
58730
58730
  setIsCloseByOutsideClick(currentAction !== actionMap$1.progress);
58731
58731
  if (currentAction === actionMap$1.before) {
@@ -58765,17 +58765,17 @@ var ActionHandler = function ActionHandler(props) {
58765
58765
  if (props.isConfirm) {
58766
58766
  var confText;
58767
58767
  if (props.confirmText && props.confirmText()) {
58768
- confText = props.confirmText(itemCount);
58768
+ confText = props.confirmText(data.itemCount);
58769
58769
  } else {
58770
- if (itemCount === 1) {
58770
+ if (data.itemCount === 1) {
58771
58771
  confText = localeService.create(LOCALE$1.CONF_SINGLE, {
58772
58772
  actionCode: action,
58773
- itemCount: itemCount
58773
+ itemCount: data.itemCount
58774
58774
  });
58775
58775
  } else {
58776
58776
  confText = localeService.create(LOCALE$1.CONF_MULTI, {
58777
58777
  actionCode: action,
58778
- itemCount: itemCount
58778
+ itemCount: data.itemCount
58779
58779
  });
58780
58780
  }
58781
58781
  }
@@ -58804,13 +58804,13 @@ var ActionHandler = function ActionHandler(props) {
58804
58804
  setActionResult(success, successResult, failResult);
58805
58805
  if (success) {
58806
58806
  if (props.successText && props.successText()) {
58807
- setText(props.successText(itemCount));
58807
+ setText(props.successText(data.itemCount));
58808
58808
  }
58809
58809
  } else {
58810
58810
  if (error && error.text) {
58811
58811
  setText(error.text);
58812
58812
  } else if (props.errorText) {
58813
- setText(props.errorText(error, itemCount));
58813
+ setText(props.errorText(error, data.itemCount));
58814
58814
  }
58815
58815
  }
58816
58816
  };
@@ -58821,28 +58821,28 @@ var ActionHandler = function ActionHandler(props) {
58821
58821
  var key = [LOCALE$1.ACTION_MSG, props.actionCode, LOCALE$1.SUCCESS].join(CTRL.DOT);
58822
58822
  setText(localeService.create(key, {
58823
58823
  actionCode: action,
58824
- count: itemCount
58824
+ count: successResult.length
58825
58825
  }));
58826
58826
  } else if (successResult.length && failResult.length) {
58827
58827
  setIcon(styles$6['vitro-icon-warning']);
58828
58828
  setState(styles$6['vitro-warning']);
58829
- var _key = itemCount === 1 ? LOCALE$1.WARNING_SINGLE : LOCALE$1.WARNING_MULTI;
58829
+ var _key = data.itemCount === 1 ? LOCALE$1.WARNING_SINGLE : LOCALE$1.WARNING_MULTI;
58830
58830
  setText(localeService.create(_key, {
58831
58831
  actionCode: action,
58832
- itemCount: itemCount
58832
+ itemCount: data.itemCount
58833
58833
  }));
58834
58834
  } else {
58835
58835
  setIcon(styles$6['vitro-icon-error']);
58836
58836
  setState(styles$6['vitro-error']);
58837
- var _key2 = itemCount === 1 ? LOCALE$1.ERROR_SINGLE : LOCALE$1.ERROR_MULTI;
58837
+ var _key2 = data.itemCount === 1 ? LOCALE$1.ERROR_SINGLE : LOCALE$1.ERROR_MULTI;
58838
58838
  setText(localeService.create(_key2, {
58839
58839
  actionCode: action,
58840
- itemCount: itemCount
58840
+ itemCount: data.itemCount
58841
58841
  }));
58842
58842
  }
58843
58843
  };
58844
58844
  var setProgress = function setProgress(index) {
58845
- var percent = index * 100 / itemCount;
58845
+ var percent = index * 100 / data.itemCount;
58846
58846
  if (progressBarRef.current) {
58847
58847
  progressBarRef.current.style.width = percent + CTRL.PERCENT;
58848
58848
  }
@@ -58851,9 +58851,9 @@ var ActionHandler = function ActionHandler(props) {
58851
58851
  try {
58852
58852
  init();
58853
58853
  if (props.progressText) {
58854
- setText(props.progressText(itemCount));
58854
+ setText(props.progressText(data.itemCount));
58855
58855
  } else {
58856
- if (itemCount === 1) {
58856
+ if (data.itemCount === 1) {
58857
58857
  setText(localeService.create(LOCALE$1.PROGRESS_SINGLE, {
58858
58858
  actionCode: action
58859
58859
  }));
@@ -58861,7 +58861,7 @@ var ActionHandler = function ActionHandler(props) {
58861
58861
  setText(localeService.create(LOCALE$1.PROGRESS_MULTI, {
58862
58862
  idx: 1,
58863
58863
  actionCode: action,
58864
- itemCount: itemCount
58864
+ itemCount: data.itemCount
58865
58865
  }));
58866
58866
  }
58867
58867
  }
@@ -58913,13 +58913,14 @@ var ActionHandler = function ActionHandler(props) {
58913
58913
  }, function () {
58914
58914
  if (cancellationToken.cancel) {
58915
58915
  data.itemList = data.itemList.slice(0, _i + 1);
58916
+ data.itemCount = data.itemList.length;
58916
58917
  _interrupt = true;
58917
58918
  return;
58918
58919
  }
58919
- if (itemCount > 1) {
58920
+ if (data.itemCount > 1) {
58920
58921
  setText(localeService.create(LOCALE$1.PROGRESS_MULTI, {
58921
58922
  idx: _i + 1,
58922
- itemCount: itemCount,
58923
+ itemCount: data.itemCount,
58923
58924
  actionCode: action
58924
58925
  }));
58925
58926
  } else {
@@ -59004,7 +59005,7 @@ var ActionHandler = function ActionHandler(props) {
59004
59005
  }))), showItemCount && React__default.createElement("span", {
59005
59006
  className: styles$6['vitro-small']
59006
59007
  }, localeService.create(LOCALE$1.ITEM_COUNT, {
59007
- itemCount: itemCount
59008
+ itemCount: data.itemCount
59008
59009
  })), showInfo && React__default.createElement(ActionInfo, {
59009
59010
  itemList: data.itemList,
59010
59011
  successResult: successResult,
@@ -59969,6 +59970,8 @@ var TimePicker = function TimePicker(props) {
59969
59970
 
59970
59971
  var styles$h = {"vitro-selected-item":"_lookup-picker-selected-item_vitro-selected-item_hw-euth"};
59971
59972
 
59973
+ var htmlValueStyles = {"vitro-item-html-value":"_lookup-picker-html-value_vitro-item-html-value_2QBoTey"};
59974
+
59972
59975
  var SelectedValueList = function SelectedValueList(props) {
59973
59976
  return React__default.createElement(React__default.Fragment, null, props.list.map(function (x) {
59974
59977
  var title = props.selectedValueTemplate(x);
@@ -59976,7 +59979,9 @@ var SelectedValueList = function SelectedValueList(props) {
59976
59979
  key: x.id,
59977
59980
  className: styles$h['vitro-selected-item'],
59978
59981
  title: title
59979
- }, React__default.createElement("span", null, title), props.isMultiSelect && React__default.createElement("div", {
59982
+ }, props.getHtmlValue ? React__default.createElement("div", {
59983
+ className: htmlValueStyles['vitro-item-html-value']
59984
+ }, props.getHtmlValue(x)) : null, React__default.createElement("span", null, title), props.isMultiSelect && React__default.createElement("div", {
59980
59985
  onClick: function onClick() {
59981
59986
  return props.onOptionValueDelete(x.id);
59982
59987
  },
@@ -59985,7 +59990,23 @@ var SelectedValueList = function SelectedValueList(props) {
59985
59990
  }));
59986
59991
  };
59987
59992
 
59988
- var styles$i = {"vitro-value-list":"_lookup-picker-value-list_vitro-value-list_LSdCMjq","vitro-item":"_lookup-picker-value-list_vitro-item_7yZBz5u","vitro-placeholder-empty":"_lookup-picker-value-list_vitro-placeholder-empty_fTVHWwc","vitro-keyword-highlight":"_lookup-picker-value-list_vitro-keyword-highlight_1uESHan","vitro-display-none":"_lookup-picker-value-list_vitro-display-none_2kDzC6K"};
59993
+ var styles$i = {"vitro-value-list":"_lookup-picker-value-list_vitro-value-list_LSdCMjq","vitro-item":"_lookup-picker-value-list_vitro-item_7yZBz5u","vitro-item-html-value":"_lookup-picker-value-list_vitro-item-html-value_1yl9tXx","vitro-placeholder-empty":"_lookup-picker-value-list_vitro-placeholder-empty_fTVHWwc","vitro-keyword-highlight":"_lookup-picker-value-list_vitro-keyword-highlight_1uESHan","vitro-display-none":"_lookup-picker-value-list_vitro-display-none_2kDzC6K"};
59994
+
59995
+ var ValueListItem = function ValueListItem(props) {
59996
+ return React__default.createElement("div", {
59997
+ key: props.item.id,
59998
+ className: styles$i['vitro-item'],
59999
+ onClick: function onClick() {
60000
+ return props.onSelect(props.item.id);
60001
+ }
60002
+ }, props.htmlValue ? React__default.createElement("div", {
60003
+ className: htmlValueStyles['vitro-item-html-value']
60004
+ }, props.htmlValue) : null, React__default.createElement("div", {
60005
+ dangerouslySetInnerHTML: {
60006
+ __html: props.createDisplayValue(props.item)
60007
+ }
60008
+ }));
60009
+ };
59989
60010
 
59990
60011
  var FLAG = 'gi';
59991
60012
  var ValueList = function ValueList(props) {
@@ -60008,15 +60029,11 @@ var ValueList = function ValueList(props) {
60008
60029
  }, React__default.createElement(commonUi.ScrollBar, {
60009
60030
  onInit: setScrollableElement
60010
60031
  }, props.isPending && React__default.createElement(commonUi.Progress, null), !props.isPending && React__default.createElement(React__default.Fragment, null, props.list.length > 0 ? props.list.map(function (x) {
60011
- return React__default.createElement("div", {
60012
- key: x.id,
60013
- className: styles$i['vitro-item'],
60014
- onClick: function onClick() {
60015
- return props.onOptionValueSelect(x.id);
60016
- },
60017
- dangerouslySetInnerHTML: {
60018
- __html: createDisplayValue(x)
60019
- }
60032
+ return React__default.createElement(ValueListItem, {
60033
+ item: x,
60034
+ onSelect: props.onOptionValueSelect,
60035
+ createDisplayValue: createDisplayValue,
60036
+ htmlValue: props.getHtmlValue && props.getHtmlValue(x)
60020
60037
  });
60021
60038
  }) : React__default.createElement("div", {
60022
60039
  className: styles$i['vitro-placeholder-empty']
@@ -60230,6 +60247,12 @@ var LookupPicker = function LookupPicker(props) {
60230
60247
  classList.push(state);
60231
60248
  return classList.join(CTRL.SPACE);
60232
60249
  };
60250
+ var getHtmlValue = function getHtmlValue(item) {
60251
+ if (props.htmlValueTemplate && props.getHtmlValueTemplateProps) {
60252
+ return React__default.createElement(props.htmlValueTemplate, props.getHtmlValueTemplateProps(item));
60253
+ }
60254
+ return null;
60255
+ };
60233
60256
  return React__default.createElement("div", {
60234
60257
  className: getClassName(),
60235
60258
  tabIndex: 1,
@@ -60246,7 +60269,8 @@ var LookupPicker = function LookupPicker(props) {
60246
60269
  list: selectedValueList,
60247
60270
  onOptionValueDelete: onOptionValueDelete,
60248
60271
  selectedValueTemplate: selectedValueTemplate,
60249
- isMultiSelect: props.isMultiSelect
60272
+ isMultiSelect: props.isMultiSelect,
60273
+ getHtmlValue: getHtmlValue
60250
60274
  }) : !valueListVisible && React__default.createElement(React__default.Fragment, null, props.placeholder), !props.isDisabled && !props.isReadOnly && React__default.createElement("input", {
60251
60275
  ref: inputRef,
60252
60276
  value: inputValue,
@@ -60277,7 +60301,8 @@ var LookupPicker = function LookupPicker(props) {
60277
60301
  filterValueTemplate: filterValueTemplate,
60278
60302
  onOptionValueSelect: onOptionValueSelect,
60279
60303
  isVisible: valueListVisible,
60280
- emptyPlaceholder: props.emptyPlaceholder || localeService.create(LOCALE$3.PLACEHOLDER_EMPTY)
60304
+ emptyPlaceholder: props.emptyPlaceholder || localeService.create(LOCALE$3.PLACEHOLDER_EMPTY),
60305
+ getHtmlValue: getHtmlValue
60281
60306
  }), props.errorMessage && React__default.createElement("span", {
60282
60307
  className: styles$j['vitro-error-text']
60283
60308
  }, props.errorMessage));
@@ -62584,10 +62609,141 @@ var DialogFooter = function DialogFooter(props) {
62584
62609
  }));
62585
62610
  };
62586
62611
 
62612
+ var styles$w = {"vitro-avatar":"_avatar_vitro-avatar_P2tU-_r","vitro-avatar-big":"_avatar_vitro-avatar-big_pEmlX3a"};
62613
+
62614
+ var Avatar = function Avatar(props) {
62615
+ var getInitials = function getInitials() {
62616
+ var initials = CTRL.EMPTY;
62617
+ if (props.userName) {
62618
+ props.userName.split(CTRL.SPACE).forEach(function (name, i) {
62619
+ initials += i < 2 ? name[0] ? name[0] : CTRL.EMPTY : CTRL.EMPTY;
62620
+ });
62621
+ }
62622
+ return initials;
62623
+ };
62624
+ var getBackground = function getBackground() {
62625
+ if (props.image) {
62626
+ return props.image;
62627
+ } else if (props.userName) {
62628
+ return getBgColor(props.userName);
62629
+ }
62630
+ return CTRL.EMPTY;
62631
+ };
62632
+ var getHashOfString = function getHashOfString(str) {
62633
+ var hash = 0;
62634
+ for (var i = 0; i < str.length; i++) {
62635
+ hash = str.charCodeAt(i) + ((hash << 5) - hash);
62636
+ }
62637
+ hash = Math.abs(hash);
62638
+ return hash;
62639
+ };
62640
+ var normalizeHash = function normalizeHash(hash, min, max) {
62641
+ return Math.floor(hash % (max - min) + min);
62642
+ };
62643
+ var getHue = function getHue(name) {
62644
+ var min = 1000;
62645
+ var max = 360;
62646
+ var hash = getHashOfString(name);
62647
+ var normalizedHash = normalizeHash(hash, min, max);
62648
+ return normalizedHash;
62649
+ };
62650
+ var getBgColor = function getBgColor(name) {
62651
+ return "linear-gradient(0deg, hsla(" + getHue(name) + ", 58%, 55%, 1), hsla(" + (getHue(name) + 50) + ", 100%, 78%, 1))";
62652
+ };
62653
+ var className = styles$w['vitro-avatar'] + (props.isBigSize ? CTRL.SPACE + styles$w['vitro-avatar-big'] : CTRL.EMPTY);
62654
+ return React__default.createElement("div", {
62655
+ className: className,
62656
+ style: {
62657
+ background: getBackground()
62658
+ }
62659
+ }, getInitials());
62660
+ };
62661
+
62662
+ var styles$x = {"vitro-user-profile":"_user-profile_vitro-user-profile_11XpBoQ","vitro-dropdown-item":"_user-profile_vitro-dropdown-item_dSErsta"};
62663
+
62664
+ var UserProfileMenuItem = function UserProfileMenuItem(props) {
62665
+ var onClick = function onClick() {
62666
+ if (props.onClick) {
62667
+ props.onClick();
62668
+ }
62669
+ props.setDropdownState(false);
62670
+ };
62671
+ if (props.link) {
62672
+ return React__default.createElement("div", {
62673
+ className: styles$x['vitro-dropdown-item'],
62674
+ onClick: onClick
62675
+ }, React__default.createElement(Link, {
62676
+ to: props.link
62677
+ }, props.imageUrl && React__default.createElement(commonUi.Icon, {
62678
+ defaultUrl: props.imageUrl,
62679
+ hoverUrl: props.hoverImageUrl
62680
+ }), props.text));
62681
+ }
62682
+ if (props.onClick) {
62683
+ return React__default.createElement("div", {
62684
+ className: styles$x['vitro-dropdown-item'],
62685
+ key: props.text,
62686
+ onClick: onClick
62687
+ }, props.imageUrl && React__default.createElement(commonUi.Icon, {
62688
+ defaultUrl: props.imageUrl,
62689
+ hoverUrl: props.hoverImageUrl
62690
+ }), props.text);
62691
+ }
62692
+ return null;
62693
+ };
62694
+
62695
+ var UserProfile = function UserProfile(props) {
62696
+ var _useState = React.useState(false),
62697
+ dropdownOpen = _useState[0],
62698
+ setDropdownOpen = _useState[1];
62699
+ var toggle = function toggle() {
62700
+ return setDropdownOpen(function (prevState) {
62701
+ return !prevState;
62702
+ });
62703
+ };
62704
+ var createSurnameWithInitials = function createSurnameWithInitials(name) {
62705
+ var username = CTRL.EMPTY;
62706
+ if (name) {
62707
+ name.split(CTRL.SPACE).forEach(function (name, i) {
62708
+ if (i < 3) {
62709
+ username += i === 0 ? name + CTRL.SPACE : (name[0] ? name[0] : CTRL.EMPTY) + CTRL.DOT;
62710
+ }
62711
+ });
62712
+ }
62713
+ return username;
62714
+ };
62715
+ return React__default.createElement(Dropdown, {
62716
+ isOpen: dropdownOpen,
62717
+ toggle: toggle,
62718
+ className: styles$x['vitro-user-profile']
62719
+ }, React__default.createElement(DropdownToggle, {
62720
+ caret: true
62721
+ }, React__default.createElement("div", null, React__default.createElement("span", {
62722
+ className: styles$x['vitro-text-color-white']
62723
+ }, createSurnameWithInitials(props.userName)), React__default.createElement(Avatar, {
62724
+ userName: props.userName,
62725
+ isBigSize: true
62726
+ }))), React__default.createElement(DropdownMenu, {
62727
+ right: true
62728
+ }, props.dropdownMenuItemList && props.dropdownMenuItemList.length > 0 && props.dropdownMenuItemList.map(function (item) {
62729
+ return React__default.createElement(UserProfileMenuItem, Object.assign({
62730
+ setDropdownState: setDropdownOpen
62731
+ }, item));
62732
+ })));
62733
+ };
62734
+
62735
+ var UserLookupPicker = function UserLookupPicker(props) {
62736
+ return React__default.createElement(LookupPicker, Object.assign({}, props, {
62737
+ htmlValueTemplate: Avatar,
62738
+ getHtmlValueTemplateProps: props.getHtmlValueTemplateProps
62739
+ }));
62740
+ };
62741
+
62587
62742
  exports.ACTION_HANDLER = ActionHandlerConstants;
62588
62743
  exports.ALERT = AlertConstants;
62589
62744
  exports.ActionHandler = ActionHandler;
62590
62745
  exports.Alert = Alert$1;
62746
+ exports.Avatar = Avatar;
62591
62747
  exports.Breadcrumbs = Breadcrumbs;
62592
62748
  exports.Button = Button$2;
62593
62749
  exports.CommandMenu = CommandMenu;
@@ -62619,6 +62775,8 @@ exports.TelerikUploaderContextImpl = TelerikUploaderContextImpl;
62619
62775
  exports.TimePicker = TimePicker;
62620
62776
  exports.TopLevelMenu = TopLevelMenu;
62621
62777
  exports.TreeView = TreeView;
62778
+ exports.UserLookupPicker = UserLookupPicker;
62779
+ exports.UserProfile = UserProfile;
62622
62780
  exports.View = View;
62623
62781
  exports.commonEn = commonEn;
62624
62782
  exports.commonRu = commonRu;