@rpg-engine/long-bow 0.3.88 → 0.3.90

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.3.88",
3
+ "version": "0.3.90",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -238,4 +238,7 @@ const ButtonWrapper = styled.div`
238
238
  justify-content: space-around;
239
239
  padding-top: 20px;
240
240
  width: 100%;
241
+ button {
242
+ padding: 0px 50px;
243
+ }
241
244
  `;
@@ -146,6 +146,10 @@ const CloseButton = styled.div`
146
146
  color: white;
147
147
  z-index: 22;
148
148
  font-size: 1.1rem;
149
+ @media (max-width: 768px) {
150
+ font-size: 1.3rem;
151
+ padding: 3px;
152
+ }
149
153
  `;
150
154
 
151
155
  const TitleContainer = styled.div`
@@ -28,9 +28,20 @@ export const Dropdown: React.FC<IDropdownProps> = ({
28
28
  useEffect(() => {
29
29
  const firstOption = options[0];
30
30
 
31
- if (firstOption && !selectedValue) {
32
- setSelectedValue(firstOption.value);
33
- setSelectedOption(firstOption.option);
31
+ if (firstOption) {
32
+ let change = !selectedValue;
33
+ if (!change) {
34
+ change = options.filter((o) => o.value === selectedValue).length < 1;
35
+ }
36
+
37
+ /**
38
+ * make a selection if there is no selected value already present
39
+ * or if there is a selected value but its not in new options
40
+ */
41
+ if (change) {
42
+ setSelectedValue(firstOption.value);
43
+ setSelectedOption(firstOption.option);
44
+ }
34
45
  }
35
46
  }, [options]);
36
47
 
@@ -45,13 +56,13 @@ export const Dropdown: React.FC<IDropdownProps> = ({
45
56
  <DropdownSelect
46
57
  id={`dropdown-${dropdownId}`}
47
58
  className="rpgui-dropdown-imp rpgui-dropdown-imp-header"
48
- onPointerDown={() => setOpened(prev => !prev)}
59
+ onPointerDown={() => setOpened((prev) => !prev)}
49
60
  >
50
61
  <label>▼</label> {selectedOption}
51
62
  </DropdownSelect>
52
63
 
53
64
  <DropdownOptions className="rpgui-dropdown-imp" opened={opened}>
54
- {options.map(option => {
65
+ {options.map((option) => {
55
66
  return (
56
67
  <li
57
68
  key={option.id}
@@ -72,7 +83,7 @@ export const Dropdown: React.FC<IDropdownProps> = ({
72
83
 
73
84
  const Container = styled.div<{ width: string | undefined }>`
74
85
  position: relative;
75
- width: ${props => props.width || '100%'};
86
+ width: ${(props) => props.width || '100%'};
76
87
  `;
77
88
 
78
89
  const DropdownSelect = styled.p`
@@ -85,6 +96,9 @@ const DropdownOptions = styled.ul<{
85
96
  }>`
86
97
  position: absolute;
87
98
  width: 100%;
88
- display: ${props => (props.opened ? 'block' : 'none')};
99
+ display: ${(props) => (props.opened ? 'block' : 'none')};
89
100
  box-sizing: border-box;
101
+ @media (max-width: 768px) {
102
+ padding: 8px 0;
103
+ }
90
104
  `;
@@ -88,6 +88,12 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
88
88
  });
89
89
  const [settingShortcutIndex, setSettingShortcutIndex] = useState(-1);
90
90
 
91
+ const handleSetShortcut = (item: IItem, index: number) => {
92
+ if (item.type === ItemType.Consumable || item.type === ItemType.Tool) {
93
+ setItemShortcut?.(item.key, index);
94
+ }
95
+ };
96
+
91
97
  const onRenderSlots = () => {
92
98
  const slots = [];
93
99
 
@@ -106,12 +112,7 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
106
112
  if (settingShortcutIndex !== -1) {
107
113
  setSettingShortcutIndex(-1);
108
114
 
109
- if (
110
- itemType === ItemType.Consumable ||
111
- itemType === ItemType.Tool
112
- ) {
113
- setItemShortcut?.(item.key, settingShortcutIndex);
114
- }
115
+ handleSetShortcut(item, settingShortcutIndex);
115
116
  } else if (onItemClick) onItemClick(item, itemType, containerType);
116
117
  }}
