Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): ⬆️ update dev dependencies (minor) #208

Merged
merged 2 commits into from
Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@
"@commitlint/config-conventional": "15.0.0",
"@release-it/conventional-changelog": "3.3.0",
"@size-limit/preset-big-lib": "5.0.5",
"@storybook/addon-a11y": "6.4.0-rc.7",
"@storybook/addon-actions": "6.4.0-rc.7",
"@storybook/addon-essentials": "6.4.0-rc.7",
"@storybook/addon-a11y": "6.4.0-rc.9",
"@storybook/addon-actions": "6.4.0-rc.9",
"@storybook/addon-essentials": "6.4.0-rc.9",
"@storybook/addon-postcss": "2.0.0",
"@storybook/builder-webpack5": "6.4.0-rc.7",
"@storybook/manager-webpack5": "6.4.0-rc.7",
"@storybook/react": "6.4.0-rc.7",
"@storybook/builder-webpack5": "6.4.0-rc.9",
"@storybook/manager-webpack5": "6.4.0-rc.9",
"@storybook/react": "6.4.0-rc.9",
"@swc/cli": "0.1.52",
"@swc/core": "1.2.112",
"@tailwindcss/forms": "0.3.4",
Expand Down Expand Up @@ -185,7 +185,7 @@
"postcss-cli": "9.0.2",
"postcss-focus-visible": "6.0.1",
"postcss-selector-parser": "6.0.6",
"prettier": "2.4.1",
"prettier": "2.5.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-hook-form": "7.20.2",
Expand All @@ -202,7 +202,7 @@
"tsd": "0.19.0",
"tslib": "2.3.1",
"typescript": "4.5.2",
"webpack": "5.64.3"
"webpack": "5.64.4"
},
"peerDependencies": {
"deepmerge": "4.x",
Expand Down
27 changes: 14 additions & 13 deletions src/button-group/stories/ButtonGroupCollapsed.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ import { Button, ButtonGroup, ButtonGroupProps } from "../../index";

export type ButtonGroupCollapsedProps = ButtonGroupProps & {};

export const ButtonGroupCollapsed: React.FC<ButtonGroupCollapsedProps> =
props => {
return (
<ButtonGroup collapsed {...props}>
<Button>Undo</Button>
<Button>Redo</Button>
<Button>Copy</Button>
<Button>Paste</Button>
<Button>Delete</Button>
<Button>Close</Button>
</ButtonGroup>
);
};
export const ButtonGroupCollapsed: React.FC<
ButtonGroupCollapsedProps
> = props => {
return (
<ButtonGroup collapsed {...props}>
<Button>Undo</Button>
<Button>Redo</Button>
<Button>Copy</Button>
<Button>Paste</Button>
<Button>Delete</Button>
<Button>Close</Button>
</ButtonGroup>
);
};

export default ButtonGroupCollapsed;
117 changes: 59 additions & 58 deletions src/checkbox-group/stories/CheckboxGroupTriBoolState.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,75 +4,76 @@ import { Checkbox, CheckboxGroup } from "../../index";

export type CheckboxGroupTriBoolStateProps = {};

export const CheckboxGroupTriBoolState: React.FC<CheckboxGroupTriBoolStateProps> =
() => {
const [checkedItems, setCheckedItems] = React.useState<boolean[]>([
false,
false,
false,
]);
export const CheckboxGroupTriBoolState: React.FC<
CheckboxGroupTriBoolStateProps
> = () => {
const [checkedItems, setCheckedItems] = React.useState<boolean[]>([
false,
false,
false,
]);

const allChecked = checkedItems.every(Boolean);
const isIndeterminate = checkedItems.some(Boolean) && !allChecked;
const allChecked = checkedItems.every(Boolean);
const isIndeterminate = checkedItems.some(Boolean) && !allChecked;

return (
<CheckboxGroup aria-label="Tristate checkbox using boolean values">
return (
<CheckboxGroup aria-label="Tristate checkbox using boolean values">
<Checkbox
state={isIndeterminate ? "indeterminate" : allChecked}
onStateChange={value =>
setCheckedItems([
value as boolean,
value as boolean,
value as boolean,
])
}
label="Check all items"
aria-controls="check1 check2 check3"
/>
<CheckboxGroup
role="presentation"
aria-label="For presentation"
stack="horizontal"
>
<Checkbox
state={isIndeterminate ? "indeterminate" : allChecked}
state={checkedItems[0]}
onStateChange={value =>
setCheckedItems([
value as boolean,
checkedItems[1],
checkedItems[2],
])
}
label="Item 1"
id="check1"
/>
<Checkbox
state={checkedItems[1]}
onStateChange={value =>
setCheckedItems([
checkedItems[0],
value as boolean,
checkedItems[2],
])
}
label="Item 2"
id="check2"
/>
<Checkbox
state={checkedItems[2]}
onStateChange={value =>
setCheckedItems([
checkedItems[0],
checkedItems[1],
value as boolean,
])
}
label="Check all items"
aria-controls="check1 check2 check3"
label="Item 3"
id="check3"
/>
<CheckboxGroup
role="presentation"
aria-label="For presentation"
stack="horizontal"
>
<Checkbox
state={checkedItems[0]}
onStateChange={value =>
setCheckedItems([
value as boolean,
checkedItems[1],
checkedItems[2],
])
}
label="Item 1"
id="check1"
/>
<Checkbox
state={checkedItems[1]}
onStateChange={value =>
setCheckedItems([
checkedItems[0],
value as boolean,
checkedItems[2],
])
}
label="Item 2"
id="check2"
/>
<Checkbox
state={checkedItems[2]}
onStateChange={value =>
setCheckedItems([
checkedItems[0],
checkedItems[1],
value as boolean,
])
}
label="Item 3"
id="check3"
/>
</CheckboxGroup>
</CheckboxGroup>
);
};
</CheckboxGroup>
);
};

export default CheckboxGroupTriBoolState;
127 changes: 64 additions & 63 deletions src/checkbox-group/stories/CheckboxGroupTriStringState.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,75 +4,76 @@ import { Checkbox, CheckboxGroup, CheckboxProps } from "../../index";

export type CheckboxGroupTriStringStateProps = {};

export const CheckboxGroupTriStringState: React.FC<CheckboxGroupTriStringStateProps> =
() => {
const values = React.useMemo(() => ["Apple", "Orange", "Watermelon"], []);
const [itemState, setItemState] = React.useState<
NonNullable<CheckboxProps["state"]>
>([]);
const [groupState, setGroupState] =
React.useState<NonNullable<CheckboxProps["state"]>>(false);
export const CheckboxGroupTriStringState: React.FC<
CheckboxGroupTriStringStateProps
> = () => {
const values = React.useMemo(() => ["Apple", "Orange", "Watermelon"], []);
const [itemState, setItemState] = React.useState<
NonNullable<CheckboxProps["state"]>
>([]);
const [groupState, setGroupState] =
React.useState<NonNullable<CheckboxProps["state"]>>(false);

const isAllChecked = groupState === true;
const isIndeterminate = groupState === "indeterminate";
const isAllChecked = groupState === true;
const isIndeterminate = groupState === "indeterminate";

// updates items when group is toggled
React.useEffect(() => {
if (groupState === true) {
setItemState(values);
} else if (groupState === false) {
setItemState([]);
}
}, [groupState, values]);
// updates items when group is toggled
React.useEffect(() => {
if (groupState === true) {
setItemState(values);
} else if (groupState === false) {
setItemState([]);
}
}, [groupState, values]);

// updates group when items is toggled
React.useEffect(() => {
if (!Array.isArray(itemState)) return;
// updates group when items is toggled
React.useEffect(() => {
if (!Array.isArray(itemState)) return;

if (itemState.length === values.length) {
setGroupState(true);
} else if (itemState.length) {
setGroupState("indeterminate");
} else {
setGroupState(false);
}
}, [itemState, values]);
if (itemState.length === values.length) {
setGroupState(true);
} else if (itemState.length) {
setGroupState("indeterminate");
} else {
setGroupState(false);
}
}, [itemState, values]);

return (
<CheckboxGroup aria-label="Tristate Checkbox using string values">
<Checkbox
state={groupState}
onStateChange={setGroupState}
label={
isIndeterminate
? "Fruits in the basket"
: isAllChecked
? "Basket full"
: "Basket empty"
}
aria-controls="check1 check2 check3"
/>
<CheckboxGroup
role="presentation"
aria-label="For presentation"
stack="horizontal"
>
{values.map((value, i) => {
return (
<Checkbox
key={i}
id={`check${i + 1}`}
state={itemState}
onStateChange={setItemState}
value={value}
label={capitalizeFirstLetter(value)}
/>
);
})}
</CheckboxGroup>
return (
<CheckboxGroup aria-label="Tristate Checkbox using string values">
<Checkbox
state={groupState}
onStateChange={setGroupState}
label={
isIndeterminate
? "Fruits in the basket"
: isAllChecked
? "Basket full"
: "Basket empty"
}
aria-controls="check1 check2 check3"
/>
<CheckboxGroup
role="presentation"
aria-label="For presentation"
stack="horizontal"
>
{values.map((value, i) => {
return (
<Checkbox
key={i}
id={`check${i + 1}`}
state={itemState}
onStateChange={setItemState}
value={value}
label={capitalizeFirstLetter(value)}
/>
);
})}
</CheckboxGroup>
);
};
</CheckboxGroup>
);
};

export default CheckboxGroupTriStringState;

Expand Down
Loading