Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…onents into rkaraivanov/soft-validation
  • Loading branch information
rkaraivanov committed Apr 26, 2024
2 parents 7c91f19 + 07f7ef2 commit e36ede2
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 77 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Dropdown `positionStrategy` property. The dropdown now uses the Popover API to render its container in the top layer of the browser viewport,
making the property obsolete.

### Fixed
- Date-time input - Label in Material theme is broken when component is in read-only mode [#1166](https://github.com/IgniteUI/igniteui-webcomponents/issues/1166)

## [4.8.2] - 2024-04-15
### Fixed
- Textarea - resize handle position for non-suffixed textarea [#1094](https://github.com/IgniteUI/igniteui-webcomponents/issues/1094)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -42,8 +42,8 @@ Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
|Snackbar|:white_check_mark:|[Docs](https://www.infragistics.com/products/ignite-ui-web-components/web-components/components/notifications/snackbar)|[2.1.0](https://github.com/IgniteUI/igniteui-webcomponents/releases/tag/2.1.0)|
|Toast|:white_check_mark:|[Docs](https://www.infragistics.com/products/ignite-ui-web-components/web-components/components/notifications/toast)|[2.1.0](https://github.com/IgniteUI/igniteui-webcomponents/releases/tag/2.1.0)|
|Rating|:white_check_mark:|[Docs](https://www.infragistics.com/products/ignite-ui-web-components/web-components/components/inputs/rating)|[2.1.0](https://github.com/IgniteUI/igniteui-webcomponents/releases/tag/2.1.0)|
|Slider|:white_check_mark:|[Docs]()|[2.0.0](https://github.com/IgniteUI/igniteui-webcomponents/releases/tag/2.0.0)|
|Range Slider|:white_check_mark:|[Docs]()|[2.0.0](https://github.com/IgniteUI/igniteui-webcomponents/releases/tag/2.0.0)|
|Slider|:white_check_mark:|[Docs](https://www.infragistics.com/products/ignite-ui-web-components/web-components/components/inputs/slider)|[2.0.0](https://github.com/IgniteUI/igniteui-webcomponents/releases/tag/2.0.0)|
|Range Slider|:white_check_mark:|[Docs](https://www.infragistics.com/products/ignite-ui-web-components/web-components/components/inputs/slider)|[2.0.0](https://github.com/IgniteUI/igniteui-webcomponents/releases/tag/2.0.0)|
|Avatar|:white_check_mark:|[Docs](https://www.infragistics.com/products/ignite-ui-web-components/web-components/components/layouts/avatar)|[1.0.0](https://github.com/IgniteUI/igniteui-webcomponents/releases/tag/1.0.0)|
|Badge|:white_check_mark:|[Docs](https://www.infragistics.com/products/ignite-ui-web-components/web-components/components/inputs/badge)|[1.0.0](https://github.com/IgniteUI/igniteui-webcomponents/releases/tag/1.0.0)|
|Button|:white_check_mark:|[Docs](https://www.infragistics.com/products/ignite-ui-web-components/web-components/components/inputs/button)|[1.0.0](https://github.com/IgniteUI/igniteui-webcomponents/releases/tag/1.0.0)|
Expand Down
80 changes: 40 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -58,8 +58,8 @@
"lit": "^3.1.3"
},
"devDependencies": {
"@biomejs/biome": "1.7.0",
"@custom-elements-manifest/analyzer": "^0.9.4",
"@biomejs/biome": "1.7.1",
"@custom-elements-manifest/analyzer": "^0.9.6",
"@igniteui/material-icons-extended": "^3.0.2",
"@open-wc/testing": "^4.0.0",
"@storybook/addon-a11y": "^8.0.9",
Expand Down
51 changes: 19 additions & 32 deletions src/components/date-time-input/date-time-input.ts
Expand Up @@ -554,8 +554,9 @@ export default class IgcDateTimeInputComponent extends EventEmitterMixin<
'0'
);

this._mask =
newMask.indexOf('tt') !== -1 ? newMask.replace(/tt/g, 'LL') : newMask;
this._mask = newMask.includes('tt')
? newMask.replace(/tt/g, 'LL')
: newMask;

this.parser.mask = this._mask;
this.parser.prompt = this.prompt;
Expand All @@ -566,15 +567,9 @@ export default class IgcDateTimeInputComponent extends EventEmitterMixin<
}

private parseDate(val: string) {
if (!val) {
return null;
}

return DateTimeUtil.parseValueFromMask(
val,
this._inputDateParts,
this.prompt
);
return val
? DateTimeUtil.parseValueFromMask(val, this._inputDateParts, this.prompt)
: null;
}

private getMaskedValue(): string {
Expand Down Expand Up @@ -606,17 +601,13 @@ export default class IgcDateTimeInputComponent extends EventEmitterMixin<
}

private isComplete(): boolean {
return this.maskedValue.indexOf(this.prompt) === -1;
return !this.maskedValue.includes(this.prompt);
}

private updateValue(): void {
if (this.isComplete()) {
const parsedDate = this.parseDate(this.maskedValue);
if (DateTimeUtil.isValidDate(parsedDate)) {
this.value = parsedDate;
} else {
this.value = null;
}
this.value = DateTimeUtil.isValidDate(parsedDate) ? parsedDate : null;
} else {
this.value = null;
}
Expand All @@ -627,29 +618,25 @@ export default class IgcDateTimeInputComponent extends EventEmitterMixin<
}

private getNewPosition(value: string, direction = 0): number {
const literals = this._inputDateParts.filter(
(p) => p.type === DateParts.Literal
);
let cursorPos = this.selection.start;
const cursorPos = this.selection.start;

if (!direction) {
do {
cursorPos = cursorPos > 0 ? --cursorPos : cursorPos;
} while (!literals.some((l) => l.end === cursorPos) && cursorPos > 0);
return cursorPos;
// Last literal before the current cursor position or start of input value
const part = this._inputDateParts.findLast(
(part) => part.type === DateParts.Literal && part.end < cursorPos
);
return part?.end ?? 0;
}
do {
cursorPos++;
} while (
!literals.some((l) => l.start === cursorPos) &&
cursorPos < value.length

// First literal after the current cursor position or end of input value
const part = this._inputDateParts.find(
(part) => part.type === DateParts.Literal && part.start > cursorPos
);
return cursorPos;
return part?.start ?? value.length;
}

protected override async handleFocus() {
this.focused = true;
this.updateMask();
super.handleFocus();

if (this.readOnly) {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"target": "es2021",
"module": "es2020",
"lib": ["es2022", "DOM", "DOM.Iterable"],
"lib": ["es2023", "DOM", "DOM.Iterable"],
"outDir": "dist",
"rootDir": "./",
"declaration": true,
Expand Down

0 comments on commit e36ede2

Please sign in to comment.