@rpg-engine/long-bow 0.5.60 → 0.5.61
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/components/Dropdown.d.ts +1 -0
- package/dist/long-bow.cjs.development.js +16 -6
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +16 -6
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Dropdown.tsx +13 -4
- package/src/stories/Dropdown.stories.tsx +1 -0
|
@@ -14798,26 +14798,36 @@ var ItemTypes = /*#__PURE__*/styled__default.div.withConfig({
|
|
|
14798
14798
|
})(["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
14799
|
|
|
14800
14800
|
var Dropdown = function Dropdown(_ref) {
|
|
14801
|
-
var _options$, _options$2;
|
|
14801
|
+
var _options$, _options$find, _options$2;
|
|
14802
14802
|
var options = _ref.options,
|
|
14803
14803
|
width = _ref.width,
|
|
14804
|
-
onChange = _ref.onChange
|
|
14804
|
+
onChange = _ref.onChange,
|
|
14805
|
+
defaultValue = _ref.defaultValue;
|
|
14805
14806
|
var dropdownId = uuid.v4();
|
|
14806
|
-
var _useState = React.useState(options == null ? void 0 : (_options$ = options[0]) == null ? void 0 : _options$.value),
|
|
14807
|
+
var _useState = React.useState(defaultValue || (options == null ? void 0 : (_options$ = options[0]) == null ? void 0 : _options$.value)),
|
|
14807
14808
|
selectedValue = _useState[0],
|
|
14808
14809
|
setSelectedValue = _useState[1];
|
|
14809
|
-
var _useState2 = React.useState(options == null ? void 0 : (_options$
|
|
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)),
|
|
14810
14813
|
selectedOption = _useState2[0],
|
|
14811
14814
|
setSelectedOption = _useState2[1];
|
|
14812
14815
|
var _useState3 = React.useState(false),
|
|
14813
14816
|
opened = _useState3[0],
|
|
14814
14817
|
setOpened = _useState3[1];
|
|
14815
14818
|
React.useEffect(function () {
|
|
14816
|
-
if (
|
|
14819
|
+
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) {
|
|
14817
14827
|
setSelectedValue(options[0].value);
|
|
14818
14828
|
setSelectedOption(options[0].option);
|
|
14819
14829
|
}
|
|
14820
|
-
}, [options]);
|
|
14830
|
+
}, [options, defaultValue]);
|
|
14821
14831
|
var handleSelection = function handleSelection(value, option) {
|
|
14822
14832
|
if (value !== selectedValue) {
|
|
14823
14833
|
setSelectedValue(value);
|