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