@rpg-engine/long-bow 0.1.794 → 0.2.2
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/Button.d.ts +1 -0
- package/dist/components/Equipment/EquipmentSet.d.ts +5 -3
- package/dist/components/Item/Cards/ItemTooltip.d.ts +6 -0
- package/dist/components/Item/Inventory/ItemContainer.d.ts +4 -6
- package/dist/components/Item/Inventory/ItemContainerTypes.d.ts +6 -0
- package/dist/components/Item/Inventory/ItemSlot.d.ts +5 -9
- package/dist/components/Item/Inventory/itemContainerHelper.d.ts +2 -7
- package/dist/components/PropertySelect/PropertySelect.d.ts +12 -0
- package/dist/components/QuestInfo/QuestInfo.d.ts +14 -0
- package/dist/components/RelativeListMenu.d.ts +13 -0
- package/dist/index.d.ts +1 -1
- package/dist/long-bow.cjs.development.js +748 -1194
- 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 +748 -1196
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/mocks/equipmentSet.mocks.d.ts +2 -2
- package/dist/stories/Button.stories.d.ts +5 -0
- package/dist/stories/Chat.stories.d.ts +5 -0
- package/dist/stories/CheckButton.stories.d.ts +5 -0
- package/dist/stories/DraggableContainer.stories.d.ts +5 -0
- package/dist/stories/Dropdown.stories.d.ts +5 -0
- package/dist/stories/EquipmentSet.stories.d.ts +5 -0
- package/dist/stories/ItemContainer.stories.d.ts +5 -0
- package/dist/stories/ListMenu.stories.d.ts +5 -0
- package/dist/stories/Multitab.stories.d.ts +6 -0
- package/dist/stories/NPCDialog.stories.d.ts +7 -0
- package/dist/stories/ProgressBar.stories.d.ts +8 -0
- package/dist/stories/PropertySelect.stories.d.ts +5 -0
- package/dist/stories/QuestInfo.stories.d.ts +5 -0
- package/dist/stories/RPGUIContainers.stories.d.ts +5 -0
- package/dist/stories/RadioButton.stories.d.ts +5 -0
- package/dist/stories/RangeSlider.stories.d.ts +5 -0
- package/dist/stories/ScrollList.stories.d.ts +5 -0
- package/dist/stories/SimpleProgressBar.stories.d.ts +5 -0
- package/dist/stories/SkillProgressBar.stories.d.ts +5 -0
- package/dist/stories/SkillsContainer.stories.d.ts +5 -0
- package/dist/stories/Text.stories.d.ts +7 -0
- package/package.json +98 -96
- package/src/components/Abstractions/SlotsContainer.tsx +42 -42
- package/src/components/Button.tsx +30 -29
- 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 +138 -180
- package/src/components/Input.tsx +11 -11
- package/src/components/Item/Cards/ItemTooltip.tsx +32 -0
- package/src/components/Item/Inventory/ItemContainer.tsx +68 -113
- package/src/components/Item/Inventory/ItemContainerTypes.ts +6 -0
- package/src/components/Item/Inventory/ItemSlot.tsx +212 -158
- package/src/components/Item/Inventory/itemContainerHelper.ts +146 -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 +237 -242
- package/src/components/ProgressBar.tsx +91 -91
- package/src/components/PropertySelect/PropertySelect.tsx +101 -0
- 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 -0
- package/src/components/QuestInfo/img/default.png +0 -0
- 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 -0
- package/src/components/ScrollList.tsx +77 -77
- package/src/components/SimpleProgressBar.tsx +62 -62
- package/src/components/SkillProgressBar.tsx +123 -124
- package/src/components/SkillsContainer.tsx +196 -235
- 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 -303
- package/src/mocks/atlas/icons/icons.png +0 -0
- package/src/mocks/atlas/items/items.json +5215 -5195
- package/src/mocks/atlas/items/items.png +0 -0
- package/src/mocks/equipmentSet.mocks.ts +347 -347
- package/src/mocks/itemContainer.mocks.ts +281 -249
- package/src/mocks/skills.mocks.ts +122 -122
- package/src/stories/Button.stories.tsx +36 -0
- package/src/stories/Chat.stories.tsx +170 -0
- package/src/stories/CheckButton.stories.tsx +48 -0
- package/src/stories/DraggableContainer.stories.tsx +28 -0
- package/src/stories/Dropdown.stories.tsx +46 -0
- package/src/stories/EquipmentSet.stories.tsx +51 -0
- package/src/stories/ItemContainer.stories.tsx +51 -0
- package/src/stories/ListMenu.stories.tsx +56 -0
- package/src/stories/Multitab.stories.tsx +51 -0
- package/src/stories/NPCDialog.stories.tsx +130 -0
- package/src/stories/ProgressBar.stories.tsx +23 -0
- package/src/stories/PropertySelect.stories.tsx +41 -0
- package/src/stories/QuestInfo.stories.tsx +76 -0
- package/src/stories/RPGUIContainers.stories.tsx +42 -0
- package/src/stories/RadioButton.stories.tsx +49 -0
- package/src/stories/RangeSlider.stories.tsx +60 -0
- package/src/stories/ScrollList.stories.tsx +85 -0
- package/src/stories/SimpleProgressBar.stories.tsx +22 -0
- package/src/stories/SkillProgressBar.stories.tsx +30 -0
- package/src/stories/SkillsContainer.stories.tsx +31 -0
- package/src/stories/Text.stories.tsx +42 -0
- package/src/types/eventTypes.ts +4 -4
- package/src/types/index.d.ts +2 -2
- package/dist/components/Item/Cards/ItemCard.d.ts +0 -9
- package/dist/components/shared/SpriteIcon.d.ts +0 -9
- package/dist/components/store/UI.store.d.ts +0 -38
- package/src/components/Item/Cards/ItemCard.tsx +0 -36
- package/src/components/shared/SpriteIcon.tsx +0 -67
- package/src/components/store/UI.store.ts +0 -232
|
@@ -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/
|
|
15
|
-
export * from './components/
|
|
16
|
-
export * from './components/
|
|
17
|
-
export * from './components/
|
|
18
|
-
export * from './components/
|
|
19
|
-
export * from './components/shared/
|
|
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
|
+
};
|