@rpg-engine/long-bow 0.5.85 → 0.5.87
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 +3 -3
- package/dist/long-bow.cjs.development.js +11 -12
- 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 +11 -12
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/stories/CheckButton.stories.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/CheckItem.tsx +11 -15
- package/src/stories/CheckButton.stories.tsx +20 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Meta } from '@storybook/react';
|
|
2
2
|
import { ICheckProps } from '../../src/components/CheckButton';
|
|
3
|
+
import { ICheckItemProps } from '../components/CheckItem';
|
|
3
4
|
declare const meta: Meta;
|
|
4
5
|
export default meta;
|
|
5
6
|
export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, ICheckProps>;
|
|
7
|
+
export declare const DefaultCheckItems: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, ICheckItemProps>;
|
package/package.json
CHANGED
|
@@ -1,32 +1,28 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
|
|
3
3
|
export interface ICheckItemProps {
|
|
4
|
-
label
|
|
5
|
-
|
|
6
|
-
onChange: (label: string, selected: boolean) => void;
|
|
4
|
+
label?: string;
|
|
5
|
+
defaultValue?: boolean;
|
|
6
|
+
onChange: (label: string | undefined, selected: boolean) => void;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export const CheckItem: React.FC<ICheckItemProps> = ({
|
|
10
10
|
label,
|
|
11
|
-
|
|
11
|
+
defaultValue = false,
|
|
12
12
|
onChange,
|
|
13
13
|
}) => {
|
|
14
|
-
const [
|
|
14
|
+
const [checked, setChecked] = useState(defaultValue);
|
|
15
15
|
|
|
16
16
|
const handleClick = () => {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const newCheckedState = !checked;
|
|
18
|
+
setChecked(newCheckedState);
|
|
19
|
+
onChange(label, newCheckedState);
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
return (
|
|
22
|
-
<div
|
|
23
|
-
<input
|
|
24
|
-
|
|
25
|
-
type="checkbox"
|
|
26
|
-
checked={selected}
|
|
27
|
-
onChange={() => {}}
|
|
28
|
-
/>
|
|
29
|
-
<label onPointerDown={handleClick}>{label}</label>
|
|
23
|
+
<div onPointerDown={handleClick}>
|
|
24
|
+
<input className="rpgui-checkbox" type="checkbox" checked={checked} />
|
|
25
|
+
<label>{label}</label>
|
|
30
26
|
<br />
|
|
31
27
|
</div>
|
|
32
28
|
);
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
ICheckItems,
|
|
6
6
|
ICheckProps,
|
|
7
7
|
} from '../../src/components/CheckButton';
|
|
8
|
+
import { CheckItem, ICheckItemProps } from '../components/CheckItem';
|
|
8
9
|
import {
|
|
9
10
|
RPGUIContainer,
|
|
10
11
|
RPGUIContainerTypes,
|
|
@@ -26,8 +27,20 @@ const Template: Story<ICheckProps> = args => (
|
|
|
26
27
|
</RPGUIRoot>
|
|
27
28
|
);
|
|
28
29
|
|
|
30
|
+
const TemplateCheckItems: Story<ICheckItemProps> = args => {
|
|
31
|
+
return (
|
|
32
|
+
<RPGUIRoot>
|
|
33
|
+
<RPGUIContainer type={RPGUIContainerTypes.Framed}>
|
|
34
|
+
<CheckItem {...args} />
|
|
35
|
+
</RPGUIContainer>
|
|
36
|
+
</RPGUIRoot>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
29
40
|
export const Default = Template.bind({});
|
|
30
41
|
|
|
42
|
+
export const DefaultCheckItems = TemplateCheckItems.bind({});
|
|
43
|
+
|
|
31
44
|
const items: ICheckItems[] = [
|
|
32
45
|
{
|
|
33
46
|
label: 'label1',
|
|
@@ -46,3 +59,10 @@ const items: ICheckItems[] = [
|
|
|
46
59
|
Default.args = {
|
|
47
60
|
items,
|
|
48
61
|
};
|
|
62
|
+
|
|
63
|
+
DefaultCheckItems.args = {
|
|
64
|
+
label: 'label',
|
|
65
|
+
onChange: (label, value) => {
|
|
66
|
+
console.log(label, value);
|
|
67
|
+
},
|
|
68
|
+
};
|