diff --git a/packages/form/spec/base.spec.ts b/packages/form/spec/base.spec.ts index 17e3b67dd..406775145 100644 --- a/packages/form/spec/base.spec.ts +++ b/packages/form/spec/base.spec.ts @@ -75,10 +75,16 @@ export function builder(options?: { }; } -export function configureSFTestSuite(): void { +export function configureSFTestSuite(options?: { imports?: NzSafeAny[] }): void { beforeEach(() => { TestBed.configureTestingModule({ - imports: [NoopAnimationsModule, AlainThemeModule.forRoot(), DelonFormModule.forRoot(), HttpClientTestingModule], + imports: [ + NoopAnimationsModule, + AlainThemeModule.forRoot(), + DelonFormModule.forRoot(), + HttpClientTestingModule, + ...(options?.imports ?? []) + ], declarations: [TestFormComponent] }); }); diff --git a/packages/form/src/module.ts b/packages/form/src/module.ts index 8e1e6ecd6..e64509fba 100644 --- a/packages/form/src/module.ts +++ b/packages/form/src/module.ts @@ -17,9 +17,7 @@ import { NzModalModule } from 'ng-zorro-antd/modal'; import { NzRadioModule } from 'ng-zorro-antd/radio'; import { NzSelectModule } from 'ng-zorro-antd/select'; import { NzSwitchModule } from 'ng-zorro-antd/switch'; -import { NzTimePickerModule } from 'ng-zorro-antd/time-picker'; import { NzToolTipModule } from 'ng-zorro-antd/tooltip'; -import { NzUploadModule } from 'ng-zorro-antd/upload'; import { DelonLocaleModule } from '@delon/theme'; import { AlainConfigService } from '@delon/util/config'; @@ -39,9 +37,7 @@ const ZORROS = [ NzRadioModule, NzSelectModule, NzSwitchModule, - NzTimePickerModule, - NzToolTipModule, - NzUploadModule + NzToolTipModule ]; import { SFFixedDirective } from './sf-fixed.directive'; @@ -70,8 +66,6 @@ import { SelectWidget } from './widgets/select/select.widget'; import { StringWidget } from './widgets/string/string.widget'; import { TextWidget } from './widgets/text/text.widget'; import { TextareaWidget } from './widgets/textarea/textarea.widget'; -import { TimeWidget } from './widgets/time/time.widget'; -import { UploadWidget } from './widgets/upload/upload.widget'; const WIDGETS = [ ObjectWidget, @@ -79,13 +73,11 @@ const WIDGETS = [ StringWidget, NumberWidget, DateWidget, - TimeWidget, RadioWidget, CheckboxWidget, BooleanWidget, TextareaWidget, SelectWidget, - UploadWidget, AutoCompleteWidget, CustomWidget, TextWidget diff --git a/packages/form/src/widgets/index.ts b/packages/form/src/widgets/index.ts index 3eaf8ac1b..e9804ef1e 100644 --- a/packages/form/src/widgets/index.ts +++ b/packages/form/src/widgets/index.ts @@ -8,8 +8,6 @@ export * from './number/number.widget'; export * from './number/schema'; export * from './date/date.widget'; export * from './date/schema'; -export * from './time/time.widget'; -export * from './time/schema'; export * from './radio/radio.widget'; export * from './radio/schema'; export * from './checkbox/checkbox.widget'; @@ -19,8 +17,6 @@ export * from './textarea/textarea.widget'; export * from './textarea/schema'; export * from './select/select.widget'; export * from './select/schema'; -export * from './upload/upload.widget'; -export * from './upload/schema'; export * from './autocomplete/autocomplete.widget'; export * from './autocomplete/schema'; export * from './text/text.widget'; diff --git a/packages/form/src/widgets/nz-widget.registry.ts b/packages/form/src/widgets/nz-widget.registry.ts index 8196f71d4..464c9ace2 100644 --- a/packages/form/src/widgets/nz-widget.registry.ts +++ b/packages/form/src/widgets/nz-widget.registry.ts @@ -11,8 +11,6 @@ import { SelectWidget } from './select/select.widget'; import { StringWidget } from './string/string.widget'; import { TextWidget } from './text/text.widget'; import { TextareaWidget } from './textarea/textarea.widget'; -import { TimeWidget } from './time/time.widget'; -import { UploadWidget } from './upload/upload.widget'; import { WidgetRegistry } from '../widget.factory'; export class NzWidgetRegistry extends WidgetRegistry { @@ -27,13 +25,11 @@ export class NzWidgetRegistry extends WidgetRegistry { this.register('number', NumberWidget); this.register('integer', NumberWidget); this.register('date', DateWidget); - this.register('time', TimeWidget); this.register('radio', RadioWidget); this.register('checkbox', CheckboxWidget); this.register('boolean', BooleanWidget); this.register('textarea', TextareaWidget); this.register('select', SelectWidget); - this.register('upload', UploadWidget); this.register('autocomplete', AutoCompleteWidget); this.register('custom', CustomWidget); diff --git a/packages/form/src/widgets/time/time.widget.html b/packages/form/src/widgets/time/time.widget.html deleted file mode 100644 index 0509498b4..000000000 --- a/packages/form/src/widgets/time/time.widget.html +++ /dev/null @@ -1,26 +0,0 @@ - - - diff --git a/packages/form/src/widgets/upload/upload.widget.html b/packages/form/src/widgets/upload/upload.widget.html deleted file mode 100644 index 7c2fb28e2..000000000 --- a/packages/form/src/widgets/upload/upload.widget.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - -
-
- -

-

-

-
- - - -
-
-
diff --git a/packages/form/widgets/cascader/widget.spec.ts b/packages/form/widgets/cascader/widget.spec.ts index a5b9be2a2..509c5af74 100644 --- a/packages/form/widgets/cascader/widget.spec.ts +++ b/packages/form/widgets/cascader/widget.spec.ts @@ -3,6 +3,7 @@ import { ComponentFixture, fakeAsync } from '@angular/core/testing'; import { createTestContext } from '@delon/testing'; +import { CascaderWidgetModule } from './index'; import { CascaderWidget } from './widget'; import { configureSFTestSuite, SFPage, TestFormComponent } from '../../spec/base.spec'; @@ -13,7 +14,7 @@ describe('form: widget: cascader', () => { let page: SFPage; const widget = 'cascader'; - configureSFTestSuite(); + configureSFTestSuite({ imports: [CascaderWidgetModule] }); beforeEach(() => { ({ fixture, dl, context } = createTestContext(TestFormComponent)); diff --git a/packages/form/widgets/mention/widget.spec.ts b/packages/form/widgets/mention/widget.spec.ts index 8209d764c..bf32d585c 100644 --- a/packages/form/widgets/mention/widget.spec.ts +++ b/packages/form/widgets/mention/widget.spec.ts @@ -6,6 +6,7 @@ import type { SFSchema } from '@delon/form'; import { createTestContext } from '@delon/testing'; import { NzSafeAny } from 'ng-zorro-antd/core/types'; +import { MentionWidgetModule } from './index'; import { MentionWidget } from './widget'; import { configureSFTestSuite, SFPage, TestFormComponent } from '../../spec/base.spec'; @@ -18,7 +19,7 @@ describe('form: widget: mention', () => { let page: SFPage; const widget = 'mention'; - configureSFTestSuite(); + configureSFTestSuite({ imports: [MentionWidgetModule] }); beforeEach(() => { ({ fixture, dl, context } = createTestContext(TestFormComponent)); diff --git a/packages/form/widgets/rate/widget.spec.ts b/packages/form/widgets/rate/widget.spec.ts index 30ae9bca1..d992fefa0 100644 --- a/packages/form/widgets/rate/widget.spec.ts +++ b/packages/form/widgets/rate/widget.spec.ts @@ -3,6 +3,7 @@ import { ComponentFixture, fakeAsync } from '@angular/core/testing'; import { createTestContext } from '@delon/testing'; +import { RateWidgetModule } from './index'; import { configureSFTestSuite, SFPage, TestFormComponent } from '../../spec/base.spec'; describe('form: widget: rate', () => { @@ -12,7 +13,7 @@ describe('form: widget: rate', () => { let page: SFPage; const widget = 'rate'; - configureSFTestSuite(); + configureSFTestSuite({ imports: [RateWidgetModule] }); beforeEach(() => { ({ fixture, dl, context } = createTestContext(TestFormComponent)); diff --git a/packages/form/widgets/slider/widget.spec.ts b/packages/form/widgets/slider/widget.spec.ts index 2f715ff50..bef716812 100644 --- a/packages/form/widgets/slider/widget.spec.ts +++ b/packages/form/widgets/slider/widget.spec.ts @@ -6,6 +6,7 @@ import { createTestContext } from '@delon/testing'; import { NzSafeAny } from 'ng-zorro-antd/core/types'; import { NzSliderComponent } from 'ng-zorro-antd/slider'; +import { SliderWidgetModule } from './index'; import { SliderWidget } from './widget'; import { configureSFTestSuite, SFPage, TestFormComponent } from '../../spec/base.spec'; @@ -16,7 +17,7 @@ describe('form: widget: slider', () => { let page: SFPage; const widget = 'slider'; - configureSFTestSuite(); + configureSFTestSuite({ imports: [SliderWidgetModule] }); beforeEach(() => { ({ fixture, dl, context } = createTestContext(TestFormComponent)); diff --git a/packages/form/widgets/tag/widget.spec.ts b/packages/form/widgets/tag/widget.spec.ts index 867079e03..6d87d9fe1 100644 --- a/packages/form/widgets/tag/widget.spec.ts +++ b/packages/form/widgets/tag/widget.spec.ts @@ -6,6 +6,7 @@ import { createTestContext } from '@delon/testing'; import { NzSafeAny } from 'ng-zorro-antd/core/types'; import { NzTagComponent } from 'ng-zorro-antd/tag'; +import { TagWidgetModule } from './index'; import { configureSFTestSuite, SFPage, TestFormComponent } from '../../spec/base.spec'; describe('form: widget: tag', () => { @@ -14,7 +15,7 @@ describe('form: widget: tag', () => { let context: TestFormComponent; let page: SFPage; - configureSFTestSuite(); + configureSFTestSuite({ imports: [TagWidgetModule] }); beforeEach(() => { ({ fixture, dl, context } = createTestContext(TestFormComponent)); diff --git a/packages/form/src/widgets/time/demo/simple.md b/packages/form/widgets/time/demo/simple.md similarity index 90% rename from packages/form/src/widgets/time/demo/simple.md rename to packages/form/widgets/time/demo/simple.md index e0d0e59f4..cc0fcd7ce 100644 --- a/packages/form/src/widgets/time/demo/simple.md +++ b/packages/form/widgets/time/demo/simple.md @@ -15,12 +15,13 @@ Simplest of usage. ```ts import { Component } from '@angular/core'; -import { SFSchema, SFTimeWidgetSchema } from '@delon/form'; +import { SFSchema } from '@delon/form'; +import type { SFTimeWidgetSchema } from '@delon/form/widgets/time'; import { NzMessageService } from 'ng-zorro-antd/message'; @Component({ selector: 'app-demo', - template: ` `, + template: ` `, }) export class DemoComponent { schema: SFSchema = { diff --git a/packages/form/src/widgets/time/index.en-US.md b/packages/form/widgets/time/index.en-US.md similarity index 92% rename from packages/form/src/widgets/time/index.en-US.md rename to packages/form/widgets/time/index.en-US.md index 5254e2112..0f0d03a47 100644 --- a/packages/form/src/widgets/time/index.en-US.md +++ b/packages/form/widgets/time/index.en-US.md @@ -1,11 +1,15 @@ --- title: time subtitle: Time -type: Widgets +type: Non-built-in widgets --- To select/input a time. +## Import module + +Non-built-in modules, Should be import `TimeWidgetModule` in [json-schema.module.ts](https://github.com/ng-alain/ng-alain/blob/master/src/app/shared/json-schema/json-schema.module.ts#L11). + ## Notice - Format is divided into two types: **Data format** means form data, **Display format** means display data ([nzFormat](https://ng.ant.design/components/time-picker/en#api)) diff --git a/packages/form/widgets/time/index.ts b/packages/form/widgets/time/index.ts new file mode 100644 index 000000000..c3ce18dec --- /dev/null +++ b/packages/form/widgets/time/index.ts @@ -0,0 +1,20 @@ +import { NgModule } from '@angular/core'; +import { FormsModule } from '@angular/forms'; + +import { DelonFormModule, WidgetRegistry } from '@delon/form'; +import { NzTimePickerModule } from 'ng-zorro-antd/time-picker'; + +import { TimeWidget } from './widget'; + +export * from './widget'; +export * from './schema'; + +@NgModule({ + imports: [FormsModule, DelonFormModule, NzTimePickerModule], + declarations: [TimeWidget] +}) +export class TimeWidgetModule { + constructor(widgetRegistry: WidgetRegistry) { + widgetRegistry.register(TimeWidget.KEY, TimeWidget); + } +} diff --git a/packages/form/src/widgets/time/index.zh-CN.md b/packages/form/widgets/time/index.zh-CN.md similarity index 92% rename from packages/form/src/widgets/time/index.zh-CN.md rename to packages/form/widgets/time/index.zh-CN.md index 993dd7c68..fb7bca0c7 100644 --- a/packages/form/src/widgets/time/index.zh-CN.md +++ b/packages/form/widgets/time/index.zh-CN.md @@ -1,11 +1,15 @@ --- title: time subtitle: 时间 -type: Widgets +type: Non-built-in widgets --- 输入或选择时间的控件。 +## 导入模块 + +非内置模块,需要额外在 [json-schema.module.ts](https://github.com/ng-alain/ng-alain/blob/master/src/app/shared/json-schema/json-schema.module.ts#L11) 导入 `TimeWidgetModule`。 + ## 注意事项 - 格式化分为:**数据格式化**表示表单数据和**显示格式化**显示数据(等同 [nzFormat](https://ng.ant.design/components/time-picker/zh#api) 值) diff --git a/packages/form/src/widgets/time/schema.ts b/packages/form/widgets/time/schema.ts similarity index 97% rename from packages/form/src/widgets/time/schema.ts rename to packages/form/widgets/time/schema.ts index 336defd47..f39c8df49 100644 --- a/packages/form/src/widgets/time/schema.ts +++ b/packages/form/widgets/time/schema.ts @@ -1,4 +1,4 @@ -import { SFDLSSize, SFUISchemaItem } from '../../schema/ui'; +import type { SFDLSSize, SFUISchemaItem } from '@delon/form'; export interface SFTimeWidgetSchema extends SFUISchemaItem { size?: SFDLSSize; diff --git a/packages/form/src/widgets/time/time.widget.spec.ts b/packages/form/widgets/time/widget.spec.ts similarity index 95% rename from packages/form/src/widgets/time/time.widget.spec.ts rename to packages/form/widgets/time/widget.spec.ts index 4d07cdd40..5eb051c59 100644 --- a/packages/form/src/widgets/time/time.widget.spec.ts +++ b/packages/form/widgets/time/widget.spec.ts @@ -3,11 +3,12 @@ import { ComponentFixture } from '@angular/core/testing'; import { format } from 'date-fns'; +import type { SFSchema } from '@delon/form'; import { createTestContext } from '@delon/testing'; -import { TimeWidget } from './time.widget'; -import { configureSFTestSuite, SFPage, TestFormComponent } from '../../../spec/base.spec'; -import { SFSchema } from '../../../src/schema/index'; +import { TimeWidgetModule } from './index'; +import { TimeWidget } from './widget'; +import { configureSFTestSuite, SFPage, TestFormComponent } from '../../spec/base.spec'; const FORMAT = 'yyyy-MM-dd HH:mm:ss'; @@ -18,7 +19,7 @@ describe('form: widget: time', () => { let dl: DebugElement; const widget = 'time'; - configureSFTestSuite(); + configureSFTestSuite({ imports: [TimeWidgetModule] }); beforeEach(() => { ({ fixture, dl, context } = createTestContext(TestFormComponent)); diff --git a/packages/form/src/widgets/time/time.widget.ts b/packages/form/widgets/time/widget.ts similarity index 64% rename from packages/form/src/widgets/time/time.widget.ts rename to packages/form/widgets/time/widget.ts index e3cfbd59c..057d05ac1 100644 --- a/packages/form/src/widgets/time/time.widget.ts +++ b/packages/form/widgets/time/widget.ts @@ -2,20 +2,52 @@ import { Component, OnInit, ViewEncapsulation } from '@angular/core'; import { format } from 'date-fns'; +import { ControlUIWidget, SFValue, toBool } from '@delon/form'; import type { NzSafeAny } from 'ng-zorro-antd/core/types'; -import { SFTimeWidgetSchema } from './schema'; -import { SFValue } from '../../interface'; -import { toBool } from '../../utils'; -import { ControlUIWidget } from '../../widget'; +import type { SFTimeWidgetSchema } from './schema'; @Component({ selector: 'sf-time', - templateUrl: './time.widget.html', + template: ` + + `, preserveWhitespaces: false, encapsulation: ViewEncapsulation.None }) export class TimeWidget extends ControlUIWidget implements OnInit { + static readonly KEY = 'time'; + private valueFormat: string | undefined; displayValue: Date | null = null; i: NzSafeAny; diff --git a/packages/form/widgets/transfer/widget.spec.ts b/packages/form/widgets/transfer/widget.spec.ts index b678e8f2b..39cadd668 100644 --- a/packages/form/widgets/transfer/widget.spec.ts +++ b/packages/form/widgets/transfer/widget.spec.ts @@ -6,6 +6,7 @@ import { SFSchema } from '@delon/form'; import { createTestContext } from '@delon/testing'; import { NzSafeAny } from 'ng-zorro-antd/core/types'; +import { TransferWidgetModule } from './index'; import { configureSFTestSuite, SFPage, TestFormComponent } from '../../spec/base.spec'; describe('form: widget: transfer', () => { @@ -21,7 +22,7 @@ describe('form: widget: transfer', () => { rightBtn: '.ant-transfer-operation .ant-btn:last-child' }; - configureSFTestSuite(); + configureSFTestSuite({ imports: [TransferWidgetModule] }); beforeEach(() => { ({ fixture, dl, context } = createTestContext(TestFormComponent)); diff --git a/packages/form/widgets/tree-select/widget.spec.ts b/packages/form/widgets/tree-select/widget.spec.ts index 1c99d29ed..e766f817e 100644 --- a/packages/form/widgets/tree-select/widget.spec.ts +++ b/packages/form/widgets/tree-select/widget.spec.ts @@ -6,6 +6,7 @@ import { SFSchema } from '@delon/form'; import { createTestContext } from '@delon/testing'; import { NzSafeAny } from 'ng-zorro-antd/core/types'; +import { TreeSelectWidgetModule } from './index'; import { configureSFTestSuite, SFPage, TestFormComponent } from '../../spec/base.spec'; describe('form: widget: tree-select', () => { @@ -15,7 +16,7 @@ describe('form: widget: tree-select', () => { let dl: DebugElement; const widget = 'tree-select'; - configureSFTestSuite(); + configureSFTestSuite({ imports: [TreeSelectWidgetModule] }); beforeEach(() => { ({ fixture, dl, context } = createTestContext(TestFormComponent)); diff --git a/packages/form/src/widgets/upload/demo/simple.md b/packages/form/widgets/upload/demo/simple.md similarity index 93% rename from packages/form/src/widgets/upload/demo/simple.md rename to packages/form/widgets/upload/demo/simple.md index e6d733953..072b085b3 100644 --- a/packages/form/src/widgets/upload/demo/simple.md +++ b/packages/form/widgets/upload/demo/simple.md @@ -15,7 +15,8 @@ Simplest of usage. ```ts import { Component } from '@angular/core'; -import { SFSchema, SFUploadWidgetSchema } from '@delon/form'; +import { SFSchema } from '@delon/form'; +import type { SFUploadWidgetSchema } from '@delon/form/widgets/upload'; import { NzMessageService } from 'ng-zorro-antd/message'; @Component({ diff --git a/packages/form/src/widgets/upload/index.en-US.md b/packages/form/widgets/upload/index.en-US.md similarity index 94% rename from packages/form/src/widgets/upload/index.en-US.md rename to packages/form/widgets/upload/index.en-US.md index 330c2916c..a1c3ce0e2 100644 --- a/packages/form/src/widgets/upload/index.en-US.md +++ b/packages/form/widgets/upload/index.en-US.md @@ -1,11 +1,15 @@ --- title: upload subtitle: Upload -type: Widgets +type: Non-built-in widgets --- Upload file widget by select or drag. +## Import module + +Non-built-in modules, Should be import `UploadWidgetModule` in [json-schema.module.ts](https://github.com/ng-alain/ng-alain/blob/master/src/app/shared/json-schema/json-schema.module.ts#L11). + ## Note - **Must** set `resReName` to get correct data diff --git a/packages/form/widgets/upload/index.ts b/packages/form/widgets/upload/index.ts new file mode 100644 index 000000000..45fe75f50 --- /dev/null +++ b/packages/form/widgets/upload/index.ts @@ -0,0 +1,23 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { FormsModule } from '@angular/forms'; + +import { DelonFormModule, WidgetRegistry } from '@delon/form'; +import { NzButtonModule } from 'ng-zorro-antd/button'; +import { NzIconModule } from 'ng-zorro-antd/icon'; +import { NzUploadModule } from 'ng-zorro-antd/upload'; + +import { UploadWidget } from './widget'; + +export * from './widget'; +export * from './schema'; + +@NgModule({ + imports: [FormsModule, CommonModule, DelonFormModule, NzUploadModule, NzIconModule, NzButtonModule], + declarations: [UploadWidget] +}) +export class UploadWidgetModule { + constructor(widgetRegistry: WidgetRegistry) { + widgetRegistry.register(UploadWidget.KEY, UploadWidget); + } +} diff --git a/packages/form/src/widgets/upload/index.zh-CN.md b/packages/form/widgets/upload/index.zh-CN.md similarity index 94% rename from packages/form/src/widgets/upload/index.zh-CN.md rename to packages/form/widgets/upload/index.zh-CN.md index 7d2923649..504ea04e0 100644 --- a/packages/form/src/widgets/upload/index.zh-CN.md +++ b/packages/form/widgets/upload/index.zh-CN.md @@ -1,11 +1,15 @@ --- title: upload subtitle: 上传 -type: Widgets +type: Non-built-in widgets --- 文件选择上传和拖拽上传控件。 +## 导入模块 + +非内置模块,需要额外在 [json-schema.module.ts](https://github.com/ng-alain/ng-alain/blob/master/src/app/shared/json-schema/json-schema.module.ts#L11) 导入 `UploadWidgetModule`。 + ## 注意事项 - **务必** 指定 `resReName` 来获取正确数据 diff --git a/packages/form/src/widgets/upload/schema.ts b/packages/form/widgets/upload/schema.ts similarity index 97% rename from packages/form/src/widgets/upload/schema.ts rename to packages/form/widgets/upload/schema.ts index e3b0420a4..514aa32d2 100644 --- a/packages/form/src/widgets/upload/schema.ts +++ b/packages/form/widgets/upload/schema.ts @@ -1,6 +1,7 @@ import { Observable, Subscription } from 'rxjs'; -import { +import type { SFSchemaEnumType, SFUISchemaItem } from '@delon/form'; +import type { NzShowUploadList, NzUploadChangeParam, NzUploadFile, @@ -9,9 +10,6 @@ import { UploadFilter } from 'ng-zorro-antd/upload'; -import { SFSchemaEnumType } from '../../schema'; -import { SFUISchemaItem } from '../../schema/ui'; - export interface SFUploadWidgetSchema extends SFUISchemaItem { /** * 异步数据源 diff --git a/packages/form/src/widgets/upload/upload.widget.spec.ts b/packages/form/widgets/upload/widget.spec.ts similarity index 97% rename from packages/form/src/widgets/upload/upload.widget.spec.ts rename to packages/form/widgets/upload/widget.spec.ts index 48f7a8746..117340aa2 100644 --- a/packages/form/src/widgets/upload/upload.widget.spec.ts +++ b/packages/form/widgets/upload/widget.spec.ts @@ -7,8 +7,9 @@ import { NzSafeAny } from 'ng-zorro-antd/core/types'; import { NzModalService } from 'ng-zorro-antd/modal'; import { NzUploadComponent } from 'ng-zorro-antd/upload'; -import { UploadWidget } from './upload.widget'; -import { configureSFTestSuite, SFPage, TestFormComponent } from '../../../spec/base.spec'; +import { UploadWidgetModule } from './index'; +import { UploadWidget } from './widget'; +import { configureSFTestSuite, SFPage, TestFormComponent } from '../../spec/base.spec'; describe('form: widget: upload', () => { let fixture: ComponentFixture; @@ -17,7 +18,7 @@ describe('form: widget: upload', () => { let dl: DebugElement; const widget = 'upload'; - configureSFTestSuite(); + configureSFTestSuite({ imports: [UploadWidgetModule] }); beforeEach(() => { ({ fixture, dl, context } = createTestContext(TestFormComponent)); diff --git a/packages/form/src/widgets/upload/upload.widget.ts b/packages/form/widgets/upload/widget.ts similarity index 66% rename from packages/form/src/widgets/upload/upload.widget.ts rename to packages/form/widgets/upload/widget.ts index 49ecf797b..666a6fc1a 100644 --- a/packages/form/src/widgets/upload/upload.widget.ts +++ b/packages/form/widgets/upload/widget.ts @@ -1,23 +1,75 @@ import { Component, OnInit, ViewEncapsulation } from '@angular/core'; import { of } from 'rxjs'; +import { ControlUIWidget, SFValue, getData, toBool } from '@delon/form'; import { deepGet } from '@delon/util/other'; import type { NzSafeAny } from 'ng-zorro-antd/core/types'; import { NzModalService } from 'ng-zorro-antd/modal'; import { NzUploadChangeParam, NzUploadFile } from 'ng-zorro-antd/upload'; -import { SFUploadWidgetSchema } from './schema'; -import { SFValue } from '../../interface'; -import { getData, toBool } from '../../utils'; -import { ControlUIWidget } from '../../widget'; +import type { SFUploadWidgetSchema } from './schema'; @Component({ selector: 'sf-upload', - templateUrl: './upload.widget.html', + template: ` + + + + +
+
+ +

+

+

+
+ + + +
+
+
`, preserveWhitespaces: false, encapsulation: ViewEncapsulation.None }) export class UploadWidget extends ControlUIWidget implements OnInit { + static readonly KEY = 'upload'; + i: NzSafeAny; fileList: NzUploadFile[] = []; btnType = ''; diff --git a/src/app/routes/form-pages/validator/validator.component.ts b/src/app/routes/form-pages/validator/validator.component.ts index ca130d0c6..c50cff221 100644 --- a/src/app/routes/form-pages/validator/validator.component.ts +++ b/src/app/routes/form-pages/validator/validator.component.ts @@ -19,7 +19,7 @@ import { NzMessageService } from 'ng-zorro-antd/message'; @Component({ selector: 'demo', template: \` - diff --git a/src/app/shared/json-schema/json-schema.module.ts b/src/app/shared/json-schema/json-schema.module.ts index ba588e71f..51a383bed 100644 --- a/src/app/shared/json-schema/json-schema.module.ts +++ b/src/app/shared/json-schema/json-schema.module.ts @@ -6,8 +6,10 @@ import { MentionWidgetModule } from '@delon/form/widgets/mention'; import { RateWidgetModule } from '@delon/form/widgets/rate'; import { SliderWidgetModule } from '@delon/form/widgets/slider'; import { TagWidgetModule } from '@delon/form/widgets/tag'; +import { TimeWidgetModule } from '@delon/form/widgets/time'; import { TransferWidgetModule } from '@delon/form/widgets/transfer'; import { TreeSelectWidgetModule } from '@delon/form/widgets/tree-select'; +import { UploadWidgetModule } from '@delon/form/widgets/upload'; import { TinymceWidget } from '@delon/form/widgets-third/tinymce/tinymce.widget'; import { SharedModule } from '../shared.module'; @@ -25,7 +27,9 @@ export const SCHEMA_THIRDS_COMPONENTS = [TinymceWidget]; RateWidgetModule, SliderWidgetModule, TreeSelectWidgetModule, - TagWidgetModule + TagWidgetModule, + TimeWidgetModule, + UploadWidgetModule ], exports: [...SCHEMA_THIRDS_COMPONENTS] })