@rpg-engine/long-bow 0.5.53 → 0.5.55
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/long-bow.cjs.development.js +16 -20
- 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 -20
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Dropdown.tsx +24 -34
- package/src/components/SkillsContainer.tsx +4 -0
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
4
|
|
|
@@ -21,37 +21,29 @@ export const Dropdown: React.FC<IDropdownProps> = ({
|
|
|
21
21
|
}) => {
|
|
22
22
|
const dropdownId = uuidv4();
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const firstOption = useMemo(() => options[0], [options]);
|
|
25
|
+
const [selectedValue, setSelectedValue] = useState<string>(
|
|
26
|
+
firstOption ? firstOption.value : ''
|
|
27
|
+
);
|
|
25
28
|
const [selectedOption, setSelectedOption] = useState<string | JSX.Element>(
|
|
26
|
-
''
|
|
29
|
+
firstOption ? firstOption.option : ''
|
|
27
30
|
);
|
|
28
31
|
const [opened, setOpened] = useState<boolean>(false);
|
|
29
32
|
|
|
30
33
|
useEffect(() => {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
if (firstOption) {
|
|
34
|
-
let change = !selectedValue;
|
|
35
|
-
if (!change) {
|
|
36
|
-
change = options.filter(o => o.value === selectedValue).length < 1;
|
|
37
|
-
}
|
|
34
|
+
const optionValues = new Set(options.map(option => option.value));
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*/
|
|
43
|
-
if (change) {
|
|
44
|
-
setSelectedValue(firstOption.value);
|
|
45
|
-
setSelectedOption(firstOption.option);
|
|
46
|
-
}
|
|
36
|
+
if (!selectedValue || !optionValues.has(selectedValue)) {
|
|
37
|
+
setSelectedValue(firstOption.value);
|
|
38
|
+
setSelectedOption(firstOption.option);
|
|
47
39
|
}
|
|
48
|
-
}, [options]);
|
|
40
|
+
}, [firstOption, options, selectedValue]);
|
|
49
41
|
|
|
50
42
|
useEffect(() => {
|
|
51
43
|
if (selectedValue) {
|
|
52
44
|
onChange(selectedValue);
|
|
53
45
|
}
|
|
54
|
-
}, [selectedValue]);
|
|
46
|
+
}, [selectedValue, onChange]);
|
|
55
47
|
|
|
56
48
|
return (
|
|
57
49
|
<Container onMouseLeave={() => setOpened(false)} width={width}>
|
|
@@ -64,20 +56,18 @@ export const Dropdown: React.FC<IDropdownProps> = ({
|
|
|
64
56
|
</DropdownSelect>
|
|
65
57
|
|
|
66
58
|
<DropdownOptions className="rpgui-dropdown-imp" opened={opened}>
|
|
67
|
-
{options.map(option =>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
);
|
|
80
|
-
})}
|
|
59
|
+
{options.map(option => (
|
|
60
|
+
<li
|
|
61
|
+
key={option.id}
|
|
62
|
+
onPointerUp={() => {
|
|
63
|
+
setSelectedValue(option.value);
|
|
64
|
+
setSelectedOption(option.option);
|
|
65
|
+
setOpened(false);
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
{option.option}
|
|
69
|
+
</li>
|
|
70
|
+
))}
|
|
81
71
|
</DropdownOptions>
|
|
82
72
|
</Container>
|
|
83
73
|
);
|
|
@@ -126,6 +126,10 @@ export const SkillsContainer: React.FC<ISkillContainerProps> = ({
|
|
|
126
126
|
//@ts-ignore
|
|
127
127
|
const skillDetails = (skill[key] as unknown) as ISkillDetails;
|
|
128
128
|
|
|
129
|
+
if (!skillDetails) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
|
|
129
133
|
output.push(
|
|
130
134
|
<SkillProgressBar
|
|
131
135
|
key={key}
|