@vitrosoftware/common-ui-ts 1.1.13 → 1.1.14

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.
@@ -60071,6 +60071,23 @@ var LookupPicker = function LookupPicker(props) {
60071
60071
  }, [props.selectedValueList]);
60072
60072
  useEffect(function () {
60073
60073
  valueListVisible && inputRef && inputRef.current && inputRef.current.focus();
60074
+ if (props.isReadOnly) {
60075
+ if (props.valueList) {
60076
+ updateFilteredValueList(props.valueList);
60077
+ } else if (props.getAllValueList) {
60078
+ setPending(true);
60079
+ var requestToken = {
60080
+ cancel: false
60081
+ };
60082
+ if (valueListRequestToken) {
60083
+ valueListRequestToken.cancel = true;
60084
+ }
60085
+ setValueListRequestToken(requestToken);
60086
+ props.getAllValueList().then(function (valueList) {
60087
+ return onGetValueList(valueList, requestToken);
60088
+ });
60089
+ }
60090
+ }
60074
60091
  }, [valueListVisible]);
60075
60092
  useEffect(function () {
60076
60093
  if (props.selectedValue) {
@@ -60235,14 +60252,14 @@ var LookupPicker = function LookupPicker(props) {
60235
60252
  onClick: onFocus,
60236
60253
  disabled: props.isDisabled,
60237
60254
  readOnly: props.isReadOnly
60238
- }), !props.isDisabled && !props.isReadOnly && props.children, React__default.createElement("div", {
60255
+ }), !props.isDisabled && props.children, React__default.createElement("div", {
60239
60256
  className: styles$j['vitro-right']
60240
60257
  }, !props.isMultiSelect && selectedValueList && selectedValueList.length > 0 && !props.isDisabled && !props.isReadOnly && React__default.createElement("div", {
60241
60258
  className: styles$j['vitro-button-close'],
60242
60259
  onClick: function onClick() {
60243
60260
  return onOptionValueDelete();
60244
60261
  }
60245
- }), !props.isDisabled && !props.isReadOnly && React__default.createElement("div", {
60262
+ }), !props.isDisabled && React__default.createElement("div", {
60246
60263
  onClick: function onClick() {
60247
60264
  return setValueListVisible(!valueListVisible);
60248
60265
  },
@@ -60250,7 +60267,7 @@ var LookupPicker = function LookupPicker(props) {
60250
60267
  }), props.isReadOnly ? React__default.createElement("span", {
60251
60268
  className: styles$j['vitro-button-copy'],
60252
60269
  onClick: copyValue
60253
- }) : null)), !props.isDisabled && !props.isReadOnly && (!props.filterMinLength || props.filterMinLength <= inputValue.length) && React__default.createElement(ValueList, {
60270
+ }) : null)), !props.isDisabled && (!props.filterMinLength || props.filterMinLength <= inputValue.length) && React__default.createElement(ValueList, {
60254
60271
  isPending: pending,
60255
60272
  inputValue: inputValue,
60256
60273
  list: filteredValueList,
@@ -62166,7 +62183,7 @@ var CommandMenuDropdownButton = function CommandMenuDropdownButton(props) {
62166
62183
  }), props.children));
62167
62184
  };
62168
62185
 
62169
- var styles$o = {"vitro-active":"_sidebar-item_vitro-active_7p5iOhY","vitro-icon-text":"_sidebar-item_vitro-icon-text_3ROhyLK","vitro-item-text":"_sidebar-item_vitro-item-text_1kK_aIZ","vitro-icon":"_sidebar-item_vitro-icon_2B88tow"};
62186
+ var styles$o = {"vitro-active":"_sidebar-item_vitro-active_7p5iOhY","vitro-icon-text":"_sidebar-item_vitro-icon-text_3ROhyLK","vitro-item-text":"_sidebar-item_vitro-item-text_1kK_aIZ","vitro-icon":"_sidebar-item_vitro-icon_2B88tow","vitro-item":"_sidebar-item_vitro-item_1BR_7F0"};
62170
62187
 
62171
62188
  var Item$1 = function Item(props) {
62172
62189
  return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", null, React__default.createElement(Icon, {
@@ -62188,6 +62205,8 @@ var TARGET;
62188
62205
  })(TARGET || (TARGET = {}));
62189
62206
 
62190
62207
  var w$6 = window;
