Skip to content

Commit 4ca375f

Browse files
authored
Merge pull request #34 from uploadcare/feat/BLOCKS-469/replace-from-lr-to-uc
feat: replace from lr to uc
2 parents 1f10b41 + 480dfa3 commit 4ca375f

File tree

76 files changed

+1529
-607
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1529
-607
lines changed

examples/angular-uploader/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ $ npm run start
3838

3939
## Installation
4040

41-
All you need to do is to install [`@uploadcare/blocks`](https://www.npmjs.com/package/@uploadcare/blocks) from npm
41+
All you need to do is to install [`@uploadcare/file-uploader`](https://www.npmjs.com/package/@uploadcare/file-uploader) from npm
4242
via your favorite Node package manager.
4343

4444
[Read more about installation](https://uploadcare.com/docs/file-uploader/installation/) in the Uploadcare documentation.
@@ -65,7 +65,7 @@ if you want to know more about using custom elements in Angular.
6565
### Styling
6666

6767
If your styling solution may provide class string or style object, feel free to use them on blocks like
68-
`lr-file-uploader-regular` and override default class using CSS variables.
68+
`uc-file-uploader-regular` and override default class using CSS variables.
6969

7070
Otherwise you may go “full override” way and pass a string with styles to a File Uploader type of your choice.
7171

@@ -75,7 +75,7 @@ Otherwise you may go “full override” way and pass a string with styles to a
7575

7676
You’re always welcome to contribute:
7777

78-
* Create [issues](https://github.com/uploadcare/blocks/issues) every time you feel something is missing or goes wrong.
78+
* Create [issues](https://github.com/uploadcare/file-uploader/issues) every time you feel something is missing or goes wrong.
7979
* Provide your feedback or drop us a support request at <a href="mailto:[email protected]">[email protected]</a>.
8080
* Ask questions on [Stack Overflow](https://stackoverflow.com/questions/tagged/uploadcare) with "uploadcare" tag if others can have these questions as well.
8181
* Star this repo if you like it ⭐️

examples/angular-uploader/package-lock.json

+35-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/angular-uploader/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@angular/platform-browser": "17.0.9",
1818
"@angular/platform-browser-dynamic": "17.0.9",
1919
"@angular/router": "17.0.9",
20-
"@uploadcare/blocks": "0.44.0",
20+
"@uploadcare/file-uploader": "^1.2.0",
2121
"rxjs": "7.4.0",
2222
"tslib": "2.3.1",
2323
"zone.js": "0.14.4"

examples/angular-uploader/src/app/components/file-uploader/file-uploader.component.html

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<div class="root">
22
<!--
3-
Note: `lr-config` is the main block we use to configure File Uploader.
3+
Note: `uc-config` is the main block we use to configure File Uploader.
44
It's important to all the context-related blocks to have the same `ctx-name` attribute.
55
66
See more: https://uploadcare.com/docs/file-uploader/configuration/
77
Available options: https://uploadcare.com/docs/file-uploader/options/
88
9-
Also note: Some options currently are not available via `lr-config`,
9+
Also note: Some options currently are not available via `uc-config`,
1010
but may be set via CSS properties or CSS classes. E.g. accent colors or darkmode
1111
1212
Here they are: https://uploadcare.com/docs/file-uploader/styling/
1313
-->
14-
<lr-config
14+
<uc-config
1515
#config
1616
[attr.ctx-name]="uploaderCtxName"
1717
pubkey="a6ca334c3520777c0045"
@@ -20,19 +20,19 @@
2020
confirmUpload="false"
2121
removeCopyright="true"
2222
imgOnly="true"
23-
></lr-config>
23+
></uc-config>
2424

25-
<lr-file-uploader-regular
25+
<uc-file-uploader-regular
2626
[attr.ctx-name]="uploaderCtxName"
2727
[class]="uploaderClassName"
2828
[class.uc-dark]="theme === 'dark'"
2929
[class.uc-light]="theme === 'light'"
30-
></lr-file-uploader-regular>
30+
></uc-file-uploader-regular>
3131

32-
<lr-upload-ctx-provider
32+
<uc-upload-ctx-provider
3333
#ctxProvider
3434
[attr.ctx-name]="uploaderCtxName"
35-
></lr-upload-ctx-provider>
35+
></uc-upload-ctx-provider>
3636

3737
<div class="previews">
3838
@for (file of files; track file.cdnUrl) {

examples/angular-uploader/src/app/components/file-uploader/file-uploader.component.scss

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
object-fit: cover;
5151
}
5252

53-
.root::ng-deep lr-simple-btn button {
53+
.root::ng-deep uc-simple-btn button {
5454
height: auto;
5555
padding: 10px 12px !important;
5656
font-family: monospace;
@@ -63,16 +63,16 @@
6363
color: var(--ui-control-text-color);
6464
}
6565

66-
.root::ng-deep lr-simple-btn lr-icon {
66+
.root::ng-deep uc-simple-btn uc-icon {
6767
display: none;
6868
}
6969

70-
.root::ng-deep lr-simple-btn button:hover,
71-
.root::ng-deep lr-simple-btn button:focus {
70+
.root::ng-deep uc-simple-btn button:hover,
71+
.root::ng-deep uc-simple-btn button:focus {
7272
background: var(--ui-control-background-color);
7373
outline: 3px solid var(--ui-control-outline-color-focus);
7474
}
7575

76-
.root::ng-deep lr-simple-btn button:active {
76+
.root::ng-deep uc-simple-btn button:active {
7777
border-color: var(--ui-control-border-color-focus);
7878
}

examples/angular-uploader/src/app/components/file-uploader/file-uploader.component.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import {
77
Output,
88
ViewChild
99
} from '@angular/core';
10-
import * as LR from '@uploadcare/blocks';
11-
import { OutputFileEntry } from '@uploadcare/blocks';
10+
import * as UC from '@uploadcare/file-uploader';
11+
import { OutputFileEntry } from '@uploadcare/file-uploader';
1212

13-
LR.registerBlocks(LR);
13+
UC.defineComponents(UC);
1414

1515
@Component({
1616
selector: 'file-uploader',
@@ -29,11 +29,11 @@ export class FileUploaderComponent {
2929

3030
uploadedFiles: OutputFileEntry<'success'>[] = [];
3131
@ViewChild('ctxProvider', { static: true }) ctxProviderRef!: ElementRef<
32-
InstanceType<LR.UploadCtxProvider>
32+
InstanceType<UC.UploadCtxProvider>
3333
>;
3434

3535
@ViewChild('config', { static: true }) configRef!: ElementRef<
36-
InstanceType<LR.Config>
36+
InstanceType<UC.Config>
3737
>;
3838

3939
ngOnInit() {
@@ -100,14 +100,14 @@ export class FileUploaderComponent {
100100
See more: https://uploadcare.com/docs/file-uploader/api/
101101
*/
102102
resetUploaderState() {
103-
this.ctxProviderRef.nativeElement.uploadCollection.clearAll();
103+
this.ctxProviderRef.nativeElement.getAPI().removeAllFiles();
104104
}
105105

106106
handleRemoveClick(uuid: OutputFileEntry['uuid']) {
107107
this.filesChange.emit(this.files.filter((f) => f.uuid !== uuid));
108108
}
109109

110-
handleChangeEvent = (e: LR.EventMap['change']) => {
110+
handleChangeEvent = (e: UC.EventMap['change']) => {
111111
this.uploadedFiles = e.detail.allEntries.filter(f => f.status === 'success') as OutputFileEntry<'success'>[];
112112
};
113113

examples/angular-uploader/src/app/views/form-view/form-view.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component } from '@angular/core';
22
import { JsonPipe } from '@angular/common';
33
import { FormControl, ReactiveFormsModule } from '@angular/forms';
4-
import { OutputFileEntry } from '@uploadcare/blocks';
4+
import { OutputFileEntry } from '@uploadcare/file-uploader';
55

66
import { FileUploaderComponent } from '../../components/file-uploader/file-uploader.component';
77

examples/angular-uploader/src/app/views/form-view/mocks.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { OutputFileEntry } from '@uploadcare/blocks';
1+
import { OutputFileEntry } from '@uploadcare/file-uploader';
22

33
type MocksType = {
44
title: string;

examples/angular-uploader/src/app/views/minimal-view/minimal-view.component.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
<lr-config
1+
<uc-config
22
ctx-name="my-uploader-2"
33
pubkey="a6ca334c3520777c0045"
4-
></lr-config>
5-
<lr-file-uploader-minimal
4+
></uc-config>
5+
<uc-file-uploader-minimal
66
ctx-name="my-uploader-2"
7-
></lr-file-uploader-minimal>
8-
<lr-upload-ctx-provider
7+
></uc-file-uploader-minimal>
8+
<uc-upload-ctx-provider
99
ctx-name="my-uploader-2"
1010
#ctxProvider
11-
></lr-upload-ctx-provider>
11+
></uc-upload-ctx-provider>
1212

1313
<div class="previews">
1414
@for (file of files; track file.cdnUrl) {

examples/angular-uploader/src/app/views/minimal-view/minimal-view.component.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import {
77
Output,
88
ViewChild,
99
} from '@angular/core';
10-
import * as LR from '@uploadcare/blocks';
11-
import { OutputFileEntry } from '@uploadcare/blocks';
10+
import * as UC from '@uploadcare/file-uploader';
11+
import { OutputFileEntry } from '@uploadcare/file-uploader';
1212

13-
LR.registerBlocks(LR);
13+
UC.defineComponents(UC);
1414

1515
@Component({
1616
selector: 'minimal-view',
@@ -24,7 +24,7 @@ export class MinimalViewComponent {
2424
@Output() filesChange = new EventEmitter<OutputFileEntry<'success'>[]>();
2525

2626
@ViewChild('ctxProvider', { static: true }) ctxProviderRef!: ElementRef<
27-
InstanceType<LR.UploadCtxProvider>
27+
InstanceType<UC.UploadCtxProvider>
2828
>;
2929

3030
ngOnInit() {
@@ -47,7 +47,7 @@ export class MinimalViewComponent {
4747
);
4848
}
4949

50-
handleChangeEvent = (e: LR.EventMap['change']) => {
50+
handleChangeEvent = (e: UC.EventMap['change']) => {
5151
console.log('change event payload:', e);
5252

5353
this.files = e.detail.allEntries.filter(f => f.status === 'success') as OutputFileEntry<'success'>[];

examples/angular-uploader/src/app/views/regular-view/regular-view.component.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
<lr-config
1+
<uc-config
22
ctx-name="my-uploader-3"
33
pubkey="a6ca334c3520777c0045"
44
source-list="local, url, camera, dropbox"
5-
></lr-config>
6-
<lr-file-uploader-regular
5+
></uc-config>
6+
<uc-file-uploader-regular
77
ctx-name="my-uploader-3"
8-
></lr-file-uploader-regular>
9-
<lr-upload-ctx-provider
8+
></uc-file-uploader-regular>
9+
<uc-upload-ctx-provider
1010
ctx-name="my-uploader-3"
1111
#ctxProvider
12-
></lr-upload-ctx-provider>
12+
></uc-upload-ctx-provider>
1313

1414
<div class="previews">
1515
@for (file of files; track file.cdnUrl) {

examples/angular-uploader/src/app/views/regular-view/regular-view.component.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core';
2-
import * as LR from '@uploadcare/blocks';
3-
import { OutputFileEntry } from '@uploadcare/blocks';
2+
import * as UC from '@uploadcare/file-uploader';
3+
import { OutputFileEntry } from '@uploadcare/file-uploader';
44

5-
LR.registerBlocks(LR);
5+
UC.defineComponents(UC);
66

77
@Component({
88
selector: 'regular-view',
@@ -16,7 +16,7 @@ export class RegularViewComponent {
1616
@Output() filesChange = new EventEmitter<OutputFileEntry<'success'>[]>();
1717

1818
@ViewChild('ctxProvider', { static: true }) ctxProviderRef!: ElementRef<
19-
InstanceType<LR.UploadCtxProvider>
19+
InstanceType<UC.UploadCtxProvider>
2020
>;
2121

2222
ngOnInit() {
@@ -39,7 +39,7 @@ export class RegularViewComponent {
3939
);
4040
}
4141

42-
handleChangeEvent = (e: LR.EventMap['change']) => {
42+
handleChangeEvent = (e: UC.EventMap['change']) => {
4343
console.log('change event payload:', e);
4444

4545
this.files = e.detail.allEntries.filter(f => f.status === 'success') as OutputFileEntry<'success'>[];

0 commit comments

Comments
 (0)