Skip to content

Commit

Permalink
feat: bump @uploadcare/file-uploader to v1
Browse files Browse the repository at this point in the history
  • Loading branch information
egordidenko committed Aug 1, 2024
1 parent 7a9d2bf commit 671457a
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 55 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion packages/react-uploader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ import "@uploadcare/react-uploader/core.css";
```

```css
.fileUploaderWrapper lr-file-uploader-regular {
.fileUploaderWrapper uc-file-uploader-regular {
}
```

Expand Down
2 changes: 1 addition & 1 deletion packages/react-uploader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@types/react": "17 || 18"
},
"dependencies": {
"@uploadcare/blocks": "^0.46.3",
"@uploadcare/file-uploader": "^1.2.0",
"@uploadcare/react-adapter": "^0.3.0"
},
"repository": {
Expand Down
19 changes: 11 additions & 8 deletions packages/react-uploader/src/Uploader/Inline/FileUploaderInline.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import React, { type FC, useMemo } from "react";
import * as LR from "@uploadcare/blocks";
import "@uploadcare/blocks/web/lr-file-uploader-inline.min.css";
import * as UC from "@uploadcare/file-uploader";
import "@uploadcare/file-uploader/web/uc-file-uploader-inline.min.css";
import { customElementToReactComponent } from "@uploadcare/react-adapter";
import { AdapterConfig } from "../core/AdapterConfig";
import { AdapterUploadCtxProvider } from "../core/AdapterUploadCtxProvider";
import type { TProps } from "../types";
import { getCalcPropertyOfProps } from "../../utils/getCalcPropertyOfProps";
import { getUserAgentIntegration } from "../../utils/getUserAgentIntegration";
import { ConditionalSuspense, useIsBrowser } from "../../SSR/ConditionalSuspense";
import {
ConditionalSuspense,
useIsBrowser,
} from "../../SSR/ConditionalSuspense";

LR.registerBlocks(LR);
UC.defineComponents(UC);

const AdapterFileUploaderInline = customElementToReactComponent({
react: React,
tag: "lr-file-uploader-inline",
elClass: LR.FileUploaderMinimal,
tag: "uc-file-uploader-inline",
elClass: UC.FileUploaderMinimal,
});

export const FileUploaderInline: FC<TProps> = ({
Expand All @@ -25,7 +28,7 @@ export const FileUploaderInline: FC<TProps> = ({
fallback,
...props
}) => {
const CTX_NAME = useMemo(() => ctxName ?? LR.UID.generate(), [ctxName]);
const CTX_NAME = useMemo(() => ctxName ?? UC.UID.generate(), [ctxName]);

const { eventHandlers, config } = useMemo(
() => getCalcPropertyOfProps<TProps>(props),
Expand All @@ -35,7 +38,7 @@ export const FileUploaderInline: FC<TProps> = ({
const isBrowser = useIsBrowser();

return (
<ConditionalSuspense condition={isBrowser} fallback={fallback} >
<ConditionalSuspense condition={isBrowser} fallback={fallback}>
<div className={className}>
{/* @ts-ignore */}
<AdapterConfig userAgentIntegration={getUserAgentIntegration()} ctx-name={CTX_NAME} {...config} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import React, { type FC, useMemo } from "react";
import * as LR from "@uploadcare/blocks";
import "@uploadcare/blocks/web/lr-file-uploader-minimal.min.css"
import * as UC from "@uploadcare/file-uploader";
import "@uploadcare/file-uploader/web/uc-file-uploader-minimal.min.css";
import { customElementToReactComponent } from "@uploadcare/react-adapter";
import { AdapterConfig } from "../core/AdapterConfig";
import { AdapterUploadCtxProvider } from "../core/AdapterUploadCtxProvider";
import type { TProps } from "../types";
import { getCalcPropertyOfProps } from "../../utils/getCalcPropertyOfProps";
import { getUserAgentIntegration } from "../../utils/getUserAgentIntegration";
import { ConditionalSuspense, useIsBrowser } from "../../SSR/ConditionalSuspense";
import {
ConditionalSuspense,
useIsBrowser,
} from "../../SSR/ConditionalSuspense";

LR.registerBlocks(LR);
UC.defineComponents(UC);

const AdapterFileUploaderMinimal = customElementToReactComponent({
react: React,
tag: "lr-file-uploader-minimal",
elClass: LR.FileUploaderMinimal,
tag: "uc-file-uploader-minimal",
elClass: UC.FileUploaderMinimal,
});


export const FileUploaderMinimal: FC<TProps> = ({
ctxName,
className,
Expand All @@ -26,7 +28,7 @@ export const FileUploaderMinimal: FC<TProps> = ({
fallback,
...props
}) => {
const CTX_NAME = useMemo(() => ctxName ?? LR.UID.generate(), [ctxName]);
const CTX_NAME = useMemo(() => ctxName ?? UC.UID.generate(), [ctxName]);

const { eventHandlers, config } = useMemo(
() => getCalcPropertyOfProps<TProps>(props),
Expand All @@ -36,7 +38,7 @@ export const FileUploaderMinimal: FC<TProps> = ({
const isBrowser = useIsBrowser();

return (
<ConditionalSuspense condition={isBrowser} fallback={fallback} >
<ConditionalSuspense condition={isBrowser} fallback={fallback}>
<div className={className}>
{/* @ts-ignore */}
<AdapterConfig userAgentIntegration={getUserAgentIntegration()} ctx-name={CTX_NAME} {...config} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import React, { type FC, useMemo } from "react";
import * as LR from "@uploadcare/blocks";
import "@uploadcare/blocks/web/lr-file-uploader-regular.min.css";
import * as UC from "@uploadcare/file-uploader";
import "@uploadcare/file-uploader/web/uc-file-uploader-regular.min.css";
import { customElementToReactComponent } from "@uploadcare/react-adapter";
import { AdapterConfig } from "../core/AdapterConfig";
import { AdapterUploadCtxProvider } from "../core/AdapterUploadCtxProvider";
import type { TProps } from "../types";

import { getCalcPropertyOfProps } from "../../utils/getCalcPropertyOfProps";
import { getUserAgentIntegration } from "../../utils/getUserAgentIntegration";
import { ConditionalSuspense, useIsBrowser } from "../../SSR/ConditionalSuspense";
import {
ConditionalSuspense,
useIsBrowser,
} from "../../SSR/ConditionalSuspense";

LR.registerBlocks(LR);
UC.defineComponents(UC);

const AdapterFileUploaderRegular = customElementToReactComponent({
react: React,
tag: "lr-file-uploader-regular",
elClass: LR.FileUploaderRegular,
tag: "uc-file-uploader-regular",
elClass: UC.FileUploaderRegular,
});

export const FileUploaderRegular: FC<TProps> = ({
Expand All @@ -26,7 +29,7 @@ export const FileUploaderRegular: FC<TProps> = ({
fallback,
...props
}) => {
const CTX_NAME = useMemo(() => ctxName ?? LR.UID.generate(), [ctxName]);
const CTX_NAME = useMemo(() => ctxName ?? UC.UID.generate(), [ctxName]);

const { eventHandlers, config } = useMemo(
() => getCalcPropertyOfProps<TProps>(props),
Expand All @@ -49,6 +52,6 @@ export const FileUploaderRegular: FC<TProps> = ({
{/* @ts-ignore */}
<AdapterFileUploaderRegular class={classNameUploader} ctx-name={CTX_NAME} />
</div>
</ConditionalSuspense >
</ConditionalSuspense>
);
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { customElementToReactComponent } from "@uploadcare/react-adapter";
import * as LR from "@uploadcare/blocks";
import * as UC from "@uploadcare/file-uploader";

export const AdapterConfig = customElementToReactComponent({
react: React,
tag: "lr-config",
elClass: LR.Config,
tag: "uc-config",
elClass: UC.Config,
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react";
import { customElementToReactComponent } from "@uploadcare/react-adapter";
import * as LR from "@uploadcare/blocks";
import * as UC from "@uploadcare/file-uploader";

export const AdapterUploadCtxProvider = customElementToReactComponent({
react: React,
tag: "lr-upload-ctx-provider",
elClass: LR.UploadCtxProvider,
schemaEvents: LR.UploadCtxProvider.EventType,
tag: "uc-upload-ctx-provider",
elClass: UC.UploadCtxProvider,
schemaEvents: UC.UploadCtxProvider.EventType,
});
9 changes: 3 additions & 6 deletions packages/react-uploader/src/Uploader/types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@

import type { Ref } from "react";
import type {
ConfigType,
UploadCtxProvider,
EventMap,
} from "@uploadcare/blocks";
import type {
TProps as TPropsConditionalSuspense
} from "../SSR/ConditionalSuspense"
} from "@uploadcare/file-uploader";
import type { TProps as TPropsConditionalSuspense } from "../SSR/ConditionalSuspense";

type TToCamelCase<S extends string> = S extends `${infer Head}-${infer Tail}`
? `${Lowercase<Head>}${Capitalize<TToCamelCase<Tail>>}`
Expand Down Expand Up @@ -42,4 +39,4 @@ export type TProps = TDefaultProps &
TPropsWithEvents &
TPropsWithConfig;

export { UploadCtxProvider } from "@uploadcare/blocks";
export { UploadCtxProvider } from "@uploadcare/file-uploader";
6 changes: 3 additions & 3 deletions packages/react-uploader/src/libs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export { FileUploaderMinimal } from "./Uploader/Minimal/FileUploaderMinimal";
export { FileUploaderInline } from "./Uploader/Inline/FileUploaderInline";

export { type TProps, UploadCtxProvider } from "./Uploader/types";
export { type TEventsSchema } from './Uploader/types'
export { type TEventsSchema } from "./Uploader/types";

export { defineLocale } from "@uploadcare/blocks"
export * from '@uploadcare/blocks/types/index.js'
export { defineLocale } from "@uploadcare/file-uploader";
export * from "@uploadcare/file-uploader/types/index.js";
10 changes: 3 additions & 7 deletions packages/react-uploader/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,21 @@ export default defineConfig({
build: {
cssCodeSplit: true,
lib: {
entry: [
resolve(__dirname, "src/libs.ts"),
],
entry: [resolve(__dirname, "src/libs.ts")],
name: "@uploadcare/react-uploader",

formats: ["es", "cjs"],

fileName: "react-uploader",
},
rollupOptions: {
external: ["react", "@uploadcare/blocks"],
external: ["react", "@uploadcare/file-uploader"],
output: {
globals: {
react: "React",
},
},
},
},
plugins: [
dts({ rollupTypes: true, insertTypesEntry: true }),
],
plugins: [dts({ rollupTypes: true, insertTypesEntry: true })],
});

0 comments on commit 671457a

Please sign in to comment.