62208
+ var PX_UNIT$3 = 'px';
62209
+ var WIDTH_AUTO = 'auto';
62191
62210
  var LinkItem$1 = function LinkItem(props) {
62192
62211
  var _useState = useState(false),
62193
62212
  isHover = _useState[0],
@@ -62199,7 +62218,11 @@ var LinkItem$1 = function LinkItem(props) {
62199
62218
  },
62200
62219
  onMouseLeave: function onMouseLeave() {
62201
62220
  return setIsHover(false);
62202
- }
62221
+ },
62222
+ style: {
62223
+ width: props.linkItemWidth ? props.linkItemWidth + PX_UNIT$3 : WIDTH_AUTO
62224
+ },
62225
+ className: styles$o['vitro-item']
62203
62226
  }, props.link && React__default.createElement(Link, {
62204
62227
  to: props.link,
62205
62228
  className: isActive ? styles$o['vitro-active'] : CTRL.EMPTY
@@ -62211,18 +62234,19 @@ var LinkItem$1 = function LinkItem(props) {
62211
62234
  },
62212
62235
  className: isActive ? styles$o['vitro-active'] : CTRL.EMPTY
62213
62236
  }, React__default.createElement(Item$1, Object.assign({}, props, {
62214
- isHover: isActive || isHover
62237
+ isHover: isActive
62215
62238
  }))), props.href && React__default.createElement("a", {
62216
62239
  href: props.href,
62217
62240
  target: props.isExternal ? TARGET.BLANK : TARGET.SELF
62218
62241
  }, React__default.createElement(Item$1, Object.assign({}, props, {
62219
- isHover: isActive || isHover
62242
+ isHover: isActive
62220
62243
  }))));
62221
62244
  };
62222
62245
 
