@rpg-engine/long-bow 0.5.61 → 0.5.62

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.
@@ -17,7 +17,6 @@ var ReactDOM = _interopDefault(require('react-dom'));
17
17
  var lodash = require('lodash');
18
18
  var mobxReactLite = require('mobx-react-lite');
19
19
  var uuid = require('uuid');
20
- var reactSpinners = require('react-spinners');
21
20
  var ai = require('react-icons/ai');
22
21
  require('rpgui/rpgui.css');
23
22
  require('rpgui/rpgui.min.js');
@@ -14798,43 +14797,55 @@ var ItemTypes = /*#__PURE__*/styled__default.div.withConfig({
14798
14797
  })(["display:flex;overflow-y:scroll;overflow-x:hidden;width:max-content;flex-direction:column;padding-right:5px;@media (max-width:", "){overflow-x:scroll;overflow-y:hidden;padding-right:0;width:100%;}"], mobilePortrait.width);
14799
14798
 
14800
14799
  var Dropdown = function Dropdown(_ref) {
14801
- var _options$, _options$find, _options$2;
14802
14800
  var options = _ref.options,
14803
14801
  width = _ref.width,
14804
14802
  onChange = _ref.onChange,
14805
14803
  defaultValue = _ref.defaultValue;
14806
14804
  var dropdownId = uuid.v4();
14807
- var _useState = React.useState(defaultValue || (options == null ? void 0 : (_options$ = options[0]) == null ? void 0 : _options$.value)),
14805
+ var _useState = React.useState(defaultValue || ''),
14808
14806
  selectedValue = _useState[0],
14809
14807
  setSelectedValue = _useState[1];
14810
- var _useState2 = React.useState((options == null ? void 0 : (_options$find = options.find(function (option) {
14811
- return option.value === defaultValue;
14812
- })) == null ? void 0 : _options$find.option) || (options == null ? void 0 : (_options$2 = options[0]) == null ? void 0 : _options$2.option)),
14808
+ var _useState2 = React.useState(''),
14813
14809
  selectedOption = _useState2[0],
14814
14810
  setSelectedOption = _useState2[1];
14815
14811
  var _useState3 = React.useState(false),
14816
14812
  opened = _useState3[0],
14817
14813
  setOpened = _useState3[1];
14814
+ React.useEffect(function () {
14815
+ var firstOption = options[0];
14816
+ if (firstOption) {
14817
+ var change = !selectedValue;
14818
+ if (!change) {
14819
+ change = options.filter(function (o) {
14820
+ return o.value === selectedValue;
14821
+ }).length < 1;
14822
+ }
14823
+ /**
14824
+ * make a selection if there is no selected value already present
14825
+ * or if there is a selected value but its not in new options
14826
+ */
14827
+ if (change) {
14828
+ setSelectedValue(firstOption.value);
14829
+ setSelectedOption(firstOption.option);
14830
+ }
14831
+ }
14832
+ }, [options]);
14818
14833
  React.useEffect(function () {
14819
14834
  if (defaultValue) {
14820
- var _options$find2;
14821
- setSelectedValue(defaultValue);
14822
- setSelectedOption( //@ts-ignore
14823
- options == null ? void 0 : (_options$find2 = options.find(function (option) {
14824
- return option.value === defaultValue;
14825
- })) == null ? void 0 : _options$find2.option);
14826
- } else if ((options == null ? void 0 : options.length) > 0) {
14827
- setSelectedValue(options[0].value);
14828
- setSelectedOption(options[0].option);
14835
+ var option = options.find(function (o) {
14836
+ return o.value === defaultValue;
14837
+ });
14838
+ if (option) {
14839
+ setSelectedValue(option.value);
14840
+ setSelectedOption(option.option);
14841
+ }
14829
14842
  }
14830
- }, [options, defaultValue]);
14831
- var handleSelection = function handleSelection(value, option) {
14832
- if (value !== selectedValue) {
14833
- setSelectedValue(value);
14834
- setSelectedOption(option);
14835
- onChange(value);
14843
+ }, [defaultValue]);
14844
+ React.useEffect(function () {
14845
+ if (selectedValue) {
14846
+ onChange(selectedValue);
14836
14847
  }
14837
- };
14848
+ }, [selectedValue]);
14838
14849
  return React__default.createElement(Container$d, {
14839
14850
  onMouseLeave: function onMouseLeave() {
14840
14851
  return setOpened(false);
@@ -14848,43 +14859,33 @@ var Dropdown = function Dropdown(_ref) {
14848
14859
  return !prev;
14849
14860
  });
14850
14861
  }
14851
- }, React__default.createElement(DropdownDisplay, null, React__default.createElement(DropdownLabel, null, "\u25BC"), " ", selectedOption, !options.length && React__default.createElement(reactSpinners.BeatLoader, {
14852
- size: 4,
14853
- color: uiColors.white
14854
- }))), React__default.createElement(DropdownOptions, {
14862
+ }, React__default.createElement("label", null, "\u25BC"), " ", selectedOption), React__default.createElement(DropdownOptions, {
14855
14863
  className: "rpgui-dropdown-imp",
14856
14864
  opened: opened
14857
- }, options == null ? void 0 : options.map(function (option) {
14865
+ }, options.map(function (option) {
14858
14866
  return React__default.createElement("li", {
14859
14867
  key: option.id,
14860
14868
  onPointerUp: function onPointerUp() {
14861
- handleSelection(option.value, option.option);
14869
+ setSelectedValue(option.value);
14870
+ setSelectedOption(option.option);
14862
14871
  setOpened(false);
14863
14872
  }
14864
14873
  }, option.option);
14865
14874
  })));
14866
14875
  };
14867
- var DropdownDisplay = /*#__PURE__*/styled__default.span.withConfig({
14868
- displayName: "Dropdown__DropdownDisplay",
14869
- componentId: "sc-8arn65-0"
14870
- })(["display:flex;flex-wrap:wrap;justify-content:start;align-items:center;"]);
14871
- var DropdownLabel = /*#__PURE__*/styled__default.label.withConfig({
14872
- displayName: "Dropdown__DropdownLabel",
14873
- componentId: "sc-8arn65-1"
14874
- })(["margin-right:0.5rem;"]);
14875
14876
  var Container$d = /*#__PURE__*/styled__default.div.withConfig({
14876
14877
  displayName: "Dropdown__Container",
14877
- componentId: "sc-8arn65-2"
14878
+ componentId: "sc-8arn65-0"
14878
14879
  })(["position:relative;width:", ";"], function (props) {
14879
14880
  return props.width || '100%';
14880
14881
  });
14881
14882
  var DropdownSelect = /*#__PURE__*/styled__default.p.withConfig({
14882
14883
  displayName: "Dropdown__DropdownSelect",
14883
- componentId: "sc-8arn65-3"
14884
+ componentId: "sc-8arn65-1"
14884
14885
  })(["width:100%;box-sizing:border-box;label{display:inline-block;transform:translateY(-2px);}"]);
14885
14886
  var DropdownOptions = /*#__PURE__*/styled__default.ul.withConfig({
14886
14887
  displayName: "Dropdown__DropdownOptions",
14887
- componentId: "sc-8arn65-4"
14888
+ componentId: "sc-8arn65-2"
14888
14889
  })(["position:absolute;width:100%;max-height:300px;overflow-y:auto;display:", ";box-sizing:border-box;@media (max-width:768px){padding:8px 0;}"], function (props) {
14889
14890
  return props.opened ? 'block' : 'none';
14890
14891
  });