Skip to content

Commit

Permalink
fix(*): update type error
Browse files Browse the repository at this point in the history
  • Loading branch information
ng-nest-moon committed Jun 2, 2021
1 parent 8a3da4c commit e1f2d08
Show file tree
Hide file tree
Showing 90 changed files with 374 additions and 360 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: use node.js
uses: actions/setup-node@v1
with:
node-version: 13.12.0
node-version: 14.15.4

- name: build
run: |
Expand Down
4 changes: 2 additions & 2 deletions lib/ng-nest/ui/affix/affix.property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export class XAffixProperty extends XProperty {
* @zh_CN 距离顶部距离
* @en_US Distance from top
*/
@Input() @XWithConfig<string>(X_CONFIG_NAME) top!: string;
@Input() @XWithConfig<string>(X_CONFIG_NAME) top?: string;
/**
* @zh_CN 距离左边距离
* @en_US Distance from left
*/
@Input() @XWithConfig<string>(X_CONFIG_NAME) left!: string;
@Input() @XWithConfig<string>(X_CONFIG_NAME) left?: string;
}
22 changes: 11 additions & 11 deletions lib/ng-nest/ui/alert/alert.property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,57 +18,57 @@ export class XAlertProperty extends XProperty {
* @zh_CN 隐藏
* @en_US Hide
*/
@Input() @XInputBoolean() hide!: XBoolean;
@Input() @XInputBoolean() hide?: XBoolean;
/**
* @zh_CN 标题
* @en_US Title
*/
@Input() title!: XTemplate;
@Input() title?: XTemplate;
/**
* @zh_CN 内容
* @en_US Content
*/
@Input() content!: XTemplate;
@Input() content?: XTemplate;
/**
* @zh_CN 类型
* @en_US Alert type
*/
@Input() type: XAlertType = 'info';
@Input() type?: XAlertType = 'info';
/**
* @zh_CN 主题
* @en_US Theme
*/
@Input() @XWithConfig<XEffect>(X_CONFIG_NAME, 'light') effect!: XEffect;
@Input() @XWithConfig<XEffect>(X_CONFIG_NAME, 'light') effect?: XEffect;
/**
* @zh_CN 隐藏关闭按钮
* @en_US Hide close button
*/
@Input() @XWithConfig<XBoolean>(X_CONFIG_NAME) @XInputBoolean() hideClose!: XBoolean;
@Input() @XWithConfig<XBoolean>(X_CONFIG_NAME) @XInputBoolean() hideClose?: XBoolean;
/**
* @zh_CN 使用文本关闭按钮
* @en_US Use the text to close button
*/
@Input() closeText!: string;
@Input() closeText?: string;
/**
* @zh_CN 显示图标
* @en_US Show icon
*/
@Input() @XWithConfig<XBoolean>(X_CONFIG_NAME) @XInputBoolean() showIcon!: XBoolean;
@Input() @XWithConfig<XBoolean>(X_CONFIG_NAME) @XInputBoolean() showIcon?: XBoolean;
/**
* @zh_CN 禁用动画
* @en_US Disable animation
*/
@Input() @XWithConfig<XBoolean>(X_CONFIG_NAME) @XInputBoolean() disabledAnimation!: XBoolean;
@Input() @XWithConfig<XBoolean>(X_CONFIG_NAME) @XInputBoolean() disabledAnimation?: XBoolean;
/**
* @zh_CN 延迟关闭,默认 0 表示不关闭
* @en_US Delay close, the default value of 0 means do not close
*/
@Input() @XWithConfig<XNumber>(X_CONFIG_NAME, 0) @XInputNumber() duration!: XNumber;
@Input() @XWithConfig<XNumber>(X_CONFIG_NAME, 0) @XInputNumber() duration?: XNumber;
/**
* @zh_CN 手动处理关闭事件
* @en_US Manually handle close events
*/
@Input() @XInputBoolean() manual!: XBoolean;
@Input() @XInputBoolean() manual?: XBoolean;
/**
* @zh_CN 关闭的事件
* @en_US Closed events
Expand Down
8 changes: 4 additions & 4 deletions lib/ng-nest/ui/anchor/anchor.property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ export class XAnchorProperty extends XProperty {
* @zh_CN 滚动区域对象
* @en_US Scroll area object
*/
@Input() scroll!: HTMLElement;
@Input() scroll?: HTMLElement;
/**
* @zh_CN 顶部距离
* @en_US Top distance
*/
@Input() @XWithConfig<string>(X_CONFIG_NAME, '0') affixTop!: string;
@Input() @XWithConfig<string>(X_CONFIG_NAME, '0') affixTop?: string;
/**
* @zh_CN 导航相对内容位置
* @en_US Navigation relative content position
*/
@Input() @XWithConfig<XAnchorLayout>(X_CONFIG_NAME, 'right') layout!: XAnchorLayout;
@Input() @XWithConfig<XAnchorLayout>(X_CONFIG_NAME, 'right') layout?: XAnchorLayout;
/**
* @zh_CN 对齐方式
* @en_US Alignment
*/
@Input() @XWithConfig<XJustify>(X_CONFIG_NAME, 'start') justify!: XJustify;
@Input() @XWithConfig<XJustify>(X_CONFIG_NAME, 'start') justify?: XJustify;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/ng-nest/ui/auto-complete/auto-complete.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class XAutoCompleteComponent extends XAutoCompleteProperty implements OnI
this.closeSubject.pipe(takeUntil(this._unSubject)).subscribe((x) => {
this.closePortal();
});
this.inputChange.pipe(debounceTime(this.debounceTime), takeUntil(this._unSubject)).subscribe(() => {
this.inputChange.pipe(debounceTime(this.debounceTime as number), takeUntil(this._unSubject)).subscribe(() => {
this.modelChange();
});
this.keydownSubject.pipe(takeUntil(this._unSubject)).subscribe((x) => {
Expand Down Expand Up @@ -241,7 +241,7 @@ export class XAutoCompleteComponent extends XAutoCompleteProperty implements OnI
setPlacement() {
return this.portalService.setPlacement({
elementRef: this.inputCom.inputElement,
placement: [this.placement, 'bottom-start', 'bottom-end', 'top-start', 'top-end'],
placement: [this.placement as XPositionTopBottom, 'bottom-start', 'bottom-end', 'top-start', 'top-end'],
transformOriginOn: 'x-auto-complete-portal'
});
}
Expand Down
6 changes: 3 additions & 3 deletions lib/ng-nest/ui/auto-complete/auto-complete.property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ export class XAutoCompleteProperty extends XControlValueAccessor<any> {
* @zh_CN 输入延迟执行时间,ms
* @en_US Enter a delay execution time, ms
*/
@Input() @XWithConfig<number>(X_CONFIG_NAME, 200) debounceTime!: number;
@Input() @XWithConfig<number>(X_CONFIG_NAME, 200) debounceTime?: number;
/**
* @zh_CN 展示方位
* @en_US Display position
*/
@Input() @XWithConfig<XPositionTopBottom>(X_CONFIG_NAME, 'bottom') placement!: XPositionTopBottom;
@Input() @XWithConfig<XPositionTopBottom>(X_CONFIG_NAME, 'bottom') placement?: XPositionTopBottom;
/**
* @zh_CN 节点模板
* @en_US Node template
*/
@Input() nodeTpl!: TemplateRef<any>;
@Input() nodeTpl?: TemplateRef<any>;
/**
* @zh_CN 选择节点事件
* @en_US Node click event
Expand Down
12 changes: 6 additions & 6 deletions lib/ng-nest/ui/avatar/avatar.property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,32 @@ export class XAvatarProperty extends XProperty {
* @zh_CN 显示字符
* @en_US Display characters
*/
@Input() label!: XTemplate;
@Input() label?: XTemplate;
/**
* @zh_CN 尺寸
* @en_US Size
*/
@Input() @XWithConfig<XSize>(X_CONFIG_NAME, 'medium') size!: XSize;
@Input() @XWithConfig<XSize>(X_CONFIG_NAME, 'medium') size?: XSize;
/**
* @zh_CN 显示图标
* @en_US Show icon
*/
@Input() icon!: string;
@Input() icon?: string;
/**
* @zh_CN 形状
* @en_US Shape
*/
@Input() @XWithConfig<XAvatarShape>(X_CONFIG_NAME, 'circle') shape!: XAvatarShape;
@Input() @XWithConfig<XAvatarShape>(X_CONFIG_NAME, 'circle') shape?: XAvatarShape;
/**
* @zh_CN 图片地址
* @en_US The map's address
*/
@Input() src!: string;
@Input() src?: string;
/**
* @zh_CN 图片适应方式
* @en_US Image adaptation method
*/
@Input() @XWithConfig<XAvatarFit>(X_CONFIG_NAME, 'cover') fit!: XAvatarFit;
@Input() @XWithConfig<XAvatarFit>(X_CONFIG_NAME, 'cover') fit?: XAvatarFit;
}

/**
Expand Down
9 changes: 7 additions & 2 deletions lib/ng-nest/ui/back-top/back-top.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,20 @@ export class XBackTopComponent extends XBackTopProperty implements OnInit, OnCha

private setScrolling() {
const scrollTop = this.scrollTop;
const visible = scrollTop >= this.visibilityHeight;
const visible = scrollTop >= (this.visibilityHeight as number);
if (this.visiable !== visible) {
this.visiable = visible;
if (this.visiable) {
this.portalRef = this.portal.attach({
content: this.backTopTpl,
viewContainerRef: this.viewContainerRef,
overlayConfig: {
positionStrategy: this.portal.setPlace('bottom-end', '2.5rem', '2.5rem', ...['0', this.right, this.bottom, '0'])
positionStrategy: this.portal.setPlace(
'bottom-end',
'2.5rem',
'2.5rem',
...['0', this.right as string, this.bottom as string, '0']
)
}
});
} else {
Expand Down
8 changes: 4 additions & 4 deletions lib/ng-nest/ui/back-top/back-top.property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ export class XBackTopProperty extends XProperty {
* @zh_CN 距离右边的距离
* @en_US Distance to the right
*/
@Input() @XWithConfig<string>(X_CONFIG_NAME, '2.5rem') right!: string;
@Input() @XWithConfig<string>(X_CONFIG_NAME, '2.5rem') right?: string;
/**
* @zh_CN 距离底部的距离
* @en_US Distance from bottom
*/
@Input() @XWithConfig<string>(X_CONFIG_NAME, '2.5rem') bottom!: string;
@Input() @XWithConfig<string>(X_CONFIG_NAME, '2.5rem') bottom?: string;
/**
* @zh_CN 滚动多少高度后显示
* @en_US Display after scrolling how much height
*/
@Input() @XWithConfig<XNumber>(X_CONFIG_NAME, 200) visibilityHeight!: XNumber;
@Input() @XWithConfig<XNumber>(X_CONFIG_NAME, 200) visibilityHeight?: XNumber;
/**
* @zh_CN 内容模板
* @en_US Content template
Expand All @@ -38,5 +38,5 @@ export class XBackTopProperty extends XProperty {
* @zh_CN 滚动的元素
* @en_US Scroll element
*/
@Input() target!: string | HTMLElement;
@Input() target?: string | HTMLElement;
}
6 changes: 3 additions & 3 deletions lib/ng-nest/ui/badge/badge.property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export class XBadgeProperty extends XProperty {
* @zh_CN 背景颜色
* @en_US Background color
*/
@Input() @XWithConfig<XBadgeType>(X_CONFIG_NAME, 'danger') type!: XBadgeType;
@Input() @XWithConfig<XBadgeType>(X_CONFIG_NAME, 'danger') type?: XBadgeType;
/**
* @zh_CN 最大值
* @en_US Max
*/
@Input() @XInputNumber() max!: XNumber;
@Input() @XInputNumber() max?: XNumber;
/**
* @zh_CN 显示值
* @en_US Display value
Expand All @@ -33,7 +33,7 @@ export class XBadgeProperty extends XProperty {
* @zh_CN 是否显示小红点
* @en_US Whether to show the small red dot
*/
@Input() @XInputBoolean() dot!: XBoolean;
@Input() @XInputBoolean() dot?: XBoolean;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/ng-nest/ui/base-form/base-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class XControlValueAccessor<T> extends XFormProp implements ControlValueA
index++;
}
} else {
result = !new RegExp(this.pattern).test(this.value as any);
result = !new RegExp(this.pattern as RegExp).test(this.value as any);
}
return result;
}
Expand All @@ -32,7 +32,7 @@ export class XControlValueAccessor<T> extends XFormProp implements ControlValueA
if (Array.isArray(this.message)) {
return this.message.length > this.invalidIndex ? this.message[this.invalidIndex] : '';
} else {
return this.message;
return this.message as string;
}
}
invalidIndex: number = 0;
Expand All @@ -52,7 +52,7 @@ export class XControlValueAccessor<T> extends XFormProp implements ControlValueA
setDisabledState(disabled: boolean) {
this.disabled = disabled;
}
setFlex(ele: Element, renderer: Renderer2, justify: XJustify, align: XAlign, direction: XDirection) {
setFlex(ele: Element, renderer: Renderer2, justify?: XJustify, align?: XAlign, direction?: XDirection) {
if (!XIsEmpty(justify)) renderer.addClass(ele, `x-justify-${this.justify}`);
if (!XIsEmpty(align)) renderer.addClass(ele, `x-align-${this.align}`);
if (!XIsEmpty(direction)) renderer.addClass(ele, `x-direction-${this.direction}`);
Expand Down
20 changes: 10 additions & 10 deletions lib/ng-nest/ui/base-form/base-form.property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@ export class XFormProp extends XProperty {
/**
* 标签
*/
@Input() label: string = '';
@Input() label?: string = '';
/**
* 标签宽度
*/
@Input() labelWidth: string = '';
@Input() labelWidth?: string = '';
/**
* 标签文字对齐方式
*/
@Input() labelAlign: XAlign = 'start';
@Input() labelAlign?: XAlign = 'start';
/**
* flex 布局下的子元素水平排列方式
*/
@Input() justify: XJustify = 'start';
@Input() justify?: XJustify = 'start';
/**
* flex 布局下的子元素垂直排列方式
*/
@Input() align: XAlign = 'start';
@Input() align?: XAlign = 'start';
/**
* flex 布局下的子元素排列方向
*/
@Input() direction: XDirection = 'column';
@Input() direction?: XDirection = 'column';
/**
* 尺寸
*/
@Input() size: XSize = 'medium';
@Input() size?: XSize = 'medium';
/**
* 输入提示信息
*/
@Input() placeholder: string = '';
@Input() placeholder?: string = '';
/**
* 禁用
*/
Expand All @@ -49,11 +49,11 @@ export class XFormProp extends XProperty {
/**
* 正则验证规则
*/
@Input() pattern!: RegExp | RegExp[];
@Input() pattern?: RegExp | RegExp[];
/**
* 验证不通过提示文字
*/
@Input() message!: string | string[];
@Input() message?: string | string[];
}

export interface XFormOption {
Expand Down

0 comments on commit e1f2d08

Please sign in to comment.