diff --git a/package.json b/package.json index d91d4933d..526ca6c31 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "react-virtuoso": "^2.16.5", "remark-gfm": "^3.0.1", "textarea-caret": "^3.1.0", + "tslib": "^2.6.2", "unist-builder": "^3.0.0", "unist-util-visit": "^4.1.1" }, @@ -171,7 +172,6 @@ "stream-chat": "^8.4.1", "style-loader": "^2.0.0", "ts-jest": "^26.5.1", - "tslib": "2.3.0", "typescript": "^4.7.4", "url-loader": "^4.1.1", "webpack": "4.44.2", diff --git a/rollup.config.js b/rollup.config.js index 824dfcd74..f4b93d7b8 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -81,9 +81,9 @@ const basePlugins = ({ useBrowserResolve = false }) => [ copy({ targets: [ { dest: 'dist/assets', src: './node_modules/@stream-io/stream-chat-css/dist/assets/*' }, - { dest: 'dist/css', src: './node_modules/@stream-io/stream-chat-css/dist/css/*' }, + { dest: 'dist/css', src: './node_modules/@stream-io/stream-chat-css/dist/css/*.css' }, { dest: 'dist/scss', src: './node_modules/@stream-io/stream-chat-css/dist/scss/*' }, - { dest: 'dist/css/v2', src: './node_modules/@stream-io/stream-chat-css/dist/v2/css/*' }, + { dest: 'dist/css/v2', src: './node_modules/@stream-io/stream-chat-css/dist/v2/css/*.css' }, { dest: 'dist/scss/v2', src: './node_modules/@stream-io/stream-chat-css/dist/v2/scss/*' }, ], verbose: process.env.VERBOSE, diff --git a/src/components/ReactFileUtilities/utils.ts b/src/components/ReactFileUtilities/utils.ts index f1c5060e6..46af21740 100644 --- a/src/components/ReactFileUtilities/utils.ts +++ b/src/components/ReactFileUtilities/utils.ts @@ -1,21 +1,26 @@ import type { FileLike } from './types'; +import { ChangeEvent, useCallback } from 'react'; export const useHandleFileChangeWrapper = ( resetOnChange = false, handler?: (files: Array) => void, -) => ({ currentTarget }: React.ChangeEvent) => { - const { files } = currentTarget; +) => + useCallback( + ({ currentTarget }: ChangeEvent) => { + const { files } = currentTarget; - if (!files) return; + if (!files) return; - try { - handler?.(Array.from(files)); - } catch (error) { - console.error(error); - } + try { + handler?.(Array.from(files)); + } catch (error) { + console.error(error); + } - if (resetOnChange) currentTarget.value = ''; -}; + if (resetOnChange) currentTarget.value = ''; + }, + [handler, resetOnChange], + ); export function dataTransferItemsHaveFiles(items?: DataTransferItem[]): boolean { if (!items || !items.length) { diff --git a/src/components/index.ts b/src/components/index.ts index a52237d03..d8f57cc80 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -31,3 +31,5 @@ export * from './Tooltip'; export * from './TypingIndicator'; export * from './UserItem'; export * from './Window'; + +export { UploadButton, UploadButtonProps } from './ReactFileUtilities'; diff --git a/tsconfig.json b/tsconfig.json index 988c528f9..bcc6678d3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,18 +1,13 @@ { "compilerOptions": { "baseUrl": "./src", - "paths": { - "*": ["src/@types/*"] - }, "allowUnreachableCode": false, - "allowUnusedLabels": false, "esModuleInterop": true, - "importsNotUsedAsValues": "error", "forceConsistentCasingInFileNames": true, "jsx": "react", - "lib": ["esnext", "DOM"], - "module": "esnext", - "moduleResolution": "node", + "lib": ["ESNext", "DOM"], + "module": "ESNext", + "moduleResolution": "Node", "noFallthroughCasesInSwitch": true, "noImplicitReturns": true, "noImplicitUseStrict": false, @@ -25,7 +20,7 @@ "strict": true, "target": "ES5", "allowSyntheticDefaultImports": true, - "noEmitOnError": false, + "noEmitOnError": true, "noImplicitAny": true, "allowJs": true, "checkJs": false, @@ -33,14 +28,8 @@ "declaration": true, "declarationDir": "./dist", "declarationMap": true, - "types": ["vite/client"] + "importHelpers": true }, "include": ["./src/**/*"], - "exclude": [ - "./src/mock-builders", - "node_modules", - "babel.config.js", - "jest.config.js", - "**/__tests__/*.test.js" - ] + "exclude": ["./src/stories", "./src/mock-builders", "./src/**/__tests__/*"] } diff --git a/yarn.lock b/yarn.lock index 5edba142b..7b0681b82 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14044,11 +14044,6 @@ tsconfig-paths@^3.9.0: minimist "^1.2.0" strip-bom "^3.0.0" -tslib@2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.0.tgz#803b8cdab3e12ba581a4ca41c8839bbb0dacb09e" - integrity sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg== - tslib@^1.8.1, tslib@^1.9.3: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" @@ -14064,6 +14059,11 @@ tslib@^2.4.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== +tslib@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" + integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== + tsutils@^3.21.0: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"