@rpg-engine/long-bow 0.5.58 → 0.5.60

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.
@@ -8,6 +8,5 @@ export interface IDropdownProps {
8
8
  options: IOptionsProps[];
9
9
  width?: string;
10
10
  onChange: (value: string) => void;
11
- triggerOnChangeOnMount?: boolean;
12
11
  }
13
12
  export declare const Dropdown: React.FC<IDropdownProps>;
@@ -17,6 +17,7 @@ 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');
20
21
  var ai = require('react-icons/ai');
21
22
  require('rpgui/rpgui.css');
22
23
  require('rpgui/rpgui.min.js');
@@ -14800,9 +14801,7 @@ var Dropdown = function Dropdown(_ref) {
14800
14801
  var _options$, _options$2;
14801
14802
  var options = _ref.options,
14802
14803
  width = _ref.width,
14803
- onChange = _ref.onChange,
14804
- _ref$triggerOnChangeO = _ref.triggerOnChangeOnMount,
14805
- triggerOnChangeOnMount = _ref$triggerOnChangeO === void 0 ? true : _ref$triggerOnChangeO;
14804
+ onChange = _ref.onChange;
14806
14805
  var dropdownId = uuid.v4();
14807
14806
  var _useState = React.useState(options == null ? void 0 : (_options$ = options[0]) == null ? void 0 : _options$.value),
14808
14807
  selectedValue = _useState[0],
@@ -14813,6 +14812,12 @@ var Dropdown = function Dropdown(_ref) {
14813
14812
  var _useState3 = React.useState(false),
14814
14813
  opened = _useState3[0],
14815
14814
  setOpened = _useState3[1];
14815
+ React.useEffect(function () {
14816
+ if ((options == null ? void 0 : options.length) > 0) {
14817
+ setSelectedValue(options[0].value);
14818
+ setSelectedOption(options[0].option);
14819
+ }
14820
+ }, [options]);
14816
14821
  var handleSelection = function handleSelection(value, option) {
14817
14822
  if (value !== selectedValue) {
14818
14823
  setSelectedValue(value);
@@ -14820,11 +14825,6 @@ var Dropdown = function Dropdown(_ref) {
14820
14825
  onChange(value);
14821
14826
  }
14822
14827
  };
14823
- React.useEffect(function () {
14824
- if (triggerOnChangeOnMount) {
14825
- onChange(selectedValue);
14826
- }
14827
- }, []);
14828
14828
  return React__default.createElement(Container$d, {
14829
14829
  onMouseLeave: function onMouseLeave() {
14830
14830
  return setOpened(false);
@@ -14838,10 +14838,13 @@ var Dropdown = function Dropdown(_ref) {
14838
14838
  return !prev;
14839
14839
  });
14840
14840
  }
14841
- }, React__default.createElement("label", null, "\u25BC"), " ", selectedOption), React__default.createElement(DropdownOptions, {
14841
+ }, React__default.createElement(DropdownDisplay, null, React__default.createElement(DropdownLabel, null, "\u25BC"), " ", selectedOption, !options.length && React__default.createElement(reactSpinners.BeatLoader, {
14842
+ size: 4,
14843
+ color: uiColors.white
14844
+ }))), React__default.createElement(DropdownOptions, {
14842
14845
  className: "rpgui-dropdown-imp",
14843
14846
  opened: opened
14844
- }, options.map(function (option) {
14847
+ }, options == null ? void 0 : options.map(function (option) {
14845
14848
  return React__default.createElement("li", {
14846
14849
  key: option.id,
14847
14850
  onPointerUp: function onPointerUp() {
@@ -14851,19 +14854,27 @@ var Dropdown = function Dropdown(_ref) {
14851
14854
  }, option.option);
14852
14855
  })));
14853
14856
  };
14857
+ var DropdownDisplay = /*#__PURE__*/styled__default.span.withConfig({
14858
+ displayName: "Dropdown__DropdownDisplay",
14859
+ componentId: "sc-8arn65-0"
14860
+ })(["display:flex;flex-wrap:wrap;justify-content:start;align-items:center;"]);
14861
+ var DropdownLabel = /*#__PURE__*/styled__default.label.withConfig({
14862
+ displayName: "Dropdown__DropdownLabel",
14863
+ componentId: "sc-8arn65-1"
14864
+ })(["margin-right:0.5rem;"]);
14854
14865
  var Container$d = /*#__PURE__*/styled__default.div.withConfig({
14855
14866
  displayName: "Dropdown__Container",
14856
- componentId: "sc-8arn65-0"
14867
+ componentId: "sc-8arn65-2"
14857
14868
  })(["position:relative;width:", ";"], function (props) {
14858
14869
  return props.width || '100%';
14859
14870
  });
14860
14871
  var DropdownSelect = /*#__PURE__*/styled__default.p.withConfig({
14861
14872
  displayName: "Dropdown__DropdownSelect",
14862
- componentId: "sc-8arn65-1"
14873
+ componentId: "sc-8arn65-3"
14863
14874
  })(["width:100%;box-sizing:border-box;label{display:inline-block;transform:translateY(-2px);}"]);
14864
14875
  var DropdownOptions = /*#__PURE__*/styled__default.ul.withConfig({
14865
14876
  displayName: "Dropdown__DropdownOptions",
14866
- componentId: "sc-8arn65-2"
14877
+ componentId: "sc-8arn65-4"
14867
14878
  })(["position:absolute;width:100%;max-height:300px;overflow-y:auto;display:", ";box-sizing:border-box;@media (max-width:768px){padding:8px 0;}"], function (props) {
14868
14879
  return props.opened ? 'block' : 'none';
14869
14880
  });