@rpg-engine/long-bow 0.1.91 → 0.1.92
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/LICENSE +20 -20
- package/README.md +181 -181
- package/dist/components/Item/Inventory/itemContainerHelper.d.ts +2 -2
- package/dist/long-bow.cjs.development.js +49 -2
- 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 +49 -2
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +98 -98
- package/src/components/Abstractions/SlotsContainer.tsx +42 -42
- package/src/components/Button.tsx +30 -30
- package/src/components/Chat/Chat.tsx +193 -193
- package/src/components/CheckButton.tsx +65 -65
- package/src/components/DraggableContainer.tsx +150 -150
- package/src/components/Dropdown.tsx +57 -57
- package/src/components/Equipment/EquipmentSet.tsx +134 -134
- package/src/components/Input.tsx +11 -11
- package/src/components/Item/Cards/ItemTooltip.tsx +32 -32
- package/src/components/Item/Inventory/ItemContainer.tsx +65 -65
- package/src/components/Item/Inventory/ItemContainerTypes.ts +4 -4
- package/src/components/Item/Inventory/ItemSlot.tsx +199 -199
- package/src/components/Item/Inventory/itemContainerHelper.ts +94 -81
- package/src/components/ListMenu.tsx +65 -65
- package/src/components/Multitab/Tab.tsx +57 -57
- package/src/components/Multitab/TabBody.tsx +13 -13
- package/src/components/Multitab/TabsContainer.tsx +97 -97
- package/src/components/NPCDialog/NPCDialog.tsx +145 -145
- package/src/components/NPCDialog/NPCDialogText.tsx +53 -53
- package/src/components/NPCDialog/QuestionDialog/QuestionDialog.tsx +239 -239
- package/src/components/ProgressBar.tsx +91 -91
- package/src/components/PropertySelect/PropertySelect.tsx +101 -101
- package/src/components/PropertySelect/img/ui-arrows/arrow01-left-clicked.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow01-left.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow01-right-clicked.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow01-right.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow02-left-clicked.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow02-left.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow02-right-clicked.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow02-right.png +0 -0
- package/src/components/QuestInfo/QuestInfo.tsx +143 -143
- package/src/components/RPGUIContainer.tsx +47 -47
- package/src/components/RPGUIRoot.tsx +14 -14
- package/src/components/RadioButton.tsx +53 -53
- package/src/components/RangeSlider.tsx +68 -68
- package/src/components/RelativeListMenu.tsx +83 -83
- package/src/components/ScrollList.tsx +77 -77
- package/src/components/SimpleProgressBar.tsx +62 -62
- package/src/components/SkillProgressBar.tsx +123 -123
- package/src/components/SkillsContainer.tsx +196 -196
- package/src/components/TextArea.tsx +11 -11
- package/src/components/Truncate.tsx +25 -25
- package/src/components/shared/Column.tsx +16 -16
- package/src/components/shared/SpriteFromAtlas.tsx +99 -99
- package/src/components/typography/DynamicText.tsx +49 -49
- package/src/constants/uiColors.ts +10 -10
- package/src/hooks/useEventListener.ts +21 -21
- package/src/hooks/useOutsideAlerter.ts +25 -25
- package/src/index.tsx +25 -25
- package/src/libs/StringHelpers.ts +3 -3
- package/src/mocks/atlas/icons/icons.json +735 -735
- package/src/mocks/atlas/items/items.json +5215 -5215
- package/src/mocks/equipmentSet.mocks.ts +347 -347
- package/src/mocks/itemContainer.mocks.ts +249 -249
- package/src/mocks/skills.mocks.ts +122 -122
- package/src/stories/Button.stories.tsx +36 -36
- package/src/stories/Chat.stories.tsx +170 -170
- package/src/stories/CheckButton.stories.tsx +48 -48
- package/src/stories/DraggableContainer.stories.tsx +28 -28
- package/src/stories/Dropdown.stories.tsx +46 -46
- package/src/stories/EquipmentSet.stories.tsx +50 -50
- package/src/stories/ItemContainer.stories.tsx +50 -50
- package/src/stories/ListMenu.stories.tsx +56 -56
- package/src/stories/Multitab.stories.tsx +51 -51
- package/src/stories/NPCDialog.stories.tsx +130 -130
- package/src/stories/ProgressBar.stories.tsx +23 -23
- package/src/stories/PropertySelect.stories.tsx +41 -41
- package/src/stories/QuestInfo.stories.tsx +76 -76
- package/src/stories/RPGUIContainers.stories.tsx +42 -42
- package/src/stories/RadioButton.stories.tsx +49 -49
- package/src/stories/RangeSlider.stories.tsx +60 -60
- package/src/stories/ScrollList.stories.tsx +85 -85
- package/src/stories/SimpleProgressBar.stories.tsx +22 -22
- package/src/stories/SkillProgressBar.stories.tsx +30 -30
- package/src/stories/SkillsContainer.stories.tsx +31 -31
- package/src/stories/Text.stories.tsx +42 -42
- package/src/types/eventTypes.ts +4 -4
- package/src/types/index.d.ts +2 -2
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/* eslint-disable react/require-default-props */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
|
|
5
|
-
interface IProps {
|
|
6
|
-
maxLines?: number;
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const Truncate: React.FC<IProps> = ({ maxLines = 1, children }) => {
|
|
11
|
-
return <Container maxLines={maxLines}>{children}</Container>;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
interface IContainerProps {
|
|
15
|
-
maxLines: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const Container = styled.div<IContainerProps>`
|
|
19
|
-
display: -webkit-box;
|
|
20
|
-
max-width: 100%;
|
|
21
|
-
max-height: 100%;
|
|
22
|
-
-webkit-line-clamp: ${props => props.maxLines};
|
|
23
|
-
-webkit-box-orient: vertical;
|
|
24
|
-
overflow: hidden;
|
|
25
|
-
`;
|
|
1
|
+
/* eslint-disable react/require-default-props */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
|
|
5
|
+
interface IProps {
|
|
6
|
+
maxLines?: number;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const Truncate: React.FC<IProps> = ({ maxLines = 1, children }) => {
|
|
11
|
+
return <Container maxLines={maxLines}>{children}</Container>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
interface IContainerProps {
|
|
15
|
+
maxLines: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const Container = styled.div<IContainerProps>`
|
|
19
|
+
display: -webkit-box;
|
|
20
|
+
max-width: 100%;
|
|
21
|
+
max-height: 100%;
|
|
22
|
+
-webkit-line-clamp: ${props => props.maxLines};
|
|
23
|
+
-webkit-box-orient: vertical;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
`;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
interface IColumn {
|
|
4
|
-
flex?: number;
|
|
5
|
-
alignItems?: string;
|
|
6
|
-
justifyContent?: string;
|
|
7
|
-
flexWrap?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const Column = styled.div<IColumn>`
|
|
11
|
-
flex: ${props => props.flex || 'auto'};
|
|
12
|
-
display: flex;
|
|
13
|
-
flex-wrap: ${props => props.flexWrap || 'nowrap'};
|
|
14
|
-
align-items: ${props => props.alignItems || 'flex-start'};
|
|
15
|
-
justify-content: ${props => props.justifyContent || 'flex-start'};
|
|
16
|
-
`;
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
interface IColumn {
|
|
4
|
+
flex?: number;
|
|
5
|
+
alignItems?: string;
|
|
6
|
+
justifyContent?: string;
|
|
7
|
+
flexWrap?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const Column = styled.div<IColumn>`
|
|
11
|
+
flex: ${props => props.flex || 'auto'};
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-wrap: ${props => props.flexWrap || 'nowrap'};
|
|
14
|
+
align-items: ${props => props.alignItems || 'flex-start'};
|
|
15
|
+
justify-content: ${props => props.justifyContent || 'flex-start'};
|
|
16
|
+
`;
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import { GRID_HEIGHT, GRID_WIDTH } from '@rpg-engine/shared';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
|
|
5
|
-
interface IProps {
|
|
6
|
-
atlasJSON: any;
|
|
7
|
-
atlasIMG: any;
|
|
8
|
-
spriteKey: string;
|
|
9
|
-
width?: number;
|
|
10
|
-
height?: number;
|
|
11
|
-
grayScale?: boolean;
|
|
12
|
-
opacity?: number;
|
|
13
|
-
onClick?: () => void;
|
|
14
|
-
containerStyle?: any;
|
|
15
|
-
imgStyle?: any;
|
|
16
|
-
imgScale?: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const SpriteFromAtlas: React.FC<IProps> = ({
|
|
20
|
-
atlasJSON,
|
|
21
|
-
atlasIMG,
|
|
22
|
-
spriteKey,
|
|
23
|
-
width = GRID_WIDTH,
|
|
24
|
-
height = GRID_HEIGHT,
|
|
25
|
-
imgScale = 2,
|
|
26
|
-
imgStyle,
|
|
27
|
-
onClick,
|
|
28
|
-
containerStyle,
|
|
29
|
-
grayScale = false,
|
|
30
|
-
opacity = 1,
|
|
31
|
-
}) => {
|
|
32
|
-
//! If an item is not showing, remember that you MUST run yarn atlas:copy everytime you add a new item to the atlas (it will sync our public folder atlas with src/atlas).
|
|
33
|
-
//!Due to React's limitations, we cannot import it from the public folder directly!
|
|
34
|
-
|
|
35
|
-
const spriteData = atlasJSON.frames[spriteKey];
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<Container
|
|
39
|
-
width={width}
|
|
40
|
-
height={height}
|
|
41
|
-
hasHover={grayScale}
|
|
42
|
-
onClick={onClick}
|
|
43
|
-
style={containerStyle}
|
|
44
|
-
>
|
|
45
|
-
<ImgSprite
|
|
46
|
-
className="sprite-from-atlas-img"
|
|
47
|
-
atlasIMG={atlasIMG}
|
|
48
|
-
frame={spriteData.frame}
|
|
49
|
-
scale={imgScale}
|
|
50
|
-
grayScale={grayScale}
|
|
51
|
-
opacity={opacity}
|
|
52
|
-
style={imgStyle}
|
|
53
|
-
/>
|
|
54
|
-
</Container>
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
interface IImgSpriteProps {
|
|
59
|
-
atlasIMG: any;
|
|
60
|
-
frame: {
|
|
61
|
-
x: number;
|
|
62
|
-
y: number;
|
|
63
|
-
w: number;
|
|
64
|
-
h: number;
|
|
65
|
-
};
|
|
66
|
-
scale: number;
|
|
67
|
-
grayScale: boolean;
|
|
68
|
-
opacity: number;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
interface IContainerProps {
|
|
72
|
-
width: number;
|
|
73
|
-
height: number;
|
|
74
|
-
hasHover: boolean;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const Container = styled.div`
|
|
78
|
-
width: ${(props: IContainerProps) => props.width}px;
|
|
79
|
-
height: ${(props: IContainerProps) => props.height}px;
|
|
80
|
-
${(props: IContainerProps) =>
|
|
81
|
-
!props.hasHover
|
|
82
|
-
? `&:hover {
|
|
83
|
-
filter: sepia(100%) saturate(300%) brightness(70%) hue-rotate(180deg);
|
|
84
|
-
}`
|
|
85
|
-
: ``}
|
|
86
|
-
`;
|
|
87
|
-
|
|
88
|
-
const ImgSprite = styled.div<IImgSpriteProps>`
|
|
89
|
-
width: ${props => props.frame.w}px;
|
|
90
|
-
height: ${props => props.frame.h}px;
|
|
91
|
-
background-image: url(${props => props.atlasIMG});
|
|
92
|
-
background-position: -${props => props.frame.x}px -${props => props.frame.y}px;
|
|
93
|
-
transform: scale(${props => props.scale});
|
|
94
|
-
position: relative;
|
|
95
|
-
top: 8px;
|
|
96
|
-
left: 8px;
|
|
97
|
-
filter: ${props => (props.grayScale ? 'grayscale(100%)' : 'none')};
|
|
98
|
-
opacity: ${props => props.opacity};
|
|
99
|
-
`;
|
|
1
|
+
import { GRID_HEIGHT, GRID_WIDTH } from '@rpg-engine/shared';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
|
|
5
|
+
interface IProps {
|
|
6
|
+
atlasJSON: any;
|
|
7
|
+
atlasIMG: any;
|
|
8
|
+
spriteKey: string;
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
grayScale?: boolean;
|
|
12
|
+
opacity?: number;
|
|
13
|
+
onClick?: () => void;
|
|
14
|
+
containerStyle?: any;
|
|
15
|
+
imgStyle?: any;
|
|
16
|
+
imgScale?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const SpriteFromAtlas: React.FC<IProps> = ({
|
|
20
|
+
atlasJSON,
|
|
21
|
+
atlasIMG,
|
|
22
|
+
spriteKey,
|
|
23
|
+
width = GRID_WIDTH,
|
|
24
|
+
height = GRID_HEIGHT,
|
|
25
|
+
imgScale = 2,
|
|
26
|
+
imgStyle,
|
|
27
|
+
onClick,
|
|
28
|
+
containerStyle,
|
|
29
|
+
grayScale = false,
|
|
30
|
+
opacity = 1,
|
|
31
|
+
}) => {
|
|
32
|
+
//! If an item is not showing, remember that you MUST run yarn atlas:copy everytime you add a new item to the atlas (it will sync our public folder atlas with src/atlas).
|
|
33
|
+
//!Due to React's limitations, we cannot import it from the public folder directly!
|
|
34
|
+
|
|
35
|
+
const spriteData = atlasJSON.frames[spriteKey];
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Container
|
|
39
|
+
width={width}
|
|
40
|
+
height={height}
|
|
41
|
+
hasHover={grayScale}
|
|
42
|
+
onClick={onClick}
|
|
43
|
+
style={containerStyle}
|
|
44
|
+
>
|
|
45
|
+
<ImgSprite
|
|
46
|
+
className="sprite-from-atlas-img"
|
|
47
|
+
atlasIMG={atlasIMG}
|
|
48
|
+
frame={spriteData.frame}
|
|
49
|
+
scale={imgScale}
|
|
50
|
+
grayScale={grayScale}
|
|
51
|
+
opacity={opacity}
|
|
52
|
+
style={imgStyle}
|
|
53
|
+
/>
|
|
54
|
+
</Container>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
interface IImgSpriteProps {
|
|
59
|
+
atlasIMG: any;
|
|
60
|
+
frame: {
|
|
61
|
+
x: number;
|
|
62
|
+
y: number;
|
|
63
|
+
w: number;
|
|
64
|
+
h: number;
|
|
65
|
+
};
|
|
66
|
+
scale: number;
|
|
67
|
+
grayScale: boolean;
|
|
68
|
+
opacity: number;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface IContainerProps {
|
|
72
|
+
width: number;
|
|
73
|
+
height: number;
|
|
74
|
+
hasHover: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const Container = styled.div`
|
|
78
|
+
width: ${(props: IContainerProps) => props.width}px;
|
|
79
|
+
height: ${(props: IContainerProps) => props.height}px;
|
|
80
|
+
${(props: IContainerProps) =>
|
|
81
|
+
!props.hasHover
|
|
82
|
+
? `&:hover {
|
|
83
|
+
filter: sepia(100%) saturate(300%) brightness(70%) hue-rotate(180deg);
|
|
84
|
+
}`
|
|
85
|
+
: ``}
|
|
86
|
+
`;
|
|
87
|
+
|
|
88
|
+
const ImgSprite = styled.div<IImgSpriteProps>`
|
|
89
|
+
width: ${props => props.frame.w}px;
|
|
90
|
+
height: ${props => props.frame.h}px;
|
|
91
|
+
background-image: url(${props => props.atlasIMG});
|
|
92
|
+
background-position: -${props => props.frame.x}px -${props => props.frame.y}px;
|
|
93
|
+
transform: scale(${props => props.scale});
|
|
94
|
+
position: relative;
|
|
95
|
+
top: 8px;
|
|
96
|
+
left: 8px;
|
|
97
|
+
filter: ${props => (props.grayScale ? 'grayscale(100%)' : 'none')};
|
|
98
|
+
opacity: ${props => props.opacity};
|
|
99
|
+
`;
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
|
|
4
|
-
interface IProps {
|
|
5
|
-
text: string;
|
|
6
|
-
onFinish?: () => void;
|
|
7
|
-
onStart?: () => void;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const DynamicText: React.FC<IProps> = ({ text, onFinish, onStart }) => {
|
|
11
|
-
const [textState, setTextState] = useState<string>('');
|
|
12
|
-
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
let i = 0;
|
|
15
|
-
const interval = setInterval(() => {
|
|
16
|
-
// on every interval, show one more character
|
|
17
|
-
|
|
18
|
-
if (i === 0) {
|
|
19
|
-
if (onStart) {
|
|
20
|
-
onStart();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (i < text.length) {
|
|
25
|
-
setTextState(text.substring(0, i + 1));
|
|
26
|
-
i++;
|
|
27
|
-
} else {
|
|
28
|
-
clearInterval(interval);
|
|
29
|
-
if (onFinish) {
|
|
30
|
-
onFinish();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}, 50);
|
|
34
|
-
|
|
35
|
-
return () => {
|
|
36
|
-
clearInterval(interval);
|
|
37
|
-
};
|
|
38
|
-
}, [text]);
|
|
39
|
-
|
|
40
|
-
return <TextContainer>{textState}</TextContainer>;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const TextContainer = styled.p`
|
|
44
|
-
font-size: 0.7rem !important;
|
|
45
|
-
color: white;
|
|
46
|
-
text-shadow: 1px 1px 0px #000000;
|
|
47
|
-
letter-spacing: 1.2px;
|
|
48
|
-
word-break: normal;
|
|
49
|
-
`;
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
interface IProps {
|
|
5
|
+
text: string;
|
|
6
|
+
onFinish?: () => void;
|
|
7
|
+
onStart?: () => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const DynamicText: React.FC<IProps> = ({ text, onFinish, onStart }) => {
|
|
11
|
+
const [textState, setTextState] = useState<string>('');
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
let i = 0;
|
|
15
|
+
const interval = setInterval(() => {
|
|
16
|
+
// on every interval, show one more character
|
|
17
|
+
|
|
18
|
+
if (i === 0) {
|
|
19
|
+
if (onStart) {
|
|
20
|
+
onStart();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (i < text.length) {
|
|
25
|
+
setTextState(text.substring(0, i + 1));
|
|
26
|
+
i++;
|
|
27
|
+
} else {
|
|
28
|
+
clearInterval(interval);
|
|
29
|
+
if (onFinish) {
|
|
30
|
+
onFinish();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}, 50);
|
|
34
|
+
|
|
35
|
+
return () => {
|
|
36
|
+
clearInterval(interval);
|
|
37
|
+
};
|
|
38
|
+
}, [text]);
|
|
39
|
+
|
|
40
|
+
return <TextContainer>{textState}</TextContainer>;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const TextContainer = styled.p`
|
|
44
|
+
font-size: 0.7rem !important;
|
|
45
|
+
color: white;
|
|
46
|
+
text-shadow: 1px 1px 0px #000000;
|
|
47
|
+
letter-spacing: 1.2px;
|
|
48
|
+
word-break: normal;
|
|
49
|
+
`;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export const colors = {
|
|
2
|
-
darkGrey: '#3e3e3e',
|
|
3
|
-
darkYellow: '#FFC857',
|
|
4
|
-
orange: '#E9724C',
|
|
5
|
-
cardinal: '#C5283D',
|
|
6
|
-
raisinBlack: '#191923',
|
|
7
|
-
navyBlue: '#0E79B2',
|
|
8
|
-
purple: '#8C3D8C',
|
|
9
|
-
blue: '#3772FF',
|
|
10
|
-
};
|
|
1
|
+
export const colors = {
|
|
2
|
+
darkGrey: '#3e3e3e',
|
|
3
|
+
darkYellow: '#FFC857',
|
|
4
|
+
orange: '#E9724C',
|
|
5
|
+
cardinal: '#C5283D',
|
|
6
|
+
raisinBlack: '#191923',
|
|
7
|
+
navyBlue: '#0E79B2',
|
|
8
|
+
purple: '#8C3D8C',
|
|
9
|
+
blue: '#3772FF',
|
|
10
|
+
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
//@ts-ignore
|
|
4
|
-
export const useEventListener = (type, handler, el = window) => {
|
|
5
|
-
const savedHandler = React.useRef();
|
|
6
|
-
|
|
7
|
-
React.useEffect(() => {
|
|
8
|
-
savedHandler.current = handler;
|
|
9
|
-
}, [handler]);
|
|
10
|
-
|
|
11
|
-
React.useEffect(() => {
|
|
12
|
-
//@ts-ignore
|
|
13
|
-
const listener = e => savedHandler.current(e);
|
|
14
|
-
|
|
15
|
-
el.addEventListener(type, listener);
|
|
16
|
-
|
|
17
|
-
return () => {
|
|
18
|
-
el.removeEventListener(type, listener);
|
|
19
|
-
};
|
|
20
|
-
}, [type, el]);
|
|
21
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
//@ts-ignore
|
|
4
|
+
export const useEventListener = (type, handler, el = window) => {
|
|
5
|
+
const savedHandler = React.useRef();
|
|
6
|
+
|
|
7
|
+
React.useEffect(() => {
|
|
8
|
+
savedHandler.current = handler;
|
|
9
|
+
}, [handler]);
|
|
10
|
+
|
|
11
|
+
React.useEffect(() => {
|
|
12
|
+
//@ts-ignore
|
|
13
|
+
const listener = e => savedHandler.current(e);
|
|
14
|
+
|
|
15
|
+
el.addEventListener(type, listener);
|
|
16
|
+
|
|
17
|
+
return () => {
|
|
18
|
+
el.removeEventListener(type, listener);
|
|
19
|
+
};
|
|
20
|
+
}, [type, el]);
|
|
21
|
+
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
export function useOutsideClick(ref: any, id: string) {
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
/**
|
|
6
|
-
* Alert if clicked on outside of element
|
|
7
|
-
*/
|
|
8
|
-
function handleClickOutside(event: any) {
|
|
9
|
-
if (ref.current && !ref.current.contains(event.target)) {
|
|
10
|
-
const event = new CustomEvent('clickOutside', {
|
|
11
|
-
detail: {
|
|
12
|
-
id,
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
document.dispatchEvent(event);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
// Bind the event listener
|
|
19
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
20
|
-
return () => {
|
|
21
|
-
// Unbind the event listener on clean up
|
|
22
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
23
|
-
};
|
|
24
|
-
}, [ref]);
|
|
25
|
-
}
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
export function useOutsideClick(ref: any, id: string) {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
/**
|
|
6
|
+
* Alert if clicked on outside of element
|
|
7
|
+
*/
|
|
8
|
+
function handleClickOutside(event: any) {
|
|
9
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
10
|
+
const event = new CustomEvent('clickOutside', {
|
|
11
|
+
detail: {
|
|
12
|
+
id,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
document.dispatchEvent(event);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// Bind the event listener
|
|
19
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
20
|
+
return () => {
|
|
21
|
+
// Unbind the event listener on clean up
|
|
22
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
23
|
+
};
|
|
24
|
+
}, [ref]);
|
|
25
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export * from './components/Button';
|
|
2
|
-
export * from './components/Chat/Chat';
|
|
3
|
-
export * from './components/CheckButton';
|
|
4
|
-
export * from './components/DraggableContainer';
|
|
5
|
-
export * from './components/Dropdown';
|
|
6
|
-
export * from './components/Equipment/EquipmentSet';
|
|
7
|
-
export * from './components/Input';
|
|
8
|
-
export * from './components/Item/Inventory/ItemContainer';
|
|
9
|
-
export * from './components/Item/Inventory/ItemSlot';
|
|
10
|
-
export * from './components/ListMenu';
|
|
11
|
-
export * from './components/NPCDialog/NPCDialog';
|
|
12
|
-
export * from './components/NPCDialog/QuestionDialog/QuestionDialog';
|
|
13
|
-
export * from './components/ProgressBar';
|
|
14
|
-
export * from './components/PropertySelect/PropertySelect';
|
|
15
|
-
export * from './components/RadioButton';
|
|
16
|
-
export * from './components/RangeSlider';
|
|
17
|
-
export * from './components/RPGUIContainer';
|
|
18
|
-
export * from './components/RPGUIRoot';
|
|
19
|
-
export * from './components/shared/SpriteFromAtlas';
|
|
20
|
-
export * from './components/SkillProgressBar';
|
|
21
|
-
export * from './components/SkillsContainer';
|
|
22
|
-
export * from './components/TextArea';
|
|
23
|
-
export * from './components/Truncate';
|
|
24
|
-
export * from './components/typography/DynamicText';
|
|
25
|
-
export { useEventListener } from './hooks/useEventListener';
|
|
1
|
+
export * from './components/Button';
|
|
2
|
+
export * from './components/Chat/Chat';
|
|
3
|
+
export * from './components/CheckButton';
|
|
4
|
+
export * from './components/DraggableContainer';
|
|
5
|
+
export * from './components/Dropdown';
|
|
6
|
+
export * from './components/Equipment/EquipmentSet';
|
|
7
|
+
export * from './components/Input';
|
|
8
|
+
export * from './components/Item/Inventory/ItemContainer';
|
|
9
|
+
export * from './components/Item/Inventory/ItemSlot';
|
|
10
|
+
export * from './components/ListMenu';
|
|
11
|
+
export * from './components/NPCDialog/NPCDialog';
|
|
12
|
+
export * from './components/NPCDialog/QuestionDialog/QuestionDialog';
|
|
13
|
+
export * from './components/ProgressBar';
|
|
14
|
+
export * from './components/PropertySelect/PropertySelect';
|
|
15
|
+
export * from './components/RadioButton';
|
|
16
|
+
export * from './components/RangeSlider';
|
|
17
|
+
export * from './components/RPGUIContainer';
|
|
18
|
+
export * from './components/RPGUIRoot';
|
|
19
|
+
export * from './components/shared/SpriteFromAtlas';
|
|
20
|
+
export * from './components/SkillProgressBar';
|
|
21
|
+
export * from './components/SkillsContainer';
|
|
22
|
+
export * from './components/TextArea';
|
|
23
|
+
export * from './components/Truncate';
|
|
24
|
+
export * from './components/typography/DynamicText';
|
|
25
|
+
export { useEventListener } from './hooks/useEventListener';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const chunkString = (str: string, length: number) => {
|
|
2
|
-
return str.match(new RegExp('.{1,' + length + '}', 'g'));
|
|
3
|
-
};
|
|
1
|
+
export const chunkString = (str: string, length: number) => {
|
|
2
|
+
return str.match(new RegExp('.{1,' + length + '}', 'g'));
|
|
3
|
+
};
|