@rpg-engine/long-bow 0.1.29 → 0.1.35

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.
@@ -0,0 +1,53 @@
1
+ import React, { useEffect, useState } from 'react';
2
+
3
+ export interface IRadioItems {
4
+ label: string;
5
+ value: string;
6
+ }
7
+
8
+ export interface IRadioProps {
9
+ name: string;
10
+ items: IRadioItems[];
11
+ onChange: (value: string) => void;
12
+ }
13
+
14
+ export const InputRadio: React.FC<IRadioProps> = ({
15
+ name,
16
+ items,
17
+ onChange,
18
+ }) => {
19
+ const [selectedValue, setSelectedValue] = useState<string>();
20
+ const handleClick = () => {
21
+ let element = document.querySelector(
22
+ `input[name=${name}]:checked`
23
+ ) as HTMLInputElement;
24
+ const elementValue = element.value;
25
+ setSelectedValue(elementValue);
26
+ };
27
+
28
+ useEffect(() => {
29
+ if (selectedValue) {
30
+ onChange(selectedValue);
31
+ }
32
+ }, [selectedValue]);
33
+
34
+ return (
35
+ <div id="elemento-radio">
36
+ {items.map((element) => {
37
+ return (
38
+ <>
39
+ <input
40
+ key={element.value}
41
+ className="rpgui-radio"
42
+ value={element.value}
43
+ name={name}
44
+ type="radio"
45
+ />
46
+ <label onClick={handleClick}>{element.label}</label>
47
+ <br />
48
+ </>
49
+ );
50
+ })}
51
+ </div>
52
+ );
53
+ };
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { v4 as uuidv4 } from 'uuid';
4
4
  import { useEventListener } from '../hooks/useEventListener';
5
- import { RPGUIRoot, _RPGUI } from './RPGUIRoot';
5
+ import { _RPGUI } from './RPGUIRoot';
6
6
 
7
7
  export enum RangeSliderType {
8
8
  Slider = 'rpgui-slider',
@@ -43,25 +43,23 @@ export const RangeSlider: React.FC<IRangeSliderProps> = ({
43
43
  };
44
44
 
45
45
  return (
46
- <RPGUIRoot>
47
- <div
48
- onMouseUp={onHandleMouseUp}
49
- onMouseDown={() => setWasMouseDownFirst(true)}
50
- >
51
- <Input
52
- className={
53
- type === RangeSliderType.Slider
54
- ? RangeSliderType.Slider
55
- : RangeSliderType.GoldSlider
56
- }
57
- type="range"
58
- style={{ width: width }}
59
- min={valueMin}
60
- max={valueMax}
61
- id={`rpgui-slider-${sliderId}`}
62
- />
63
- </div>
64
- </RPGUIRoot>
46
+ <div
47
+ onMouseUp={onHandleMouseUp}
48
+ onMouseDown={() => setWasMouseDownFirst(true)}
49
+ >
50
+ <Input
51
+ className={
52
+ type === RangeSliderType.Slider
53
+ ? RangeSliderType.Slider
54
+ : RangeSliderType.GoldSlider
55
+ }
56
+ type="range"
57
+ style={{ width: width }}
58
+ min={valueMin}
59
+ max={valueMax}
60
+ id={`rpgui-slider-${sliderId}`}
61
+ />
62
+ </div>
65
63
  );
66
64
  };
67
65
 
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+
3
+ export interface ITextArea
4
+ extends React.DetailedHTMLProps<
5
+ React.TextareaHTMLAttributes<HTMLTextAreaElement>,
6
+ HTMLTextAreaElement
7
+ > {}
8
+
9
+ export const TextArea: React.FC<ITextArea> = ({ ...props }) => {
10
+ return <textarea {...props} />;
11
+ };
@@ -0,0 +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
+ `;
package/src/index.tsx CHANGED
@@ -1,9 +1,15 @@
1
1
  export * from './components/Button';
2
+ export * from './components/CheckButton';
3
+ export * from './components/Dropdown';
4
+ export * from './components/Input';
2
5
  export * from './components/ListMenu';
3
6
  export * from './components/NPCDialog/NPCDialog';
4
7
  export * from './components/NPCDialog/QuestionDialog/QuestionDialog';
8
+ export * from './components/RadioButton';
5
9
  export * from './components/RangeSlider';
6
10
  export * from './components/RPGUIContainer';
7
11
  export * from './components/RPGUIRoot';
12
+ export * from './components/TextArea';
13
+ export * from './components/Truncate';
8
14
  export * from './components/typography/DynamicText';
9
15
  export { useEventListener } from './hooks/useEventListener';