@rpg-engine/long-bow 0.5.83 → 0.5.85
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/dist/components/CheckItem.d.ts +7 -0
- package/dist/components/RangeSlider.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/long-bow.cjs.development.js +35 -7
- 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 +35 -8
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/CheckItem.tsx +33 -0
- package/src/components/RangeSlider.tsx +51 -46
- package/src/index.tsx +1 -0
- package/src/stories/RangeSlider.stories.tsx +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface ICheckItemProps {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
onChange: (label: string, selected: boolean) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const CheckItem: React.FC<ICheckItemProps> = ({
|
|
10
|
+
label,
|
|
11
|
+
value,
|
|
12
|
+
onChange,
|
|
13
|
+
}) => {
|
|
14
|
+
const [selected, setSelected] = useState(false);
|
|
15
|
+
|
|
16
|
+
const handleClick = () => {
|
|
17
|
+
setSelected(!selected);
|
|
18
|
+
onChange(label, !selected);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div key={value}>
|
|
23
|
+
<input
|
|
24
|
+
className="rpgui-checkbox"
|
|
25
|
+
type="checkbox"
|
|
26
|
+
checked={selected}
|
|
27
|
+
onChange={() => {}}
|
|
28
|
+
/>
|
|
29
|
+
<label onPointerDown={handleClick}>{label}</label>
|
|
30
|
+
<br />
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
4
|
|
|
@@ -14,58 +14,63 @@ export interface IRangeSliderProps {
|
|
|
14
14
|
width: string;
|
|
15
15
|
onChange: (value: number) => void;
|
|
16
16
|
value: number;
|
|
17
|
+
step?: number;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
export const RangeSlider: React.FC<IRangeSliderProps> = (
|
|
20
|
-
type,
|
|
21
|
-
|
|
22
|
-
valueMax,
|
|
23
|
-
width,
|
|
24
|
-
onChange,
|
|
25
|
-
value,
|
|
26
|
-
}) => {
|
|
27
|
-
const sliderId = uuidv4();
|
|
20
|
+
export const RangeSlider: React.FC<IRangeSliderProps> = React.memo(
|
|
21
|
+
({ type, valueMin, valueMax, width, onChange, value, step = 1 }) => {
|
|
22
|
+
const sliderId = uuidv4();
|
|
28
23
|
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
25
|
+
const [left, setLeft] = useState(0);
|
|
31
26
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const calculatedWidth = containerRef.current?.clientWidth || 0;
|
|
29
|
+
setLeft(
|
|
30
|
+
Math.max(
|
|
31
|
+
((value - valueMin) / (valueMax - valueMin)) *
|
|
32
|
+
(calculatedWidth - 35) +
|
|
33
|
+
10
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
}, [value, valueMin, valueMax]);
|
|
37
|
+
|
|
38
|
+
const typeClass = type === RangeSliderType.GoldSlider ? 'golden' : '';
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
const handleChange = useCallback(
|
|
41
|
+
(e: { target: { value: any } }) => {
|
|
42
|
+
onChange(Number(e.target.value));
|
|
43
|
+
},
|
|
44
|
+
[onChange]
|
|
45
|
+
);
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
return (
|
|
48
|
+
<div
|
|
49
|
+
style={{ width: width, position: 'relative' }}
|
|
50
|
+
className={`rpgui-slider-container ${typeClass}`}
|
|
51
|
+
id={`rpgui-slider-${sliderId}`}
|
|
52
|
+
ref={containerRef}
|
|
53
|
+
>
|
|
54
|
+
<div style={{ pointerEvents: 'none' }}>
|
|
55
|
+
<div className={`rpgui-slider-track ${typeClass}`} />
|
|
56
|
+
<div className={`rpgui-slider-left-edge ${typeClass}`} />
|
|
57
|
+
<div className={`rpgui-slider-right-edge ${typeClass}`} />
|
|
58
|
+
<div className={`rpgui-slider-thumb ${typeClass}`} style={{ left }} />
|
|
59
|
+
</div>
|
|
60
|
+
<Input
|
|
61
|
+
type="range"
|
|
62
|
+
style={{ width: width }}
|
|
63
|
+
min={valueMin}
|
|
64
|
+
max={valueMax}
|
|
65
|
+
step={step}
|
|
66
|
+
onChange={handleChange}
|
|
67
|
+
value={value}
|
|
68
|
+
className="rpgui-cursor-point"
|
|
69
|
+
/>
|
|
56
70
|
</div>
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
min={valueMin}
|
|
61
|
-
max={valueMax}
|
|
62
|
-
onChange={e => onChange(Number(e.target.value))}
|
|
63
|
-
value={value}
|
|
64
|
-
className="rpgui-cursor-point"
|
|
65
|
-
/>
|
|
66
|
-
</div>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
);
|
|
69
74
|
|
|
70
75
|
const Input = styled.input`
|
|
71
76
|
opacity: 0;
|
package/src/index.tsx
CHANGED
|
@@ -5,6 +5,7 @@ export * from './components/Chat/Chat';
|
|
|
5
5
|
export * from './components/ChatRevamp/ChatRevamp';
|
|
6
6
|
export * from './components/Chatdeprecated/ChatDeprecated';
|
|
7
7
|
export * from './components/CheckButton';
|
|
8
|
+
export * from './components/CheckItem';
|
|
8
9
|
export * from './components/CircularController/CircularController';
|
|
9
10
|
export * from './components/CraftBook/CraftBook';
|
|
10
11
|
export * from './components/DraggableContainer';
|