diff --git a/packages/components/package.json b/packages/components/package.json index df99d1c..21c95d0 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,7 +1,7 @@ { "name": "@sys42/components", "private": false, - "version": "0.0.5", + "version": "0.0.6", "type": "module", "exports": { ".": { @@ -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" }, diff --git a/packages/utils/lib/main.ts b/packages/utils/lib/main.ts index 2adff6d..76ed46d 100644 --- a/packages/utils/lib/main.ts +++ b/packages/utils/lib/main.ts @@ -1,4 +1,33 @@ -export function concatClassNames(...args: Array) - : string { - return args.filter(item => !!item).join(' '); -} \ No newline at end of file +export function concatClassNames( + ...args: Array +): 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, + }; +} diff --git a/packages/utils/package-lock.json b/packages/utils/package-lock.json new file mode 100644 index 0000000..6577a68 --- /dev/null +++ b/packages/utils/package-lock.json @@ -0,0 +1,290 @@ +{ + "name": "@sys42/utils", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@sys42/utils", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@types/react": "^18.3.3" + }, + "devDependencies": { + "@types/node": "^18.16.1", + "typescript": "^5.0.2", + "vite": "^4.3.2", + "vite-plugin-dts": "^2.3.0" + } + }, + "../../node_modules/.pnpm/@types+node@18.16.1/node_modules/@types/node": { + "version": "18.16.1", + "dev": true, + "license": "MIT" + }, + "../../node_modules/.pnpm/typescript@5.0.2/node_modules/typescript": { + "version": "5.0.2", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "devDependencies": { + "@esfx/canceltoken": "^1.0.0", + "@octokit/rest": "latest", + "@types/chai": "^4.3.4", + "@types/fs-extra": "^9.0.13", + "@types/glob": "^8.1.0", + "@types/microsoft__typescript-etw": "^0.1.1", + "@types/minimist": "^1.2.2", + "@types/mocha": "^10.0.1", + "@types/ms": "^0.7.31", + "@types/node": "latest", + "@types/source-map-support": "^0.5.6", + "@types/which": "^2.0.1", + "@typescript-eslint/eslint-plugin": "^5.33.1", + "@typescript-eslint/parser": "^5.33.1", + "@typescript-eslint/utils": "^5.33.1", + "azure-devops-node-api": "^11.2.0", + "chai": "^4.3.7", + "chalk": "^4.1.2", + "chokidar": "^3.5.3", + "del": "^6.1.1", + "diff": "^5.1.0", + "esbuild": "^0.17.2", + "eslint": "^8.22.0", + "eslint-formatter-autolinkable-stylish": "^1.2.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-local": "^1.0.0", + "eslint-plugin-no-null": "^1.0.2", + "eslint-plugin-simple-import-sort": "^10.0.0", + "fast-xml-parser": "^4.0.11", + "fs-extra": "^9.1.0", + "glob": "^8.1.0", + "hereby": "^1.6.4", + "jsonc-parser": "^3.2.0", + "minimist": "^1.2.8", + "mocha": "^10.2.0", + "mocha-fivemat-progress-reporter": "^0.1.0", + "ms": "^2.1.3", + "node-fetch": "^3.2.10", + "source-map-support": "^0.5.21", + "typescript": "5.0.0-dev.20230112", + "which": "^2.0.2" + }, + "engines": { + "node": ">=12.20" + } + }, + "../../node_modules/.pnpm/vite-plugin-dts@2.3.0_@types+node@18.16.1_rollup@3.21.0_vite@4.3.2_@types+node@18.16.1_/node_modules/vite-plugin-dts": { + "version": "2.3.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.21.4", + "@microsoft/api-extractor": "^7.34.4", + "@rollup/pluginutils": "^5.0.2", + "@rushstack/node-core-library": "^3.55.2", + "debug": "^4.3.4", + "fast-glob": "^3.2.12", + "fs-extra": "^10.1.0", + "kolorist": "^1.7.0", + "magic-string": "^0.29.0", + "ts-morph": "18.0.0" + }, + "devDependencies": { + "@babel/types": "^7.21.4", + "@commitlint/cli": "^17.6.1", + "@commitlint/config-conventional": "^17.6.1", + "@types/debug": "^4.1.7", + "@types/fs-extra": "^9.0.13", + "@types/minimist": "^1.2.2", + "@types/node": "^18.15.11", + "@types/prompts": "^2.4.4", + "@types/semver": "^7.3.13", + "@typescript-eslint/eslint-plugin": "^5.58.0", + "@typescript-eslint/parser": "^5.58.0", + "@vue/eslint-config-standard": "^8.0.1", + "@vue/eslint-config-typescript": "^11.0.2", + "conventional-changelog-cli": "^2.2.2", + "cross-env": "^7.0.3", + "eslint": "^8.38.0", + "eslint-plugin-import": "^2.27.5", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^6.1.1", + "eslint-plugin-vue": "^9.10.0", + "execa": "^6.1.0", + "husky": "^8.0.3", + "is-ci": "^3.0.1", + "lint-staged": "^13.2.1", + "minimist": "^1.2.8", + "pinst": "^3.0.0", + "prettier": "^2.8.7", + "pretty-quick": "^3.1.3", + "prompts": "^2.4.2", + "rimraf": "^3.0.2", + "semver": "^7.4.0", + "tsx": "^3.12.6", + "typescript": "^5.0.4", + "unbuild": "^0.9.4", + "vite": "^3.2.5", + "vitest": "^0.24.5", + "vue": "3.2.41" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "vite": ">=2.9.0" + } + }, + "../../node_modules/.pnpm/vite@4.3.2_@types+node@18.16.1/node_modules/vite": { + "version": "4.3.2", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.17.5", + "postcss": "^8.4.21", + "rollup": "^3.21.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "devDependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/parser": "^7.21.3", + "@babel/types": "^7.21.3", + "@jridgewell/trace-mapping": "^0.3.17", + "@rollup/plugin-alias": "^4.0.3", + "@rollup/plugin-commonjs": "^24.0.1", + "@rollup/plugin-dynamic-import-vars": "^2.0.3", + "@rollup/plugin-json": "^6.0.0", + "@rollup/plugin-node-resolve": "15.0.1", + "@rollup/plugin-typescript": "^11.0.0", + "@rollup/pluginutils": "^5.0.2", + "@types/escape-html": "^1.0.0", + "@types/pnpapi": "^0.0.2", + "acorn": "^8.8.2", + "acorn-walk": "^8.2.0", + "cac": "^6.7.14", + "chokidar": "^3.5.3", + "connect": "^3.7.0", + "connect-history-api-fallback": "^2.0.0", + "convert-source-map": "^2.0.0", + "cors": "^2.8.5", + "cross-spawn": "^7.0.3", + "debug": "^4.3.4", + "dep-types": "link:./src/types", + "dotenv": "^16.0.3", + "dotenv-expand": "^9.0.0", + "es-module-lexer": "^1.2.0", + "escape-html": "^1.0.3", + "estree-walker": "^3.0.3", + "etag": "^1.8.1", + "fast-glob": "^3.2.12", + "http-proxy": "^1.18.1", + "json-stable-stringify": "^1.0.2", + "launch-editor-middleware": "^2.6.0", + "magic-string": "^0.30.0", + "micromatch": "^4.0.5", + "mlly": "^1.2.0", + "mrmime": "^1.0.1", + "okie": "^1.0.1", + "open": "^8.4.2", + "parse5": "^7.1.2", + "periscopic": "^3.1.0", + "picocolors": "^1.0.0", + "picomatch": "^2.3.1", + "postcss-import": "^15.1.0", + "postcss-load-config": "^4.0.1", + "postcss-modules": "^6.0.0", + "resolve.exports": "^2.0.1", + "rollup-plugin-license": "^3.0.1", + "sirv": "^2.0.2", + "source-map-js": "^1.0.2", + "source-map-support": "^0.5.21", + "strip-ansi": "^7.0.1", + "strip-literal": "^1.0.1", + "tsconfck": "^2.1.1", + "tslib": "^2.5.0", + "types": "link:./types", + "ufo": "^1.1.1", + "ws": "^8.13.0" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + }, + "peerDependencies": { + "@types/node": ">= 14", + "less": "*", + "sass": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/@types/node": { + "resolved": "../../node_modules/.pnpm/@types+node@18.16.1/node_modules/@types/node", + "link": true + }, + "node_modules/@types/prop-types": { + "version": "15.7.12", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.12.tgz", + "integrity": "sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==", + "license": "MIT" + }, + "node_modules/@types/react": { + "version": "18.3.3", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.3.tgz", + "integrity": "sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==", + "license": "MIT", + "dependencies": { + "@types/prop-types": "*", + "csstype": "^3.0.2" + } + }, + "node_modules/csstype": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", + "license": "MIT" + }, + "node_modules/typescript": { + "resolved": "../../node_modules/.pnpm/typescript@5.0.2/node_modules/typescript", + "link": true + }, + "node_modules/vite": { + "resolved": "../../node_modules/.pnpm/vite@4.3.2_@types+node@18.16.1/node_modules/vite", + "link": true + }, + "node_modules/vite-plugin-dts": { + "resolved": "../../node_modules/.pnpm/vite-plugin-dts@2.3.0_@types+node@18.16.1_rollup@3.21.0_vite@4.3.2_@types+node@18.16.1_/node_modules/vite-plugin-dts", + "link": true + } + } +} diff --git a/packages/utils/package.json b/packages/utils/package.json index 885d0eb..d84fc04 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -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", @@ -26,5 +26,8 @@ "typescript": "^5.0.2", "vite": "^4.3.2", "vite-plugin-dts": "^2.3.0" + }, + "dependencies": { + "@types/react": "^18.3.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8bdd591..ef41bd5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ importers: specifier: ^3.23.1 version: 3.23.1(react@18.2.0) '@sys42/utils': - specifier: ^0.0.1 - version: 0.0.1 + specifier: workspace:^ + version: link:../utils modern-normalize: specifier: ^2.0.0 version: 2.0.0 @@ -138,6 +138,10 @@ importers: version: 5.3.3(@types/node@18.16.1) packages/utils: + dependencies: + '@types/react': + specifier: ^18.3.3 + version: 18.3.3 devDependencies: '@types/node': specifier: ^18.16.1 @@ -1167,9 +1171,6 @@ packages: '@swc/helpers@0.5.11': resolution: {integrity: sha512-YNlnKRWF2sVojTpIyzwou9XoTNbzbzONwRhOoniEioF1AtaitTvVZblaQRrAzChWQ1bLYyYSWzM18y4WwgzJ+A==} - '@sys42/utils@0.0.1': - resolution: {integrity: sha512-oEuH+UGxoVYCSVYX9HQydlspzSA3vBX7uwk1BQlgTpnbh0EZQ1FzHagZik6r3zZgp60yNvO6NO3Dxb+9/OzThw==} - '@ts-morph/common@0.19.0': resolution: {integrity: sha512-Unz/WHmd4pGax91rdIKWi51wnVUW11QttMEPpBiBgIewnc9UQIX7UDLxr5vRlqeByXCwhkF6VabSsI0raWcyAQ==} @@ -3816,8 +3817,6 @@ snapshots: dependencies: tslib: 2.6.2 - '@sys42/utils@0.0.1': {} - '@ts-morph/common@0.19.0': dependencies: fast-glob: 3.2.12