feat: nwaifu-ui lib with btn
This commit is contained in:
42
.eslintrc.base.json
Normal file
42
.eslintrc.base.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"root": true,
|
||||
"ignorePatterns": ["**/*"],
|
||||
"plugins": ["@nx"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
||||
"rules": {
|
||||
"@nx/enforce-module-boundaries": [
|
||||
"error",
|
||||
{
|
||||
"enforceBuildableLibDependency": true,
|
||||
"allow": [],
|
||||
"depConstraints": [
|
||||
{
|
||||
"sourceTag": "*",
|
||||
"onlyDependOnLibsWithTags": ["*"]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["*.ts", "*.tsx"],
|
||||
"extends": ["plugin:@nx/typescript"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.js", "*.jsx"],
|
||||
"extends": ["plugin:@nx/javascript"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
|
||||
"env": {
|
||||
"jest": true
|
||||
},
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,24 +1,17 @@
|
||||
{
|
||||
"root": true,
|
||||
"ignorePatterns": ["!**/*"],
|
||||
"plugins": ["@nx"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts", "*.tsx"],
|
||||
"extends": ["plugin:@nx/typescript"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.js", "*.jsx"],
|
||||
"extends": ["plugin:@nx/javascript"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.ts"],
|
||||
"extends": [
|
||||
"plugin:@nx/angular",
|
||||
"plugin:@angular-eslint/template/process-inline-templates"
|
||||
],
|
||||
"extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
|
||||
"rules": {
|
||||
"@angular-eslint/directive-selector": [
|
||||
"error",
|
||||
@@ -43,5 +36,6 @@
|
||||
"extends": ["plugin:@nx/angular-template"],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
],
|
||||
"extends": ["./.eslintrc.base.json"]
|
||||
}
|
||||
|
||||
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@@ -1,5 +1,8 @@
|
||||
{
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true,
|
||||
"editor.tabSize": 2
|
||||
"editor.tabSize": 2,
|
||||
"cSpell.words": [
|
||||
"nwui"
|
||||
]
|
||||
}
|
||||
23
jest.config.app.ts
Normal file
23
jest.config.app.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/* eslint-disable */
|
||||
export default {
|
||||
displayName: 'NitroPlusTranslator',
|
||||
preset: './jest.preset.js',
|
||||
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
|
||||
coverageDirectory: './coverage/NitroPlusTranslator',
|
||||
transform: {
|
||||
'^.+\\.(ts|mjs|js|html)$': [
|
||||
'jest-preset-angular',
|
||||
{
|
||||
tsconfig: '<rootDir>/tsconfig.spec.json',
|
||||
stringifyContentPathRegex: '\\.(html|svg)$',
|
||||
},
|
||||
],
|
||||
},
|
||||
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
|
||||
snapshotSerializers: [
|
||||
'jest-preset-angular/build/serializers/no-ng-attributes',
|
||||
'jest-preset-angular/build/serializers/ng-snapshot',
|
||||
'jest-preset-angular/build/serializers/html-comment',
|
||||
],
|
||||
testMatch: ['<rootDir>/src/**/__tests__/**/*.[jt]s?(x)', '<rootDir>/src/**/*(*.)@(spec|test).[jt]s?(x)'],
|
||||
};
|
||||
@@ -1,26 +1,5 @@
|
||||
/* eslint-disable */
|
||||
export default {
|
||||
displayName: 'NitroPlusTranslator',
|
||||
preset: './jest.preset.js',
|
||||
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
|
||||
coverageDirectory: './coverage/NitroPlusTranslator',
|
||||
transform: {
|
||||
'^.+\\.(ts|mjs|js|html)$': [
|
||||
'jest-preset-angular',
|
||||
{
|
||||
tsconfig: '<rootDir>/tsconfig.spec.json',
|
||||
stringifyContentPathRegex: '\\.(html|svg)$',
|
||||
},
|
||||
],
|
||||
},
|
||||
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
|
||||
snapshotSerializers: [
|
||||
'jest-preset-angular/build/serializers/no-ng-attributes',
|
||||
'jest-preset-angular/build/serializers/ng-snapshot',
|
||||
'jest-preset-angular/build/serializers/html-comment',
|
||||
],
|
||||
testMatch: [
|
||||
'<rootDir>/src/**/__tests__/**/*.[jt]s?(x)',
|
||||
'<rootDir>/src/**/*(*.)@(spec|test).[jt]s?(x)',
|
||||
],
|
||||
};
|
||||
import { getJestProjectsAsync } from '@nx/jest';
|
||||
|
||||
export default async () => ({
|
||||
projects: await getJestProjectsAsync(),
|
||||
});
|
||||
|
||||
46
nwaifu-ui/.eslintrc.json
Normal file
46
nwaifu-ui/.eslintrc.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"extends": [
|
||||
"../.eslintrc.base.json"
|
||||
],
|
||||
"ignorePatterns": [
|
||||
"!**/*"
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.ts"
|
||||
],
|
||||
"extends": [
|
||||
"plugin:@nx/angular",
|
||||
"plugin:@angular-eslint/template/process-inline-templates"
|
||||
],
|
||||
"rules": {
|
||||
"@angular-eslint/directive-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "attribute",
|
||||
"prefix": "nwui",
|
||||
"style": "camelCase"
|
||||
}
|
||||
],
|
||||
"@angular-eslint/component-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "element",
|
||||
"prefix": "nwui",
|
||||
"style": "kebab-case"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"*.html"
|
||||
],
|
||||
"extends": [
|
||||
"plugin:@nx/angular-template"
|
||||
],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
7
nwaifu-ui/README.md
Normal file
7
nwaifu-ui/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# nwaifu-ui
|
||||
|
||||
This library was generated with [Nx](https://nx.dev).
|
||||
|
||||
## Running unit tests
|
||||
|
||||
Run `nx test nwaifu-ui` to execute the unit tests.
|
||||
22
nwaifu-ui/jest.config.ts
Normal file
22
nwaifu-ui/jest.config.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/* eslint-disable */
|
||||
export default {
|
||||
displayName: 'nwaifu-ui',
|
||||
preset: '../jest.preset.js',
|
||||
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
|
||||
coverageDirectory: '../coverage/nwaifu-ui',
|
||||
transform: {
|
||||
'^.+\\.(ts|mjs|js|html)$': [
|
||||
'jest-preset-angular',
|
||||
{
|
||||
tsconfig: '<rootDir>/tsconfig.spec.json',
|
||||
stringifyContentPathRegex: '\\.(html|svg)$',
|
||||
},
|
||||
],
|
||||
},
|
||||
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
|
||||
snapshotSerializers: [
|
||||
'jest-preset-angular/build/serializers/no-ng-attributes',
|
||||
'jest-preset-angular/build/serializers/ng-snapshot',
|
||||
'jest-preset-angular/build/serializers/html-comment',
|
||||
],
|
||||
};
|
||||
9
nwaifu-ui/project.json
Normal file
9
nwaifu-ui/project.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "nwaifu-ui",
|
||||
"$schema": "../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "nwaifu-ui/src",
|
||||
"prefix": "nwui",
|
||||
"projectType": "library",
|
||||
"tags": [],
|
||||
"targets": {}
|
||||
}
|
||||
1
nwaifu-ui/src/index.ts
Normal file
1
nwaifu-ui/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './lib';
|
||||
@@ -0,0 +1 @@
|
||||
<button [disabled]="disabled" [type]="type"><ng-content></ng-content></button>
|
||||
@@ -8,7 +8,16 @@ button {
|
||||
border-radius: 15px;
|
||||
transition: ease-in-out 0.2s;
|
||||
margin: 2rem;
|
||||
&:hover {
|
||||
&:hover,
|
||||
&:active {
|
||||
transform: scale(1.2);
|
||||
}
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
&:hover,
|
||||
&:active {
|
||||
cursor: not-allowed;
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
15
nwaifu-ui/src/lib/components/button/button.component.ts
Normal file
15
nwaifu-ui/src/lib/components/button/button.component.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'nwui-button',
|
||||
templateUrl: './button.component.html',
|
||||
styleUrls: ['./button.component.scss'],
|
||||
standalone: true,
|
||||
imports: [CommonModule],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class ButtonComponent {
|
||||
@Input() disabled = false;
|
||||
@Input() type: string | undefined;
|
||||
}
|
||||
1
nwaifu-ui/src/lib/components/button/index.ts
Normal file
1
nwaifu-ui/src/lib/components/button/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './button.component';
|
||||
1
nwaifu-ui/src/lib/components/index.ts
Normal file
1
nwaifu-ui/src/lib/components/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './button';
|
||||
1
nwaifu-ui/src/lib/index.ts
Normal file
1
nwaifu-ui/src/lib/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './components';
|
||||
8
nwaifu-ui/src/test-setup.ts
Normal file
8
nwaifu-ui/src/test-setup.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
|
||||
globalThis.ngJest = {
|
||||
testEnvironmentOptions: {
|
||||
errorOnUnknownElements: true,
|
||||
errorOnUnknownProperties: true,
|
||||
},
|
||||
};
|
||||
import 'jest-preset-angular/setup-jest';
|
||||
29
nwaifu-ui/tsconfig.json
Normal file
29
nwaifu-ui/tsconfig.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2022",
|
||||
"useDefineForClassFields": false,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.lib.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.spec.json"
|
||||
}
|
||||
],
|
||||
"extends": "../tsconfig.base.json",
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true
|
||||
}
|
||||
}
|
||||
12
nwaifu-ui/tsconfig.lib.json
Normal file
12
nwaifu-ui/tsconfig.lib.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../dist/out-tsc",
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"inlineSources": true,
|
||||
"types": []
|
||||
},
|
||||
"exclude": ["src/**/*.spec.ts", "src/test-setup.ts", "jest.config.ts", "src/**/*.test.ts"],
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
11
nwaifu-ui/tsconfig.spec.json
Normal file
11
nwaifu-ui/tsconfig.spec.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../dist/out-tsc",
|
||||
"module": "commonjs",
|
||||
"target": "es2016",
|
||||
"types": ["jest", "node"]
|
||||
},
|
||||
"files": ["src/test-setup.ts"],
|
||||
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
|
||||
}
|
||||
7
nx.json
7
nx.json
@@ -49,6 +49,13 @@
|
||||
"linter": "eslint",
|
||||
"style": "scss",
|
||||
"unitTestRunner": "jest"
|
||||
},
|
||||
"@nx/angular:library": {
|
||||
"linter": "eslint",
|
||||
"unitTestRunner": "jest"
|
||||
},
|
||||
"@nx/angular:component": {
|
||||
"style": "css"
|
||||
}
|
||||
},
|
||||
"defaultProject": "NitroPlusTranslator"
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
"executor": "@nx/jest:jest",
|
||||
"outputs": ["{workspaceRoot}/coverage/{projectName}"],
|
||||
"options": {
|
||||
"jestConfig": "jest.config.ts"
|
||||
"jestConfig": "jest.config.app.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<div class="btns">
|
||||
<app-upload-btn (fileLoaded)="onFileLoaded($event)"></app-upload-btn>
|
||||
<app-clear-btn (clear)="onClearClicked()"></app-clear-btn>
|
||||
<nwui-button (click)="fileInput.click()">
|
||||
<span><i class="lni lni-upload"></i> Upload</span>
|
||||
<input type="file" (change)="submitFile($event)" #fileInput style="display: none" />
|
||||
</nwui-button>
|
||||
<nwui-button (click)="onClearClicked()">
|
||||
<span><i class="lni lni-trash-can"></i> Clear</span>
|
||||
</nwui-button>
|
||||
</div>
|
||||
<app-text-list [elements]="elements"></app-text-list>
|
||||
<router-outlet></router-outlet>
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { ClearBtnComponent } from './components/clear_btn/clear_btn.component';
|
||||
import { ButtonComponent } from '@nwaifu-ui';
|
||||
import { TextListComponent } from './components/text_list/text_list.component';
|
||||
import { UploadBtnComponent } from './components/upload_btn/upload_btn.component';
|
||||
import { TranslateData } from './dto/translate_data.dto';
|
||||
import { parse } from './lib/parser';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [UploadBtnComponent, RouterModule, TextListComponent, ClearBtnComponent],
|
||||
imports: [RouterModule, TextListComponent, ButtonComponent],
|
||||
selector: 'app-root',
|
||||
templateUrl: './app.component.html',
|
||||
styleUrl: './app.component.scss',
|
||||
@@ -16,11 +14,36 @@ import { parse } from './lib/parser';
|
||||
export class AppComponent implements OnInit {
|
||||
title = 'NitroPlusTranslator';
|
||||
elements: TranslateData[] = [];
|
||||
@ViewChild('fileInput') fileInput: HTMLInputElement | null = null;
|
||||
|
||||
ngOnInit(): void {
|
||||
const data = localStorage.getItem('translations');
|
||||
if (data) {
|
||||
try {
|
||||
this.elements = JSON.parse(data);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert('Error while loading');
|
||||
localStorage.removeItem('translations');
|
||||
this.elements = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
submitFile($event: Event) {
|
||||
const target = $event.target as HTMLInputElement;
|
||||
if (target.files) {
|
||||
const file = target.files?.[0];
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
if (reader.result) {
|
||||
this.onFileLoaded(reader.result.toString());
|
||||
target.value = '';
|
||||
}
|
||||
};
|
||||
reader.readAsText(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,5 +54,6 @@ export class AppComponent implements OnInit {
|
||||
|
||||
onClearClicked() {
|
||||
this.elements = [];
|
||||
localStorage.removeItem('translations');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<button (click)="clear_func()">
|
||||
<span><i class="lni lni-trash-can"></i> Clear</span>
|
||||
</button>
|
||||
@@ -1,14 +0,0 @@
|
||||
button {
|
||||
outline: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
background-color: #5b3f45;
|
||||
padding: 1em 1.5em;
|
||||
color: #f5f6fa;
|
||||
border-radius: 15px;
|
||||
transition: ease-in-out 0.2s;
|
||||
margin: 2rem;
|
||||
&:hover {
|
||||
transform: scale(1.2);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component, EventEmitter, Output } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-clear-btn',
|
||||
templateUrl: './clear_btn.component.html',
|
||||
styleUrls: ['./clear_btn.component.scss'],
|
||||
standalone: true,
|
||||
imports: [CommonModule],
|
||||
})
|
||||
export class ClearBtnComponent {
|
||||
@Output() clear = new EventEmitter();
|
||||
clear_func() {
|
||||
localStorage.setItem('translations', '[]');
|
||||
this.clear.emit();
|
||||
}
|
||||
}
|
||||
@@ -2,20 +2,5 @@
|
||||
<div id="elements">
|
||||
@for(item of elements_data; track $index) {
|
||||
<app-translate-block [index]="$index" [item]="item"></app-translate-block>
|
||||
<!-- <div class="element">
|
||||
<h2>{{ $index + 1 }}</h2>
|
||||
<div class="fields">
|
||||
<div class="english-text">{{ item.english_text }}</div>
|
||||
<div class="translated-text">
|
||||
<textarea
|
||||
type="text"
|
||||
[value]="item.translated_text"
|
||||
(change)="typeTranslation($event, $index)"
|
||||
rows="1"
|
||||
></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<button class="send-translate-btn" (click)="sendToTranslate(item.english_text, $index)">Translate</button>
|
||||
</div> -->
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { TranslateData } from 'src/app/dto/translate_data.dto';
|
||||
import { TranslateData } from '../../dto/translate_data.dto';
|
||||
import { TranslateBlockComponent } from '../translate_block/translate_block.component';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<div class="translated-text" #translatedText [attr.contenteditable]="isEditing" (blur)="saveTranslate()"></div>
|
||||
</div>
|
||||
<div class="btns">
|
||||
<button class="send-translate-btn btn" (click)="sendToTranslate()">Translate</button>
|
||||
<button class="change-edit-btn btn" (click)="isEditing = !isEditing" [disabled]="isEditing">Edit</button>
|
||||
<button class="clear-btn btn" (click)="clear()" [disabled]="!item.translated_text.length">Clear</button>
|
||||
<nwui-button (click)="sendToTranslate()">Translate</nwui-button>
|
||||
<button (click)="isEditing = !isEditing" [disabled]="isEditing">Edit</button>
|
||||
<button (click)="clear()" [disabled]="!item.translated_text.length">Clear</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
|
||||
import { TranslateData } from 'src/app/dto/translate_data.dto';
|
||||
import { TranslatePipe } from 'src/app/pipes/translate.pipe';
|
||||
import { ButtonComponent } from '@nwaifu-ui';
|
||||
import { TranslateData } from '../../dto/translate_data.dto';
|
||||
import { TranslatePipe } from '../../pipes/translate.pipe';
|
||||
|
||||
@Component({
|
||||
selector: 'app-translate-block',
|
||||
templateUrl: './translate_block.component.html',
|
||||
styleUrls: ['./translate_block.component.scss'],
|
||||
standalone: true,
|
||||
imports: [CommonModule],
|
||||
imports: [CommonModule, ButtonComponent],
|
||||
providers: [TranslatePipe],
|
||||
})
|
||||
export class TranslateBlockComponent implements OnInit, AfterViewInit {
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<button (click)="fileInput.click()">
|
||||
<span><i class="lni lni-upload"></i> Upload</span>
|
||||
<input type="file" (change)="onChange($event)" #fileInput style="display: none" />
|
||||
</button>
|
||||
@@ -1,34 +0,0 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component, ElementRef, EventEmitter, Output, ViewChild } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
imports: [CommonModule],
|
||||
selector: 'app-upload-btn',
|
||||
styleUrl: './upload_btn.component.scss',
|
||||
templateUrl: './upload_btn.component.html',
|
||||
standalone: true,
|
||||
})
|
||||
export class UploadBtnComponent {
|
||||
@ViewChild('fileInput') fileInput: ElementRef<HTMLDivElement> | null = null;
|
||||
@Output() fileLoaded = new EventEmitter<string>();
|
||||
|
||||
onChange(event: Event) {
|
||||
if (event.target) {
|
||||
const target = event.target as HTMLInputElement;
|
||||
if (target.files) {
|
||||
const file: File = target.files[0];
|
||||
if (!file.name.endsWith('.nps')) {
|
||||
alert('Only .nps files are allowed');
|
||||
target.value = '';
|
||||
return;
|
||||
}
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
this.fileLoaded.emit(reader.result as string);
|
||||
target.value = '';
|
||||
};
|
||||
reader.readAsText(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
30
tsconfig.base.json
Normal file
30
tsconfig.base.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"rootDir": ".",
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"importHelpers": true,
|
||||
"target": "es2022",
|
||||
"module": "esnext",
|
||||
"lib": [
|
||||
"es2020",
|
||||
"dom"
|
||||
],
|
||||
"skipLibCheck": true,
|
||||
"skipDefaultLibCheck": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@nwaifu-ui": [
|
||||
"nwaifu-ui/src/index.ts"
|
||||
]
|
||||
}
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"tmp"
|
||||
]
|
||||
}
|
||||
@@ -1,22 +1,5 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"rootDir": ".",
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"importHelpers": true,
|
||||
"target": "es2022",
|
||||
"module": "esnext",
|
||||
"lib": [
|
||||
"es2020",
|
||||
"dom"
|
||||
],
|
||||
"skipLibCheck": true,
|
||||
"skipDefaultLibCheck": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {},
|
||||
"useDefineForClassFields": false,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
@@ -38,15 +21,11 @@
|
||||
"path": "./tsconfig.spec.json"
|
||||
}
|
||||
],
|
||||
"compileOnSave": false,
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"tmp"
|
||||
],
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true
|
||||
}
|
||||
},
|
||||
"extends": "./tsconfig.base.json"
|
||||
}
|
||||
Reference in New Issue
Block a user