Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

main <= feature/release v19 #86

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2023 hackingharold
Copyright (c) 2024 hackingharold

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/on-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
registry-url: https://registry.npmjs.org/
always-auth: true
token: ${{ secrets.NPM_TOKEN }}

- uses: oven-sh/setup-bun@v1
- run: bun install --frozen-lockfile

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 hackingharold
Copyright (c) 2024 hackingharold

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 21 additions & 1 deletion projects/app/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { MatChipRow } from '@angular/material/chips';
import { MatError, MatFormField, MatLabel } from '@angular/material/form-field';
import { MatIcon } from '@angular/material/icon';
import { MatInput } from '@angular/material/input';
import { FileInputDirective } from '@ngx-dropzone/cdk';
import { MatDropzone } from '@ngx-dropzone/material';

@Component({
selector: 'app-root',
standalone: true,
imports: [
CommonModule,
ReactiveFormsModule,
MatFormField,
MatLabel,
MatError,
MatInput,
MatChipRow,
MatIcon,
MatDropzone,
FileInputDirective,
],
template: `<div class="app-container">
<mat-form-field appearance="outline">
<mat-label>Drop only .png files!</mat-label>
Expand Down
29 changes: 0 additions & 29 deletions projects/app/src/app/app.module.ts

This file was deleted.

12 changes: 6 additions & 6 deletions projects/app/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { bootstrapApplication } from '@angular/platform-browser';
import { provideAnimations } from '@angular/platform-browser/animations';
import { AppComponent } from './app/app.component';

import { AppModule } from './app/app.module';


platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
bootstrapApplication(AppComponent, {
providers: [provideAnimations()],
}).catch((e) => console.error(e));
9 changes: 0 additions & 9 deletions projects/cdk/src/lib/cdk.module.ts

This file was deleted.

8 changes: 5 additions & 3 deletions projects/cdk/src/lib/dropzone/dropzone.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { FileInputDirective, FileInputValidators, FileInputValue } from '../file-input';
import { DropzoneCdkModule } from './../cdk.module';
import { DropzoneComponent } from './dropzone.component';

interface Selectors<T> {
Expand All @@ -17,8 +16,7 @@ interface Selectors<T> {
describe('DropzoneComponent', () => {
function configureDropzoneTestingModule<T>(testComponent: Type<T>): Selectors<T> {
const fixture = TestBed.configureTestingModule({
imports: [ReactiveFormsModule, DropzoneCdkModule],
declarations: [testComponent],
imports: [testComponent],
}).createComponent(testComponent);

const element = fixture.debugElement.query(By.directive(DropzoneComponent));
Expand Down Expand Up @@ -148,6 +146,8 @@ describe('DropzoneComponent', () => {

@Component({
selector: 'basic-dropzone',
standalone: true,
imports: [DropzoneComponent, FileInputDirective],
template: `
<ngx-dropzone>
<input type="file" fileInput />
Expand All @@ -158,6 +158,8 @@ class DropzoneBasic {}

@Component({
selector: 'form-control-dropzone',
standalone: true,
imports: [ReactiveFormsModule, DropzoneComponent, FileInputDirective],
template: `
<ngx-dropzone>
<input type="file" fileInput [formControl]="fileCtrl" multiple />
Expand Down
3 changes: 3 additions & 0 deletions projects/cdk/src/lib/dropzone/dropzone.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import { DropzoneService } from './dropzone.service';
@Component({
selector: 'ngx-dropzone',
exportAs: 'dropzone',
standalone: true,
imports: [FileInputDirective],
providers: [DropzoneService],
template: `<ng-content></ng-content>`,
host: {
tabindex: '0',
Expand Down
2 changes: 1 addition & 1 deletion projects/cdk/src/lib/dropzone/dropzone.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { nonNullable } from '../coercion';
import { File } from './../file-input';
import { type File } from './../file-input';

@Injectable({
providedIn: 'root',
Expand Down
10 changes: 5 additions & 5 deletions projects/cdk/src/lib/file-input/accept.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import { AcceptService } from './accept.service';
describe('AcceptService', () => {
let service: AcceptService;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(AcceptService);
});

/** Returns a simple fake file with given extension and optional type. */
const getFile = (ext: string, type?: string) => new File(['...'], `${Date.now()}.${ext}`, { type });

Expand All @@ -14,11 +19,6 @@ describe('AcceptService', () => {
getFile('pdf', 'application/octet-stream'),
];

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(AcceptService);
});

it('should filter based on file extension', () => {
const files = getFileList();
const accepted = service.accepts(files, '.doc, txt , .pdf,random/MIME');
Expand Down
17 changes: 14 additions & 3 deletions projects/cdk/src/lib/file-input/file-input.directive.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, DebugElement, Type } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { FormControl, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { getArrayValueError, getNonArrayValueError } from './file-input-errors';
import { FileInputValue } from './file-input-value';
Expand All @@ -24,8 +24,7 @@ const getFileList = (files: File[]): FileList => {
describe('FileInputDirective', () => {
function configureFileInputTestingModule<T>(testComponent: Type<T>): Selectors<T> {
const fixture = TestBed.configureTestingModule({
imports: [FormsModule, ReactiveFormsModule],
declarations: [FileInputDirective, testComponent],
imports: [testComponent],
}).createComponent(testComponent);

const inputElement = fixture.debugElement.query(By.directive(FileInputDirective));
Expand Down Expand Up @@ -299,34 +298,46 @@ describe('FileInputDirective', () => {
});

@Component({
standalone: true,
imports: [FileInputDirective],
template: `<input fileInput type="file" />`,
})
class FileInputBasic {}

@Component({
standalone: true,
imports: [FileInputDirective],
template: `<input fileInput type="file" multiple />`,
})
class FileInputMultiple {}

@Component({
standalone: true,
imports: [FileInputDirective],
// This combination is not valid! "Append" should only be used together with "multiple".
template: `<input fileInput type="file" mode="append" />`,
})
class FileInputAppend {}

@Component({
standalone: true,
imports: [FileInputDirective],
template: `<input fileInput type="file" multiple mode="append" />`,
})
class FileInputMultipleAppend {}

@Component({
standalone: true,
imports: [ReactiveFormsModule, FileInputDirective],
template: `<input fileInput type="file" [formControl]="fileCtrl" />`,
})
class FileInputWithFormControl {
fileCtrl = new FormControl<FileInputValue>(null, [Validators.required]);
}

@Component({
standalone: true,
imports: [ReactiveFormsModule, FileInputDirective],
template: `<input fileInput type="file" disabled />`,
})
class FileInputDisabled {}
1 change: 1 addition & 0 deletions projects/cdk/src/lib/file-input/file-input.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { FileInputMode, FileInputValue } from './file-input-value';
@Directive({
selector: 'input[fileInput]',
exportAs: 'fileInput',
standalone: true,
host: {
style: 'display: none',
'(focus)': '_focusChanged(true)',
Expand Down
1 change: 0 additions & 1 deletion projects/cdk/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Public API Surface of cdk
*/

export * from './lib/cdk.module';
export * from './lib/coercion';
export * from './lib/dropzone';
export * from './lib/file-input';
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CommonModule } from '@angular/common';
import { Component, DebugElement, Type } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
Expand All @@ -6,8 +7,7 @@ import { MatError, MatFormFieldModule, MatLabel } from '@angular/material/form-f
import { MatIconModule } from '@angular/material/icon';
import { By } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { DropzoneCdkModule, FileInputDirective, FileInputValidators, FileInputValue } from '@ngx-dropzone/cdk';
import { DropzoneMaterialModule } from '../material.module';
import { FileInputDirective, FileInputValidators, FileInputValue } from '@ngx-dropzone/cdk';
import { MatDropzone } from './mat-dropzone.component';

interface Selectors<T> {
Expand All @@ -25,16 +25,7 @@ interface Selectors<T> {
describe('MatDropzone', () => {
function configureDropzoneTestingModule<T>(testComponent: Type<T>): Selectors<T> {
const fixture = TestBed.configureTestingModule({
imports: [
BrowserAnimationsModule,
ReactiveFormsModule,
MatFormFieldModule,
MatIconModule,
MatChipsModule,
DropzoneCdkModule,
DropzoneMaterialModule,
],
declarations: [testComponent],
imports: [CommonModule, BrowserAnimationsModule, testComponent],
}).createComponent(testComponent);

const element = fixture.debugElement.query(By.directive(MatDropzone));
Expand Down Expand Up @@ -127,6 +118,8 @@ describe('MatDropzone', () => {

@Component({
selector: 'basic-dropzone',
standalone: true,
imports: [MatFormFieldModule, MatDropzone, FileInputDirective],
template: `
<mat-form-field>
<mat-label>Drop it basic!</mat-label>
Expand All @@ -140,6 +133,8 @@ class DropzoneBasic {}

@Component({
selector: 'form-control-dropzone',
standalone: true,
imports: [ReactiveFormsModule, MatFormFieldModule, MatIconModule, MatChipsModule, MatDropzone, FileInputDirective],
template: `
<mat-form-field>
<ngx-mat-dropzone>
Expand Down
26 changes: 19 additions & 7 deletions projects/material/src/lib/mat-dropzone/mat-dropzone.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,32 @@ import {
import { Validators } from '@angular/forms';
import { MatChipRow } from '@angular/material/chips';
import { MatFormField, MatFormFieldControl } from '@angular/material/form-field';
import { coerceBoolean, DropzoneComponent, FileInputValue } from '@ngx-dropzone/cdk';
import {
AcceptService,
coerceBoolean,
DropzoneComponent,
DropzoneService,
FileInputDirective,
FileInputValue,
} from '@ngx-dropzone/cdk';
import { merge, Observable, Subject, takeUntil, tap } from 'rxjs';

@Component({
selector: 'ngx-mat-dropzone',
exportAs: 'matDropzone',
standalone: true,
imports: [MatFormField, MatChipRow, FileInputDirective, DropzoneComponent],
providers: [
DropzoneService,
AcceptService,
{
provide: MatFormFieldControl,
useExisting: MatDropzone,
},
],
template: `
<ng-content select="[fileInput]"></ng-content>

<div class="mat-chip-grid" [class.filled-and-float]="filled && shouldLabelFloat">
<ng-content select="mat-chip-row"></ng-content>
</div>
Expand Down Expand Up @@ -57,12 +75,6 @@ import { merge, Observable, Subject, takeUntil, tap } from 'rxjs';
],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
{
provide: MatFormFieldControl,
useExisting: MatDropzone,
},
],
})
export class MatDropzone
extends DropzoneComponent
Expand Down
15 changes: 0 additions & 15 deletions projects/material/src/lib/material.module.ts

This file was deleted.

1 change: 0 additions & 1 deletion projects/material/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
*/

export * from './lib/mat-dropzone';
export * from './lib/material.module';
Loading
Loading