@rpg-engine/long-bow 0.5.58 → 0.5.59

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,13 @@ 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
+ onChange(options[0].value);
14820
+ }
14821
+ }, [options]);
14816
14822
  var handleSelection = function handleSelection(value, option) {
14817
14823
  if (value !== selectedValue) {
14818
14824
  setSelectedValue(value);
@@ -14820,11 +14826,6 @@ var Dropdown = function Dropdown(_ref) {
14820
14826
  onChange(value);
14821
14827
  }
14822
14828
  };
14823
- React.useEffect(function () {
14824
- if (triggerOnChangeOnMount) {
14825
- onChange(selectedValue);
14826
- }
14827
- }, []);
14828
14829
  return React__default.createElement(Container$d, {
14829
14830
  onMouseLeave: function onMouseLeave() {
14830
14831
  return setOpened(false);
@@ -14838,10 +14839,13 @@ var Dropdown = function Dropdown(_ref) {
14838
14839
  return !prev;
14839
14840
  });
14840
14841
  }
14841
- }, React__default.createElement("label", null, "\u25BC"), " ", selectedOption), React__default.createElement(DropdownOptions, {
14842
+ }, React__default.createElement(DropdownDisplay, null, React__default.createElement(DropdownLabel, null, "\u25BC"), " ", selectedOption, !options.length && React__default.createElement(reactSpinners.BeatLoader, {
14843
+ size: 4,
14844
+ color: uiColors.white
14845
+ }))), React__default.createElement(DropdownOptions, {
14842
14846
  className: "rpgui-dropdown-imp",
14843
14847
  opened: opened
14844
- }, options.map(function (option) {
14848
+ }, options == null ? void 0 : options.map(function (option) {
14845
14849
  return React__default.createElement("li", {
14846
14850
  key: option.id,
14847
14851
  onPointerUp: function onPointerUp() {
@@ -14851,19 +14855,27 @@ var Dropdown = function Dropdown(_ref) {
14851
14855
  }, option.option);
14852
14856
  })));
14853
14857
  };
14858
+ var DropdownDisplay = /*#__PURE__*/styled__default.span.withConfig({
14859
+ displayName: "Dropdown__DropdownDisplay",
14860
+ componentId: "sc-8arn65-0"
14861
+ })(["display:flex;flex-wrap:wrap;justify-content:start;align-items:center;"]);
14862
+ var DropdownLabel = /*#__PURE__*/styled__default.label.withConfig({
14863
+ displayName: "Dropdown__DropdownLabel",
14864
+ componentId: "sc-8arn65-1"
14865
+ })(["margin-right:0.5rem;"]);
14854
14866
  var Container$d = /*#__PURE__*/styled__default.div.withConfig({
14855
14867
  displayName: "Dropdown__Container",
14856
- componentId: "sc-8arn65-0"
14868
+ componentId: "sc-8arn65-2"
14857
14869
  })(["position:relative;width:", ";"], function (props) {
14858
14870
  return props.width || '100%';
14859
14871
  });
14860
14872
  var DropdownSelect = /*#__PURE__*/styled__default.p.withConfig({
14861
14873
  displayName: "Dropdown__DropdownSelect",
14862
- componentId: "sc-8arn65-1"
14874
+ componentId: "sc-8arn65-3"
14863
14875
  })(["width:100%;box-sizing:border-box;label{display:inline-block;transform:translateY(-2px);}"]);
14864
14876
  var DropdownOptions = /*#__PURE__*/styled__default.ul.withConfig({
14865
14877
  displayName: "Dropdown__DropdownOptions",
14866
- componentId: "sc-8arn65-2"
14878
+ componentId: "sc-8arn65-4"
14867
14879
  })(["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
14880
  return props.opened ? 'block' : 'none';
14869
14881
  });