@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.
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.5.85",
3
+ "version": "0.5.87",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -1,32 +1,28 @@
1
1
  import React, { useState } from 'react';
2
2
 
3
3
  export interface ICheckItemProps {
4
- label: string;
5
- value: string;
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
- value,
11
+ defaultValue = false,
12
12
  onChange,
13
13
  }) => {
14
- const [selected, setSelected] = useState(false);
14
+ const [checked, setChecked] = useState(defaultValue);
15
15
 
16
16
  const handleClick = () => {
17
- setSelected(!selected);
18
- onChange(label, !selected);
17
+ const newCheckedState = !checked;
18
+ setChecked(newCheckedState);
19
+ onChange(label, newCheckedState);
19
20
  };
20
21
 
21
22
  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>
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
+ };