Skip to content

Commit

Permalink
add functions to utils and link in components, bump versions
Browse files Browse the repository at this point in the history
  • Loading branch information
receter committed Jul 16, 2024
1 parent e4ee7b2 commit 7c9263e
Show file tree
Hide file tree
Showing 5 changed files with 335 additions and 14 deletions.
4 changes: 2 additions & 2 deletions packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sys42/components",
"private": false,
"version": "0.0.5",
"version": "0.0.6",
"type": "module",
"exports": {
".": {
Expand Down Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"@react-aria/button": "^3.9.3",
"@react-types/shared": "^3.23.1",
"@sys42/utils": "^0.0.1",
"@sys42/utils": "workspace:^",
"modern-normalize": "^2.0.0",
"react-merge-refs": "^2.1.1"
},
Expand Down
37 changes: 33 additions & 4 deletions packages/utils/lib/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
export function concatClassNames(...args: Array<string | boolean | null | undefined>)
: string {
return args.filter(item => !!item).join(' ');
}
export function concatClassNames(
...args: Array<string | boolean | null | undefined>
): string {
return args.filter((item) => !!item).join(" ");
}

export function filterKeyEnter(handler: (e: React.KeyboardEvent) => void) {
return (e: React.KeyboardEvent) => {
if (e.key === "Enter") {
handler(e);
}
};
}

export function filterKeyEsc(handler: (e: React.KeyboardEvent) => void) {
return (e: React.KeyboardEvent) => {
if (e.key === "Escape") {
handler(e);
}
};
}

export function accessibleOnClick(
handler: (e: React.KeyboardEvent) => void,
tabIndex: number
) {
return {
role: "button",
tabIndex: tabIndex || 0,
onKeyDown: filterKeyEnter(handler),
onClick: handler,
};
}
290 changes: 290 additions & 0 deletions packages/utils/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@sys42/utils",
"author": "Andreas Riedmüller",
"license": "MIT",
"version": "0.0.1",
"version": "0.1.0",
"type": "module",
"main": "dist/utils.js",
"types": "dist/main.d.ts",
Expand All @@ -26,5 +26,8 @@
"typescript": "^5.0.2",
"vite": "^4.3.2",
"vite-plugin-dts": "^2.3.0"
},
"dependencies": {
"@types/react": "^18.3.3"
}
}
Loading

0 comments on commit 7c9263e

Please sign in to comment.