Skip to content

Commit

Permalink
fix: checkbox group item docs & types
Browse files Browse the repository at this point in the history
  • Loading branch information
renrizzolo committed Oct 18, 2022
1 parent 4119854 commit 10585c0
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 27 deletions.
12 changes: 6 additions & 6 deletions src/components/Checkbox/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import * as React from 'react';

export type CheckboxValue = string | number;

export type CheckboxVariant = 'default' | 'box';

export type CheckboxChecked = boolean | 'partial';

export type CheckboxValue = string | number;

export interface CheckboxProps {
/**
* name for the checkbox input
*/
name?: string;
/**
* checkBox input value
*/
value?: CheckboxValue;
variant?: CheckboxVariant;
/**
* @function onChange called when checkBox onChange event is fired
Expand All @@ -36,6 +32,10 @@ export interface CheckboxProps {
* @deprecated
*/
inline?: boolean;
/**
* checkBox input value
*/
value?: CheckboxValue;
/**
* id for the checkbox input
*/
Expand Down
8 changes: 4 additions & 4 deletions src/components/Checkbox/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ const Checkbox = ({
};

export const shareCheckboxPropTypes = {
/**
* checkBox input value
*/
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
/**
* id for the checkbox input
*/
Expand Down Expand Up @@ -136,10 +140,6 @@ Checkbox.propTypes = {
* name for the checkbox input
*/
name: PropTypes.string,
/**
* checkBox input value
*/
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
variant: PropTypes.oneOf(['default', 'box']),
/**
* @function onChange called when checkBox onChange event is fired
Expand Down
6 changes: 6 additions & 0 deletions src/components/CheckboxGroup/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import * as React from 'react';

export type CheckboxGroupItemValue = string | number;

export interface CheckboxGroupItemProps {
/**
* checkBox input value
*/
value?: CheckboxGroupItemValue;
/**
* id for the checkbox input
*/
Expand Down
30 changes: 15 additions & 15 deletions www/containers/props.json
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,21 @@
"displayName": "Checkbox",
"methods": [],
"props": {
"value": {
"type": {
"name": "union",
"value": [
{
"name": "string"
},
{
"name": "number"
}
]
},
"required": false,
"description": "checkBox input value"
},
"id": {
"type": {
"name": "string"
Expand Down Expand Up @@ -1212,21 +1227,6 @@
"required": false,
"description": "name for the checkbox input"
},
"value": {
"type": {
"name": "union",
"value": [
{
"name": "string"
},
{
"name": "number"
}
]
},
"required": false,
"description": "checkBox input value"
},
"variant": {
"type": {
"name": "enum",
Expand Down
14 changes: 12 additions & 2 deletions www/examples/CheckboxGroup.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Props from '../containers/Props.jsx';
import DesignNotes from '../containers/DesignNotes.jsx';
import { shareCheckboxPropTypes } from '../../src/components/Checkbox/index.jsx';

## CheckboxGroup

Expand Down Expand Up @@ -158,9 +159,18 @@ render(Example);

### CheckboxGroup.Item

<Props customMapper={(props) => [props[`src/components/Card/index.jsx`][0]]} />
<Props
customMapper={(props) => [
{
...props[`src/components/Checkbox/index.jsx`][0],
props: _.pickBy(props[`src/components/Checkbox/index.jsx`][0].props, (v, k) =>
_.keys(shareCheckboxPropTypes).includes(k)
),
},
]}
/>
<br />

### CheckboxGroup.All

<Props customMapper={(props) => [props[`src/components/Card/index.jsx`][1]]} />
<Props customMapper={(props) => [props[`src/components/CheckboxGroup/index.jsx`][1]]} />

0 comments on commit 10585c0

Please sign in to comment.