117
118
  onSelected={(optionId: string, item: IItem) => {
@@ -145,6 +146,9 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
145
146
  atlasJSON={atlasJSON}
146
147
  isSelectingShortcut={settingShortcutIndex !== -1}
147
148
  equipmentSet={equipmentSet}
149
+ setItemShortcut={
150
+ type === ItemContainerType.Inventory ? handleSetShortcut : undefined
151
+ }
148
152
  isDepotSystem={isDepotSystem}
149
153
  />
150
154
  );
@@ -78,6 +78,7 @@ interface IProps {
78
78
  isContextMenuDisabled?: boolean;
79
79
  isSelectingShortcut?: boolean;
80
80
  equipmentSet?: IEquipmentSet | null;
81
+ setItemShortcut?: (item: IItem, shortcutIndex: number) => void;
81
82
  isDepotSystem?: boolean;
82
83
  }
83
84
 
@@ -104,6 +105,7 @@ export const ItemSlot: React.FC<IProps> = observer(
104
105
  dragScale,
105
106
  isSelectingShortcut,
106
107
  equipmentSet,
108
+ setItemShortcut,
107
109
  isDepotSystem,
108
110
  }) => {
109
111
  const [isTooltipVisible, setTooltipVisible] = useState(false);
@@ -310,6 +312,18 @@ export const ItemSlot: React.FC<IProps> = observer(
310
312
  defaultClassName={item ? 'draggable' : 'empty-slot'}
311
313
  scale={dragScale}
312
314
  onStop={(e, data) => {
315
+ const target = e.target as HTMLElement;
316
+ if (
317
+ target?.id.includes('shortcutSetter') &&
318
+ setItemShortcut &&
319
+ item
320
+ ) {
321
+ const index = parseInt(target.id.split('_')[1]);
322
+ if (!isNaN(index)) {
323
+ setItemShortcut(item, index);
324
+ }
325
+ }
326
+
313
327
  if (wasDragged && item && !isSelectingShortcut) {
314
328
  //@ts-ignore
315
329
  const classes: string[] = Array.from(e.target?.classList);
@@ -67,12 +67,18 @@ export const ShortcutsSetter: React.FC<ShortcutsSetterProps> = ({
67
67
  <Shortcut
68
68
  key={i}
69
69
  onPointerDown={() => {
70
+ if (settingShortcutIndex !== -1) setSettingShortcutIndex(-1);
71
+
70
72
  removeShortcut(i);
71
- if (!shortcuts[i] || shortcuts[i].type === ShortcutType.None)
73
+ if (
74
+ settingShortcutIndex === -1 &&
75
+ (!shortcuts[i] || shortcuts[i].type === ShortcutType.None)
76
+ )
72
77
  setSettingShortcutIndex(i);
73
78
  }}
74
79
  disabled={settingShortcutIndex !== -1 && settingShortcutIndex !== i}
75
80
  isBeingSet={settingShortcutIndex === i}
81
+ id={`shortcutSetter_${i}`}
76
82
  >
77
83
  {getContent(i)}
78
84
  </Shortcut>
@@ -213,4 +213,7 @@ const ButtonWrapper = styled.div`
213
213
  padding-top: 20px;
214
214
  width: 100%;
215
215
  margin-top: 1rem;
216
+ button {
217
+ padding: 0px 50px;
218
+ }
216
219
  `;
@@ -14,7 +14,7 @@ const meta: Meta = {
14
14
 
15
15
  export default meta;
16
16
 
17
- const Template: Story<IDropdownProps> = args => (
17
+ const Template: Story<IDropdownProps> = (args) => (
18
18
  <RPGUIRoot>
19
19
  <Dropdown {...args} />
20
20
  </RPGUIRoot>