> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://uploadcare.com/docs/llms.txt.

# Migration guide for @uploadcare/file-uploader v1.x

> Migration guide for @uploadcare/file-uploader v1.x

## BREAKING CHANGES

* The package name `@uploadcare/blocks` has been renamed to `@uploadcare/file-uploader`.
* The prefix `lr-` has been replaced to `uc-` all custom elements.
* The prefix `lr-` has been replaced to `uc-` all attributes.
* The key `LR_WINDOW_KEY` to `UC_WINDOW_KEY` and globalName has been replaced the iife `UC` instead of `LR`.
* The path `./blocks/themes/lr-basic/*` has been changed to `./blocks/themes/uc-basic/*`.
* Bundle `blocks.min.js` is renamed to `file-uploader.min.js`.
* Bundle `blocks.iife.min.js` is renamed to `file-uploader.iife.min.js`.
* The method `registerBlocks` has been renamed to `defineComponents`.
* The method `connectBlocksFrom` has been renamed to `loadFileUploaderFrom`.

## How to migrate

### Rename npm package

First, uninstall the old package:

```bash
npm uninstall @uploadcare/blocks
```

Next, install the new package:

```bash
npm install @uploadcare/file-uploader
```

### Rename imported JS and CSS bundles

Just rename all the imports according to the following table:

| Old name                           | New name                           |
| ---------------------------------- | ---------------------------------- |
| `blocks.min.js`                    | `file-uploader.min.js`             |
| `blocks.iife.min.js`               | `file-uploader.iife.min.js`        |
| `lr-file-uploader-regular.min.js`  | `uc-file-uploader-regular.min.js`  |
| `lr-file-uploader-regular.min.css` | `uc-file-uploader-regular.min.css` |
| `lr-file-uploader-inline.min.js`   | `uc-file-uploader-inline.min.js`   |
| `lr-file-uploader-inline.min.css`  | `uc-file-uploader-inline.min.css`  |
| `lr-file-uploader-minimal.min.js`  | `uc-file-uploader-minimal.min.js`  |
| `lr-file-uploader-minimal.min.css` | `uc-file-uploader-minimal.min.css` |

For example:

```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@v1/web/uc-file-uploader-regular.min.css" >

<script type="module">
  import * as UC from "https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@v1/web/uc-file-uploader-regular.min.js";
  UC.defineComponents(UC);
</script>

<uc-config ctx-name="my-uploader" pubkey="YOUR_PUBLIC_KEY"></uc-config>

<uc-file-uploader-regular ctx-name="my-uploader"></uc-file-uploader-regular>
```

### Rename `lr` to `uc` for each custom elements

Update all instances of `lr-` to `uc-` in your custom elements. For example:

```js
FileUploaderRegular.template = /* HTML */ `
  <uc-simple-btn set="@hidden: isHidden"></uc-simple-btn>

  <uc-modal strokes block-body-scrolling>
    <uc-start-from>
      <uc-drop-area with-icon clickable></uc-drop-area>
      <uc-source-list wrap></uc-source-list>
      <button type="button" l10n="start-from-cancel" class="uc-secondary-btn" set="onclick: *historyBack"></button>
      <uc-copyright></uc-copyright>
    </uc-start-from>
    <uc-upload-list></uc-upload-list>
    <uc-camera-source></uc-camera-source>
    <uc-url-source></uc-url-source>
    <uc-external-source></uc-external-source>
    <uc-cloud-image-editor-activity></uc-cloud-image-editor-activity>
  </uc-modal>

  <uc-progress-bar-common></uc-progress-bar-common>
`;
```

### Rename `lr` to `uc` for each html attributes

All attributes that used to be rendered with the LR prefix are now UC.
The `uc-*` attribute will always be added to the tag itself.
We've started using attribute selectors instead of tag selectors to enable styles to
be attached to custom extended elements.

For example:

Before:

```html
<lr-file-uploader-regular lr-wgt-common lr-file-uploader-regular></lr-file-uploader-regular>
```

After:

```html
<uc-file-uploader-regular uc-wgt-common uc-file-uploader-regular> </uc-file-uploader-regular>
```

### Update Global Name in IIFE

If you have been using an IIFE, the `window` object must now be accessed with the key `UC` instead of `LR`.

### Rename `blocks.min.js` to `file-uploader.min.js`

If you previously used to the `blocks.min.js` bundle, you need to rename it to
`file-uploader.min.js` as follows:

```html
<script src="https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@v1/web/file-uploader.min.js" async />
```

### Rename `blocks.iife.min.js` to `file-uploader.iife.min.js`

If you previously used to the `blocks.iife.min.js` bundle, you need to rename it to
`file-uploader.iife.min.js` as follows:

```html
<script src="https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@v1/web/file-uploader.iife.min.js" async />
```

### Rename `registerBlocks` to `defineComponents`

If you have installed the File Uploader using `*.min.js` bundles, you will need to manually call `defineComponents` as follows:

```html
<script type="module">
  import * as UC from "https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@v1/web/file-uploader.min.js";
  UC.defineComponents(UC);
</script>
```

### Rename `connectBlocksFrom` to `loadFileUploaderFrom`

The was renamed method `connectBlocksFrom` to `loadFileUploaderFrom`

```js
loadFileUploaderFrom('https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@v1/web/file-uploader.iife.min.js').then(
  (UC) => {
    UC.defineComponents(UC);
    //  ...
  }
);
```