Skip to content

Commit 634d056

Browse files
marker-daomarker dao ®
andauthored
Editor: unify value and reset(value) types (T1304359) (#31023)
Co-authored-by: marker dao ® <[email protected]>
1 parent c761649 commit 634d056

29 files changed

+154
-75
lines changed

packages/devextreme-angular/src/ui/autocomplete/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,10 +746,10 @@ export class DxAutocompleteComponent extends DxComponent implements OnDestroy, C
746746
747747
*/
748748
@Input()
749-
get value(): string {
749+
get value(): null | string {
750750
return this._getOption('value');
751751
}
752-
set value(value: string) {
752+
set value(value: null | string) {
753753
this._setOption('value', value);
754754
}
755755

@@ -1311,7 +1311,7 @@ export class DxAutocompleteComponent extends DxComponent implements OnDestroy, C
13111311
* This member supports the internal infrastructure and is not intended to be used directly from your code.
13121312
13131313
*/
1314-
@Output() valueChange: EventEmitter<string>;
1314+
@Output() valueChange: EventEmitter<null | string>;
13151315

13161316
/**
13171317

packages/devextreme-angular/src/ui/color-box/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -634,10 +634,10 @@ export class DxColorBoxComponent extends DxComponent implements OnDestroy, Contr
634634
635635
*/
636636
@Input()
637-
get value(): string {
637+
get value(): null | string {
638638
return this._getOption('value');
639639
}
640-
set value(value: string) {
640+
set value(value: null | string) {
641641
this._setOption('value', value);
642642
}
643643

@@ -1080,7 +1080,7 @@ export class DxColorBoxComponent extends DxComponent implements OnDestroy, Contr
10801080
* This member supports the internal infrastructure and is not intended to be used directly from your code.
10811081
10821082
*/
1083-
@Output() valueChange: EventEmitter<string>;
1083+
@Output() valueChange: EventEmitter<null | string>;
10841084

10851085
/**
10861086

packages/devextreme-react/src/autocomplete.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ type IAutocompleteOptions = React.PropsWithChildren<ReplaceFieldTypes<Properties
5555
itemRender?: (...params: any) => React.ReactNode;
5656
itemComponent?: React.ComponentType<any>;
5757
defaultOpened?: boolean;
58-
defaultValue?: string;
58+
defaultValue?: null | string;
5959
onOpenedChange?: (value: boolean) => void;
60-
onValueChange?: (value: string) => void;
60+
onValueChange?: (value: null | string) => void;
6161
}>
6262

6363
interface AutocompleteRef {

packages/devextreme-react/src/color-box.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ type IColorBoxOptions = React.PropsWithChildren<ReplaceFieldTypes<Properties, IC
5151
fieldRender?: (...params: any) => React.ReactNode;
5252
fieldComponent?: React.ComponentType<any>;
5353
defaultOpened?: boolean;
54-
defaultValue?: string;
54+
defaultValue?: null | string;
5555
onOpenedChange?: (value: boolean) => void;
56-
onValueChange?: (value: string) => void;
56+
onValueChange?: (value: null | string) => void;
5757
}>
5858

5959
interface ColorBoxRef {

packages/devextreme-vue/src/autocomplete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ const componentConfig = {
243243
validationMessageMode: String as PropType<ValidationMessageMode>,
244244
validationMessagePosition: String as PropType<Mode | Position>,
245245
validationStatus: String as PropType<ValidationStatus>,
246-
value: String,
246+
value: String as PropType<null | string>,
247247
valueChangeEvent: String,
248248
valueExpr: [Function, String] as PropType<(((item: any) => string | number | boolean)) | string>,
249249
visible: Boolean,

packages/devextreme-vue/src/color-box.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ const componentConfig = {
205205
validationMessageMode: String as PropType<ValidationMessageMode>,
206206
validationMessagePosition: String as PropType<Mode | Position>,
207207
validationStatus: String as PropType<ValidationStatus>,
208-
value: String,
208+
value: String as PropType<null | string>,
209209
visible: Boolean,
210210
width: [Number, String]
211211
},

packages/devextreme/js/__internal/ui/color_box/m_color_box.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class ColorBox extends DropDownEditor<ColorBoxProperties> {
224224
const color = new Color(newValue);
225225

226226
if (color.colorIsInvalid) {
227-
this._input().val(oldValue);
227+
this._input().val(oldValue === null ? undefined : oldValue);
228228
return;
229229
}
230230
// @ts-expect-error ts-error

packages/devextreme/js/__internal/ui/color_box/m_color_view.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const BLACK_COLOR = '#000000';
6767
export interface ColorViewProperties extends EditorProperties {
6868
keyStep?: number;
6969

70-
matchValue?: string;
70+
matchValue?: string | null;
7171

7272
editAlphaChannel?: boolean;
7373

@@ -299,7 +299,6 @@ class ColorView extends Editor<ColorViewProperties> {
299299
return {
300300
...super._getDefaultOptions(),
301301
value: null,
302-
// @ts-expect-error ts-error
303302
matchValue: null,
304303
onEnterKeyPressed: undefined,
305304
editAlphaChannel: false,

packages/devextreme/js/ui/autocomplete.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ export interface dxAutocompleteOptions extends dxDropDownListOptions<dxAutocompl
210210
* @default null
211211
* @public
212212
*/
213-
value?: string;
214-
213+
value?: string | null;
215214
/**
216215
* @docid
217216
* @type dxPopupOptions
@@ -230,8 +229,9 @@ export default class dxAutocomplete extends dxDropDownList<dxAutocompleteOptions
230229
* @docid
231230
* @publicName reset(value)
232231
* @public
232+
* @param1 value:string | null
233233
*/
234-
reset(value?: string | null): void;
234+
reset(value?: Properties['value']): void;
235235
}
236236

237237
/** @public */

packages/devextreme/js/ui/calendar.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ export default class dxCalendar extends Editor<dxCalendarOptions> {
230230
* @docid
231231
* @publicName reset(value)
232232
* @public
233-
* @param1 value:Date|number|string|Array<Date|number|string|null>|null
233+
* @param1 value:Date | number | string | Array<Date | number | string | null> | null
234234
*/
235-
reset(value?: DateLike | Array<Date | number | string | null>): void;
235+
reset(value?: Properties['value']): void;
236236
}
237237

238238
/** @public */

0 commit comments

Comments
 (0)