Skip to content

Commit

Permalink
chore: cleanup deps, fix build typings error (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin authored Jul 31, 2023
1 parent b574518 commit c5ba896
Show file tree
Hide file tree
Showing 26 changed files with 1,802 additions and 20,372 deletions.
5 changes: 5 additions & 0 deletions .changeset/nice-houses-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alauda/ui": minor
---

feat: simplify coerceAttrBoolean getter/setter
5 changes: 5 additions & 0 deletions .changeset/spicy-deers-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alauda/ui": minor
---

feat: use `numberAttribute` from `@angular/core`
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ dist
node_modules
release
reports
/documentation.json
/ng-package.debug.json
/report.*.json
2 changes: 1 addition & 1 deletion .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('@1stg/lint-staged');
module.exports = require('@1stg/lint-staged/tsc');
17,553 changes: 0 additions & 17,553 deletions documentation.json

This file was deleted.

89 changes: 36 additions & 53 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,69 +54,52 @@
"@1stg/lint-staged": "^3.4.1",
"@1stg/simple-git-hooks": "^0.2.3",
"@1stg/stylelint-config": "^5.1.0",
"@angular-devkit/build-angular": "^16.1.3",
"@angular-devkit/core": "^16.1.3",
"@angular-eslint/builder": "^16.0.3",
"@angular-eslint/eslint-plugin": "^16.0.3",
"@angular-eslint/eslint-plugin-template": "^16.0.3",
"@angular-eslint/schematics": "^16.0.3",
"@angular-eslint/template-parser": "^16.0.3",
"@angular/animations": "^16.1.3",
"@angular/cdk": "^16.1.3",
"@angular/cli": "^16.1.3",
"@angular/common": "^16.1.3",
"@angular/compiler": "^16.1.3",
"@angular/compiler-cli": "^16.1.3",
"@angular/core": "^16.1.3",
"@angular/forms": "^16.1.3",
"@angular/platform-browser": "^16.1.3",
"@angular/platform-browser-dynamic": "^16.1.3",
"@babel/eslint-parser": "^7.18.9",
"@babel/eslint-plugin": "^7.17.7",
"@changesets/changelog-github": "^0.4.4",
"@changesets/cli": "^2.22.0",
"@compodoc/compodoc": "^1.1.19",
"@storybook/addon-essentials": "^7.0.18",
"@storybook/addon-interactions": "^7.0.18",
"@storybook/addon-links": "^7.0.18",
"@storybook/angular": "^7.0.18",
"@storybook/blocks": "^7.0.18",
"@types/chroma-js": "^2.1.3",
"@angular-devkit/build-angular": "^16.1.6",
"@angular/animations": "^16.1.7",
"@angular/cdk": "^16.1.6",
"@angular/cli": "^16.1.6",
"@angular/common": "^16.1.7",
"@angular/compiler": "^16.1.7",
"@angular/compiler-cli": "^16.1.7",
"@angular/core": "^16.1.7",
"@angular/forms": "^16.1.7",
"@angular/platform-browser": "^16.1.7",
"@angular/platform-browser-dynamic": "^16.1.7",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"@compodoc/compodoc": "^1.1.21",
"@storybook/addon-essentials": "^7.1.1",
"@storybook/addon-interactions": "^7.1.1",
"@storybook/addon-links": "^7.1.1",
"@storybook/angular": "^7.1.1",
"@storybook/blocks": "^7.1.1",
"@types/chroma-js": "^2.4.0",
"@types/file-saver": "^2.0.5",
"@types/jest": "29.4.4",
"@types/node": "^17.0.33",
"@types/resize-observer-browser": "^0.1.5",
"@typescript-eslint/eslint-plugin": "^5.30.7",
"@typescript-eslint/parser": "^5.30.7",
"angular-eslint-template-parser": "^0.1.1",
"babel-plugin-dynamic-import-node": "^2.3.3",
"chroma-js": "^2.1.2",
"commitlint": "^17.6.6",
"css-loader": "^6.7.1",
"dayjs": "^1.11.2",
"@types/jest": "29.5.3",
"@types/node": "^20.4.5",
"chroma-js": "^2.4.2",
"commitlint": "^17.6.7",
"dayjs": "^1.11.9",
"file-saver": "^2.0.5",
"gulp": "^4.0.2",
"gulp-dart-sass": "^1.0.2",
"jest": "29.4.3",
"gulp-dart-sass": "^1.1.0",
"jest": "^29.6.2",
"jest-junit": "^16.0.0",
"jest-preset-angular": "13.1.1",
"jest-preset-angular": "^13.1.1",
"lint-staged": "^13.2.3",
"ng-packagr": "^16.1.0",
"patch-package": "^6.4.7",
"postcss": "^8.4.6",
"patch-package": "^8.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"remark-gfm": "^3.0.1",
"rxjs": "7.8.0",
"sass-loader": "^12.6.0",
"storybook": "^7.0.9",
"storybook-dark-mode": "^3.0.0",
"style-loader": "^3.3.1",
"ts-jest": "29.0.5",
"rxjs": "^7.8.1",
"simple-git-hooks": "^2.9.0",
"storybook": "^7.1.1",
"storybook-dark-mode": "^3.0.1",
"ts-jest": "29.1.1",
"ts-node": "^10.9.1",
"typescript": "^4.9.5",
"webpack": "^5.72.1",
"zone.js": "0.12.0"
"yarn-deduplicate": "^6.0.2",
"zone.js": "^0.13.1"
},
"resolutions": {
"prettier": "~2.7.1"
Expand Down
4 changes: 2 additions & 2 deletions src/anchor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
| 参数 | 说明 | 类型 | 默认值 |
| ------------- | ---------------------------------------------------------------------------------------------------------- | ----------------------- | ----------- |
| auiAnchor | 滚动容器, 不传值默认取 `cdkScrollable` 或当前元素(如果可滚动)或 `window` | `HTMLElement` | `undefined` |
| adaptPosition | 是否自动调整当前元素 `paddingRight` 以保证与自动生成的锚点内容重叠 | `boolean` | `true` |
| adaptPosition | 是否自动调整当前元素 `paddingRight` 以保证与自动生成的锚点内容不重叠 | `boolean` | `true` |
| padding | 自动调整 `paddingRight` 时自动保持与自动生成的锚点内容的距离 | `number` | `20` |
| minTop | 当滚动页面时自动生成的锚点内容距离页面顶部最小距离,默认取当前 `.aui-page__content` 元素的 `paddingTop`| `number` | `20` |
| injectId | 是否自动在 `auiAnchorLabel` 元素上注入 id,将自动生成 `#` 可记录锚点 | `window === window.top` |
Expand All @@ -20,4 +20,4 @@
| --------------------- | ------------------------------------------------------------- | ----------------------- | ----------- |
| auiAnchorLabel | 自动生成锚点时对应文本内容,默认取当前元素文本内容 | `string \| TemplateRef` | `undefined` |
| auiAnchorLabelContext | 使用 `TemplateRef` 类型 `auiAnchorLabel` 时的上下文 | `unknown` | `undefined` |
| level | 锚点层级,不写这个 `input` 默认是 `0`,写了不填内容默认是 `1` | `string \| TemplateRef` | `0` |
| level | 锚点层级,不写这个 `input` 默认是 `0`,写了不填内容默认是 `1` | `number` | `0` |
16 changes: 8 additions & 8 deletions src/anchor/anchor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class AnchorComponent
scrollableEl === window
? document.documentElement
: (scrollableEl as HTMLElement);
const activedItem =
const activeItem =
this.items.find(
({ target }) =>
target.offsetTop +
Expand All @@ -188,21 +188,21 @@ export class AnchorComponent
0) >
scrollTop + paddingTop,
) || last(this.items);
return activedItem ? of(activedItem) : EMPTY;
return activeItem ? of(activeItem) : EMPTY;
}),
tap(activedItem => {
if (activedItem.id) {
this.activeId = activedItem.id;
tap(activeItem => {
if (activeItem.id) {
this.activeId = activeItem.id;
this.cdr.markForCheck();
}
}),
debounceTime(100),
tap(activedItem => {
if (injectId && activedItem.id) {
tap(activeItem => {
if (injectId && activeItem.id) {
history.replaceState(
null,
null,
location.pathname + location.search + '#' + activedItem.id,
location.pathname + location.search + '#' + activeItem.id,
);
}
}),
Expand Down
18 changes: 3 additions & 15 deletions src/autocomplete/suggestion/suggestion.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import {
ChangeDetectorRef,
Component,
ElementRef,
Inject,
Input,
ViewChild,
ViewEncapsulation,
forwardRef,
} from '@angular/core';
import {
BehaviorSubject,
Expand All @@ -33,7 +31,6 @@ import { AutocompleteComponent } from '../autocomplete.component';
export class SuggestionComponent {
bem: Bem = buildBem('aui-suggestion');

private _disabled = false;
private _value: string;
private readonly value$$ = new BehaviorSubject<string>(this.value);

Expand All @@ -47,14 +44,8 @@ export class SuggestionComponent {
this.value$$.next(val);
}

@Input()
get disabled() {
return this._disabled;
}

set disabled(val: boolean | '') {
this._disabled = coerceAttrBoolean(val);
}
@Input({ transform: coerceAttrBoolean })
disabled: boolean;

@ViewChild('elRef', { static: true })
elRef: ElementRef;
Expand All @@ -63,16 +54,13 @@ export class SuggestionComponent {
visible = true;
focused = false;

private readonly autocomplete: AutocompleteComponent;
selected$: Observable<boolean>;
visible$: Observable<boolean>;

constructor(
private readonly cdr: ChangeDetectorRef,
@Inject(forwardRef(() => AutocompleteComponent))
autocomplete: any, // FIXME: workaround temporarily
private readonly autocomplete: AutocompleteComponent,
) {
this.autocomplete = autocomplete;
this.selected$ = combineLatest([
this.autocomplete.directive$$.pipe(
switchMap(directive => directive.inputValue$),
Expand Down
12 changes: 2 additions & 10 deletions src/dropdown/dropdown-button/dropdown-button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,8 @@ export class DropdownButtonComponent implements AfterContentInit {
@Input()
loading = false;

@Input()
get disabled() {
return this._disabled;
}

set disabled(val: boolean | '') {
this._disabled = coerceAttrBoolean(val);
}
@Input({ transform: coerceAttrBoolean })
disabled: boolean;

@Output()
buttonClick = new EventEmitter<Event>();
Expand All @@ -59,8 +53,6 @@ export class DropdownButtonComponent implements AfterContentInit {
@ContentChildren(MenuItemComponent, { descendants: true })
private readonly menuItems: QueryList<MenuItemComponent>;

private _disabled = false;

disableTrigger$: Observable<boolean>;

ngAfterContentInit() {
Expand Down
16 changes: 2 additions & 14 deletions src/form/common-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,8 @@ import { coerceAttrBoolean } from '../utils';
*/
@Directive()
export class CommonFormControl<V, M = V> implements ControlValueAccessor {
@Input()
get disabled() {
return this._disabled;
}

set disabled(val: boolean | '') {
this._disabled = coerceAttrBoolean(val);
}
@Input({ transform: coerceAttrBoolean })
disabled: boolean;

@Input()
get readonly() {
Expand Down Expand Up @@ -53,7 +47,6 @@ export class CommonFormControl<V, M = V> implements ControlValueAccessor {
protected onChange: (_: V) => void;
protected onTouched: () => void;
private _propValue: V;
private _disabled = false;

model: M = null;
model$ = new ReplaySubject<M>(1);
Expand Down Expand Up @@ -102,8 +95,3 @@ export class CommonFormControl<V, M = V> implements ControlValueAccessor {
return model as any;
}
}

/**
* @deprecated use {@link CommonFormControl} instead
*/
export const CommonForm = CommonFormControl;
12 changes: 2 additions & 10 deletions src/form/helper-directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@ export class FormItemErrorDirective {}
},
})
export class FormItemControlDirective {
@Input()
get required() {
return this._required;
}

set required(val: boolean | '') {
this._required = coerceAttrBoolean(val);
}

private _required = false;
@Input({ transform: coerceAttrBoolean })
required: boolean;
}
7 changes: 2 additions & 5 deletions src/input/input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class InputComponent {
}

@Input()
get disabled() {
get disabled(): boolean {
return this._disabled;
}

Expand All @@ -64,10 +64,7 @@ export class InputComponent {

size$ = new BehaviorSubject<ComponentSize>(this.size);

/**
* workaround for @link https://github.com/microsoft/TypeScript/pull/42425
*/
disabled$ = new BehaviorSubject<boolean>(this.disabled as boolean);
disabled$ = new BehaviorSubject(this.disabled);

constructor(
public elementRef: ElementRef<HTMLInputElement>,
Expand Down
27 changes: 14 additions & 13 deletions src/input/number-input/number-input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import {
forwardRef,
ContentChildren,
QueryList,
numberAttribute,
} from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { Observable } from 'rxjs';

import { CommonFormControl } from '../../form';
import { ComponentSize } from '../../types';
import { Bem, buildBem, coerceNumber, watchContentExist } from '../../utils';
import { Bem, buildBem, watchContentExist } from '../../utils';
import {
InputAddonAfterDirective,
InputAddonBeforeDirective,
Expand Down Expand Up @@ -46,11 +47,17 @@ export class NumberInputComponent
@Input()
size: ComponentSize = ComponentSize.Medium;

@Input()
min: string | number = Number.MIN_SAFE_INTEGER;
@Input({
transform: (val: number | string) =>
numberAttribute(val, Number.MIN_SAFE_INTEGER),
})
min: number;

@Input()
max: string | number = Number.MAX_SAFE_INTEGER;
@Input({
transform: (val: number | string) =>
numberAttribute(val, Number.MAX_SAFE_INTEGER),
})
max: number;

@Input()
step = 1;
Expand Down Expand Up @@ -106,18 +113,12 @@ export class NumberInputComponent
override modelOut(value: number) {
return value === null && this.clearable
? value
: Math.max(
coerceNumber(this.min, Number.MIN_SAFE_INTEGER),
Math.min(
coerceNumber(this.max, Number.MAX_SAFE_INTEGER),
this.parsePrecision(value),
),
);
: Math.max(this.min, Math.min(this.max, this.parsePrecision(value)));
}

inputChanged(value: string) {
this.emitModel(
coerceNumber(value, !value && this.clearable ? null : this.model),
numberAttribute(value, !value && this.clearable ? null : this.model),
);
}

Expand Down
Loading

0 comments on commit c5ba896

Please sign in to comment.