Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@
the component. An object including the string value, the error and the
date value will be emitted. An example of this object is:
{{ "{" }} <code>value: value, error: error, date: date</code>{{ "}" }}. If
the string value is a valid date, <code>error</code> will be null. Also,
if the string value is not a valid date, <code>date</code> will be null.
the string value is a valid date, <code>error</code> will be undefined.
Also, if the string value is not a valid date, <code>date</code> will be
undefined.
</td>
</tr>
<tr>
Expand All @@ -108,8 +109,8 @@
{{ "{" }}
<code>value: value, error: error, date: date</code>
{{ "}" }}. If the string value is a valid date, <code>error</code> will be
null. Also, if the string value is not a valid date,
<code>date</code> will be null.
undefined. Also, if the string value is not a valid date,
<code>date</code> will be undefined.
</td>
</tr>
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
is lower than min, the onBlur and onChange functions will be called with
the current value and an internal error informing that the current value
is not correct. If a valid state is reached, the error parameter will be
null in both events.
undefined in both events.
</td>
</tr>
<tr>
Expand All @@ -80,7 +80,7 @@
Maximum value allowed by the number input. If the typed value by the user
surpasses max, the onBlur and onChange functions will be called with the
current value and an internal error informing that the current value is
not correct. If a valid state is reached, the error parameter will be null
not correct. If a valid state is reached, the error parameter will be undefined
in both events.
</td>
</tr>
Expand Down Expand Up @@ -110,7 +110,7 @@
value entered is not valid) will be passed to this function. An example of
this object is: {{ "{ " }}
<code>value: value, error: error</code>
{{ "}" }}. If there is no error, error will be null.
{{ "}" }}. If there is no error, error will be undefined.
</td>
</tr>
<tr>
Expand All @@ -121,7 +121,7 @@
including the value and the error (if the value entered is not valid) will
be passed to this function. An example of this object is: {{ "{" }}
<code>value: value, error: error</code>
{{ "}" }}. If there is no error, error will be null.
{{ "}" }}. If there is no error, error will be undefined.
</td>
</tr>
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
value entered is not valid) will be passed to this function. An example of
this object is:
{{ "{" }} <code>value: value, error: error</code>{{ "}" }}. If there is no
error, error will be null.
error, error will be undefined.
</td>
</tr>
<tr>
Expand All @@ -71,7 +71,7 @@
valid) will be passed to this function. An example of this object is:
{{ "{" }}
<code>value: value, error: error</code>
{{ "}" }}. If there is no error, error will be null.
{{ "}" }}. If there is no error, error will be undefined.
</td>
</tr>
<tr>
Expand All @@ -93,7 +93,7 @@
pattern, the onBlur and onChange functions will be called with the current
value and an internal error informing that this value does not match the
pattern. If the pattern is met, the error parameter of both events will be
null.
undefined.
</td>
</tr>
<tr>
Expand All @@ -106,7 +106,7 @@
onChange functions will be called with the current value and an internal
error informing that the value length does not comply the specified range.
If a valid length is reached, the error parameter of both events will be
null.
undefined.
</td>
</tr>
<tr>
Expand All @@ -119,7 +119,7 @@
onChange functions will be called with the current value and an internal
error informing that the value length does not comply the specified range.
If a valid length is reached, the error parameter of both events will be
null.
undefined.
</td>
</tr>
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@
<td>error: string</td>
<td></td>
<td>
If it is defined, the component will change its appearance, showing the
error below the input component. If it is not defined, the error messages
will be created and managed internally.
If it is a defined value and also a truthy string, the component will
change its appearance, showing the error below the input component. If the
defined value is an empty string, it will reserve a space below the
component for a future error, but it would not change its look. In case of
being undefined or undefined, both the appearance and the space for the error
message would not be modified.
</td>
</tr>
<tr>
Expand All @@ -81,20 +84,22 @@
<td>onChange: EventEmitter</td>
<td></td>
<td>
This function will be called when the user types within the input. The new
value will be passed as a parameter.
This event will emit when the user types within the input element
of the component. An object including the current value and the error (if
the value entered is not valid) will be passed to this function. An
example of this object is: {{ "{" }} value: value, error: error {{ "}" }}. If there is no
error, error will not be defined.
</td>
</tr>
<tr>
<td>onBlur: EventEmitter</td>
<td></td>
<td>
This function will be called when the input loses the focus. An object
This event will emit when the input element loses the focus. An object
including the input value and the error (if the value entered is not
valid) will be passed to this function. An example of this object is:
{{ "{" }}
<code>value: value, error: error</code>
{{ "}" }}. If there is no error, error will be null.
valid) will be passed to this function. An example of this object is: {{ "{" }}
value: value, error: error {{ "}" }}. If there is no error, error will not be
defined.
</td>
</tr>
<tr>
Expand All @@ -121,7 +126,7 @@
does not match the pattern, the onBlur function will be called with the
value entered and the error informing that the value does not match the
pattern as parameters. If the pattern is accomplished, the error parameter
will be null.
will be undefined.
</td>
</tr>
<tr>
Expand Down Expand Up @@ -149,7 +154,7 @@
onChange functions will be called with the current value and an internal
error informing that the value length does not comply the specified range.
If a valid length is reached, the error parameter of both events will be
null.
undefined.
</td>
</tr>
<tr>
Expand All @@ -162,7 +167,7 @@
onChange functions will be called with the current value and an internal
error informing that the value length does not comply the specified range.
If a valid length is reached, the error parameter of both events will be
null.
undefined.
</td>
</tr>
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe("DxcDate", () => {
fireEvent.input(input, { target: { value: newValue } });
expect(onChange).toHaveBeenCalledWith({
value: newValue,
error: null,
error: undefined,
date: newMockDate,
});
expect(screen.getByDisplayValue(newValue));
Expand Down Expand Up @@ -180,7 +180,7 @@ describe("DxcDate", () => {
fireEvent.input(input, { target: { value: newValue } });
expect(onChange).toHaveBeenCalledWith({
value: newValue,
error: null,
error: undefined,
date: newMockDate,
});
expect(screen.getByDisplayValue(newValue));
Expand All @@ -189,7 +189,7 @@ describe("DxcDate", () => {
fireEvent.input(input, { target: { value: "04-10-1996" } });
expect(onChange).toHaveBeenCalledWith({
value: "04-10-1996",
error: null,
error: undefined,
date: new Date("1996/10/04"),
});
expect(screen.getByDisplayValue("04-10-1996"));
Expand Down Expand Up @@ -237,7 +237,7 @@ describe("DxcDate", () => {
fireEvent.input(input, { target: { value: "1995/12/03" } });
expect(onChange).toHaveBeenCalledWith({
value: "1995/12/03",
error: null,
error: undefined,
date: newMockDate,
});
input.focus();
Expand Down Expand Up @@ -290,8 +290,8 @@ describe("DxcDate", () => {

expect(onChange).toHaveBeenCalledWith({
value: invalidValue,
error: null,
date: null,
error: undefined,
date: undefined,
});
});

Expand Down Expand Up @@ -481,14 +481,14 @@ describe("DxcDate", () => {
fireEvent.input(input, { target: { value: "03-10-1996" } });
expect(onChange).toHaveBeenCalledWith({
value: "03-10-1996",
error: null,
error: undefined,
date: new Date("1996/10/03"),
});
expect(screen.getByDisplayValue("03-12-1995"));
fireEvent.blur(input);
waitFor(() => {
expect(onBlur).toHaveBeenCalledWith({
error: null,
error: undefined,
value: "03-12-1995",
date: new Date("1995/12/03"),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ export class DxcDateInputComponent implements OnInit {

/**
* This event will emit in case the user types within the input element of the component. An object including the string value,
* the error and the date value will be emitted. If the string value is a valid date, error will be null.
* Also, if the string value is not a valid date, date will be null.
* the error and the date value will be emitted. If the string value is a valid date, error will be undefined.
* Also, if the string value is not a valid date, date will be undefined.
*/
@Output() onChange = new EventEmitter<EmittedValue>();
/**
* This event will emit in case the input element loses the focus. An object including the string value,
* the error and the date value will be emitted. If the string value is a valid date, error will be null.
* Also, if the string value is not a valid date, date will be null.
* the error and the date value will be emitted. If the string value is a valid date, error will be undefined.
* Also, if the string value is not a valid date, date will be undefined.
*/
@Output() onBlur = new EventEmitter<EmittedValue>();
/**
Expand Down Expand Up @@ -283,7 +283,7 @@ export class DxcDateInputComponent implements OnInit {
let _dateReturn = {
value: value.value,
error: value.error,
date: _dateValue.isValid() ? _dateValue.toDate() : null,
date: _dateValue.isValid() ? _dateValue.toDate() : undefined,
};
this.onChange.emit(_dateReturn);

Expand All @@ -302,7 +302,7 @@ export class DxcDateInputComponent implements OnInit {
this.onBlur.emit({
value: event.value,
error: event.error,
date: _dateValue.isValid() ? _dateValue.toDate() : null,
date: _dateValue.isValid() ? _dateValue.toDate() : undefined,
});
if (!this.controlled) {
this.renderedValue = event.value;
Expand All @@ -315,7 +315,7 @@ export class DxcDateInputComponent implements OnInit {
let _stringValue = this.getDateStringValue(value, this.format);
let _dateReturn = {
value: _stringValue,
date: value.isValid() ? value.toDate() : null,
date: value.isValid() ? value.toDate() : undefined,
error: this.dxcInputRef.error,
};
this.onChange.emit(_dateReturn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe("DxcNumberInputComponent", () => {
input.focus();
expect(input).toHaveFocus();
fireEvent.click(screen.getByLabelText("Increment"));
expect(onChange).toHaveBeenCalledWith({ value: "10", error: null });
expect(onChange).toHaveBeenCalledWith({ value: "10", error: undefined });
});

test("decrease should call onChange in dxc-number", async () => {
Expand All @@ -105,7 +105,7 @@ describe("DxcNumberInputComponent", () => {
input.focus();
expect(input).toHaveFocus();
fireEvent.click(screen.getByLabelText("Decrement"));
expect(onChange).toHaveBeenCalledWith({ value: "5", error: null });
expect(onChange).toHaveBeenCalledWith({ value: "5", error: undefined });
});

test("controlled dxc-number", async () => {
Expand Down Expand Up @@ -135,7 +135,7 @@ describe("DxcNumberInputComponent", () => {
expect(input.max).toBe("100");
expect(screen.getByDisplayValue("4")).toBeTruthy();
fireEvent.input(input, { target: { value: "10" } });
expect(onChange).toHaveBeenCalledWith({ value: "10", error: null });
expect(onChange).toHaveBeenCalledWith({ value: "10", error: undefined });
expect(screen.getByDisplayValue("4")).toBeTruthy();
});

Expand Down Expand Up @@ -170,7 +170,7 @@ describe("DxcNumberInputComponent", () => {
expect(input.max).toBe("100");
expect(screen.getByDisplayValue("4"));
fireEvent.input(input, { target: { value: "10" } });
expect(onChange).toHaveBeenCalledWith({ value: "10", error: null });
expect(onChange).toHaveBeenCalledWith({ value: "10", error: undefined });
expect(screen.getByDisplayValue("4"));
fireEvent.blur(input);
waitFor(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class DxcNumberInputComponent implements OnInit, OnChanges, OnDestroy {
* lower than min, the onBlur and onChange functions will be called with
* the current value and an internal error informing that the current
* value is not correct. If a valid state is reached, the error parameter
* will be null in both events.
* will be undefined in both events.
*/
@Input()
get min(): number {
Expand All @@ -90,7 +90,7 @@ export class DxcNumberInputComponent implements OnInit, OnChanges, OnDestroy {
* surpasses max, the onBlur and onChange functions will be called with
* the current value and an internal error informing that the current
* value is not correct. If a valid state is reached, the error parameter
* will be null in both events.
* will be undefined in both events.
*/
@Input()
get max(): number {
Expand Down Expand Up @@ -174,14 +174,14 @@ export class DxcNumberInputComponent implements OnInit, OnChanges, OnDestroy {
* This event will emit in case the user types within the input
* element of the component. An object including the current value and
* the error (if the value entered is not valid) will be passed to this
* function. If there is no error, error will be null.
* function. If there is no error, error will be undefined.
*/
@Output() onChange = new EventEmitter<OnChangeEvent>();
/**
* This event will emit in case the number loses the focus.
* An object including the input value and the error (if the value
* entered is not valid) will be passed to this function. If there is no error,
* error will be null.
* error will be undefined.
*/
@Output() onBlur = new EventEmitter<OnBlurEvent>();
@ViewChild("dxcInputRef", { static: false })
Expand Down Expand Up @@ -305,7 +305,7 @@ export class DxcNumberInputComponent implements OnInit, OnChanges, OnDestroy {
currentValue = coerceNumberProperty(this.value);
}
let calculatedValue = this.calculateMinus(currentValue);
this.handleOnChange({ value: calculatedValue.toString(), error: null });
this.handleOnChange({ value: calculatedValue.toString(), error: undefined });
this.dxcInputRef.inputRef.nativeElement.focus();
}

Expand All @@ -318,7 +318,7 @@ export class DxcNumberInputComponent implements OnInit, OnChanges, OnDestroy {
currentValue = coerceNumberProperty(this.value);
}
let calculatedValue = this.calculatePlus(currentValue);
this.handleOnChange({ value: calculatedValue.toString(), error: null });
this.handleOnChange({ value: calculatedValue.toString(), error: undefined });
this.dxcInputRef.inputRef.nativeElement.focus();
}

Expand Down
Loading