@rpg-engine/long-bow 0.5.75 → 0.5.77

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.5.75",
3
+ "version": "0.5.77",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -15,6 +15,7 @@ export interface IAsyncDropdownProps {
15
15
  width?: string;
16
16
  onChange: (value: string) => void;
17
17
  defaultValue?: string;
18
+ opensUp?: boolean;
18
19
  }
19
20
 
20
21
  export const AsyncDropdown: React.FC<IAsyncDropdownProps> = ({
@@ -22,6 +23,7 @@ export const AsyncDropdown: React.FC<IAsyncDropdownProps> = ({
22
23
  width,
23
24
  onChange,
24
25
  defaultValue,
26
+ opensUp = false,
25
27
  }) => {
26
28
  const dropdownId = uuidv4();
27
29
 
@@ -68,7 +70,11 @@ export const AsyncDropdown: React.FC<IAsyncDropdownProps> = ({
68
70
  </DropdownDisplay>
69
71
  </DropdownSelect>
70
72
 
71
- <DropdownOptions className="rpgui-dropdown-imp" opened={opened}>
73
+ <DropdownOptions
74
+ className="rpgui-dropdown-imp"
75
+ opened={opened}
76
+ opensUp={opensUp}
77
+ >
72
78
  {options?.map(option => (
73
79
  <li
74
80
  key={option.id}
@@ -113,6 +119,7 @@ const DropdownSelect = styled.p`
113
119
 
114
120
  const DropdownOptions = styled.ul<{
115
121
  opened: boolean;
122
+ opensUp: boolean; // Add a new prop to the styled component
116
123
  }>`
117
124
  position: absolute;
118
125
  width: 100%;
@@ -120,6 +127,12 @@ const DropdownOptions = styled.ul<{
120
127
  overflow-y: auto;
121
128
  display: ${props => (props.opened ? 'block' : 'none')};
122
129
  box-sizing: border-box;
130
+ bottom: ${props =>
131
+ props.opensUp ? '100%' : 'auto'}; // Adjust the position based on the prop
132
+ top: ${props =>
133
+ props.opensUp ? 'auto' : '100%'}; // Adjust the position based on the prop
134
+ margin: 0; // Remove default margin
135
+ padding: 0; // Remove default padding
123
136
 
124
137
  @media (max-width: 768px) {
125
138
  padding: 8px 0;
@@ -12,12 +12,14 @@ export interface IDropdownProps {
12
12
  options: IOptionsProps[];
13
13
  width?: string;
14
14
  onChange: (value: string) => void;
15
+ opensUp?: boolean; // Add a new prop to control the dropdown direction
15
16
  }
16
17
 
17
18
  export const Dropdown: React.FC<IDropdownProps> = ({
18
19
  options,
19
20
  width,
20
21
  onChange,
22
+ opensUp = false, // Default value is false
21
23
  }) => {
22
24
  const dropdownId = uuidv4();
23
25
 
@@ -36,10 +38,6 @@ export const Dropdown: React.FC<IDropdownProps> = ({
36
38
  change = options.filter(o => o.value === selectedValue).length < 1;
37
39
  }
38
40
 
39
- /**
40
- * make a selection if there is no selected value already present
41
- * or if there is a selected value but its not in new options
42
- */
43
41
  if (change) {
44
42
  setSelectedValue(firstOption.value);
45
43
  setSelectedOption(firstOption.option);
@@ -63,7 +61,11 @@ export const Dropdown: React.FC<IDropdownProps> = ({
63
61
  <label>▼</label> {selectedOption}
64
62
  </DropdownSelect>
65
63
 
66
- <DropdownOptions className="rpgui-dropdown-imp" opened={opened}>
64
+ <DropdownOptions
65
+ className="rpgui-dropdown-imp"
66
+ opened={opened}
67
+ opensUp={opensUp}
68
+ >
67
69
  {options.map(option => {
68
70
  return (
69
71
  <li
@@ -100,6 +102,7 @@ const DropdownSelect = styled.p`
100
102
 
101
103
  const DropdownOptions = styled.ul<{
102
104
  opened: boolean;
105
+ opensUp: boolean; // Add a new prop to the styled component
103
106
  }>`
104
107
  position: absolute;
105
108
  width: 100%;
@@ -107,7 +110,12 @@ const DropdownOptions = styled.ul<{
107
110
  overflow-y: auto;
108
111
  display: ${props => (props.opened ? 'block' : 'none')};
109
112
  box-sizing: border-box;
110
-
113
+ bottom: ${props =>
114
+ props.opensUp ? '100%' : 'auto'}; // Adjust the position based on the prop
115
+ top: ${props =>
116
+ props.opensUp ? 'auto' : '100%'}; // Adjust the position based on the prop
117
+ margin: 0;
118
+ padding: 0;
111
119
  @media (max-width: 768px) {
112
120
  padding: 8px 0;
113
121
  }
@@ -1,5 +1,6 @@
1
1
  import { Meta, Story } from '@storybook/react';
2
2
  import React from 'react';
3
+ import styled from 'styled-components';
3
4
  import { RPGUIRoot } from '../../src';
4
5
  import {
5
6
  Dropdown,
@@ -14,12 +15,18 @@ const meta: Meta = {
14
15
 
15
16
  export default meta;
16
17
 
17
- const Template: Story<IDropdownProps> = (args) => (
18
+ const Template: Story<IDropdownProps> = args => (
18
19
  <RPGUIRoot>
19
- <Dropdown {...args} />
20
+ <PushUp>
21
+ <Dropdown {...args} />
22
+ </PushUp>
20
23
  </RPGUIRoot>
21
24
  );
22
25
 
26
+ const PushUp = styled.div`
27
+ margin-top: 200px;
28
+ `;
29
+
23
30
  export const Default = Template.bind({});
24
31
 
25
32
  const options: IOptionsProps[] = [
@@ -43,4 +50,5 @@ const options: IOptionsProps[] = [
43
50
  Default.args = {
44
51
  options,
45
52
  width: '100%',
53
+ opensUp: false,
46
54
  };