62223
62246
  var Section = function Section(props) {
62224
62247
  return React__default.createElement("li", null, props.text && React__default.createElement("span", null, props.text), React__default.createElement("ul", null, props.itemList && props.itemList.map(function (i) {
62225
62248
  return React__default.createElement(LinkItem$1, Object.assign({
62249
+ linkItemWidth: props.linkItemWidth,
62226
62250
  activeItem: props.activeItem,
62227
62251
  key: i.text,
62228
62252
  currentUrl: props.currentUrl
@@ -62230,19 +62254,22 @@ var Section = function Section(props) {
62230
62254
  })));
62231
62255
  };
62232
62256
 
62233
- var SectionList = function SectionList(props) {
62257
+ var SectionList = forwardRef(function (props, ref) {
62234
62258
  if (!props.itemList || props.itemList.length === 0) {
62235
62259
  return null;
62236
62260
  }
62237
- return React__default.createElement("ul", null, props.itemList.map(function (section) {
62261
+ return React__default.createElement("ul", {
62262
+ ref: ref
62263
+ }, props.itemList.map(function (section) {
62238
62264
  return React__default.createElement(Section, Object.assign({
62265
+ linkItemWidth: props.linkItemWidth,
62239
62266
  currentUrl: props.currentUrl,
62240
62267
  activeItem: props.activeItem
62241
62268
  }, section));
62242
62269
  }));
62243
- };
62270
+ });
62244
62271
 
62245
- var styles$p = {"vitro-sidebar":"_sidebar_vitro-sidebar_1IxGYiU"};
62272
+ var styles$p = {"vitro-sidebar":"_sidebar_vitro-sidebar_1IxGYiU","vitro-scroll-container":"_sidebar_vitro-scroll-container_3K-iJy8","vitro-button-more":"_sidebar_vitro-button-more_3s9oZY9"};
62246
62273
 
62247
62274
  var Sidebar = function Sidebar(props) {
62248
62275
  var _useState = useState(props.history.location.pathname),
@@ -62251,21 +62278,75 @@ var Sidebar = function Sidebar(props) {
62251
62278
  var _useState2 = useState([]),
62252
62279
  itemList = _useState2[0],
62253
62280
  setItemList = _useState2[1];
62281
+ var _useState3 = useState(false),
62282
+ isMobileView = _useState3[0],
62283
+ setIsMobileView = _useState3[1];
62284
+ var _useState4 = useState(0),
62285
+ translate = _useState4[0],
62286
+ setTranslate = _useState4[1];
62287
+ var _useState5 = useState(0),
62288
+ linkItemWidth = _useState5[0],
62289
+ setLinkItemWidth = _useState5[1];
62290
+ var menuRef = useRef(null);
62291
+ var scrollableListRef = useRef(null);
62254
62292
  props.history.listen(function (location) {
62255
62293
  setCurrentUrl(location.pathname);
62256
62294
  });
62257
62295
  useEffect(function () {
62258
62296
  if (props.sidebar === 1 && props.overflowItemList && props.overflowItemList.length > 0) {
62259
62297
  setItemList([].concat(props.topItemList, props.overflowItemList));
62298
+ } else if (isMobileView) {
62299
+ var list = props.bottomItemList ? [].concat(props.topItemList, props.bottomItemList) : props.topItemList;
62300
+ setItemList(list);
62260
62301
  } else {
62261
62302
  setItemList(props.topItemList);
62262
62303
  }
62263
- }, [props.sidebar]);
62264
- var className = styles$p['vitro-sidebar'] + (props.theme ? CTRL.SPACE + props.theme : CTRL.EMPTY);
62304
+ }, [props.sidebar, isMobileView]);
62305
+ useEffect(function () {
62306
+ window.addEventListener(EVENT.RESIZE, handleResize);
62307
+ handleResize();
62308
+ return function () {
62309
+ window.removeEventListener(EVENT.RESIZE, handleResize);
62310
+ };
62311
+ }, []);
62312
+ useEffect(function () {
62313
+ handleResize();
62314
+ }, [window.innerWidth]);
62315
+ var handleResize = function handleResize() {
62316
+ window.innerWidth < 800 ? setIsMobileView(true) : setIsMobileView(false);
62317
+ if (window.innerWidth < 800 && menuRef.current) {
62318
+ var info = menuRef.current.getBoundingClientRect();
62319
+ var width = info.right - info.left;
62320
+ updateLinkItemWidth(width);
62321
+ }
62322
+ };
62323
+ var scroll = function scroll() {
62324
+ var container = menuRef.current;
62325
+ var scrollableList = scrollableListRef.current;
62326
+ if (container && scrollableList) {
62327
+ var info = container.getBoundingClientRect();
62328
+ var width = info.right - info.left;
62329
+ var translateValue = translate;
62330
+ if (container.scrollLeft + width >= container.scrollWidth) {
62331
+ translateValue = 0;
62332
+ } else {
62333
+ translateValue += width;
62334
+ }
62335
+ setTranslate(translateValue);
62336
+ scrollableList.style.transform = "translate(-" + translateValue + "px)";
62337
+ }
62338
+ };
62339
+ var updateLinkItemWidth = function updateLinkItemWidth(containerWidth) {
62340
+ var elemWidth = 76;
62341
+ var count = Math.floor(containerWidth / elemWidth);
62342
+ var width = containerWidth / count;
62343
+ setLinkItemWidth(width);
62344
+ };
62345
+ var className = styles$p['vitro-sidebar'] + (props.theme ? CTRL.SPACE + props.theme : CTRL.EMPTY) + CTRL.SPACE + (isMobileView ? 'vitro-bottom-menu' : CTRL.EMPTY);
62265
62346
  return React__default.createElement("div", {
62266
62347
  className: className,
62267
62348
  id: 'vitro-sidebar'
62268
- }, React__default.createElement(SectionList, {
62349
+ }, !isMobileView ? React__default.createElement(React__default.Fragment, null, React__default.createElement(SectionList, {
62269
62350
  itemList: itemList,
62270
62351
  currentUrl: currentUrl,
62271
62352
  activeItem: props.activeItem
@@ -62273,7 +62354,19 @@ var Sidebar = function Sidebar(props) {
62273
62354
  itemList: props.bottomItemList,
62274
62355
  currentUrl: currentUrl,
62275
62356
  activeItem: props.activeItem
62276
- }));
62357
+ })) : React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
62358
+ className: styles$p['vitro-scroll-container'],
62359
+ ref: menuRef
62360
+ }, React__default.createElement(SectionList, {
62361
+ itemList: itemList,
62362
+ currentUrl: currentUrl,
62363
+ activeItem: props.activeItem,
62364
+ ref: scrollableListRef,
62365
+ linkItemWidth: linkItemWidth
62366
+ })), React__default.createElement("button", {
62367
+ onClick: scroll,
62368
+ className: styles$p['vitro-button-more']
62369
+ })));
62277
62370
  };
62278
62371
 
62279
62372
  var styles$q = {"vitro-task-tile":"_task-tile_vitro-task-tile_35bZu48","vitro-active":"_task-tile_vitro-active_11W9nJz","vitro-content":"_task-tile_vitro-content_rl2ERCQ","vitro-description":"_task-tile_vitro-description_qtyUbLy","vitro-comment":"_task-tile_vitro-comment_2im2AJj","vitro-title":"_task-tile_vitro-title_1pXrIrB","vitro-top-right":"_task-tile_vitro-top-right_19tbPX4","vitro-dropdown-button":"_task-tile_vitro-dropdown-button_2YgEUdg","vitro-bottom-right":"_task-tile_vitro-bottom-right_2E9WAle","vitro-button-cancel":"_task-tile_vitro-button-cancel_1lgja1K"};