From 6ecaec9f4786e8d46a5174c814300f585f2f16d4 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Fri, 8 Nov 2024 09:37:31 +0530 Subject: [PATCH 01/36] fix: emitEvent error handling on parsing of icelandic language --- .../src/components/datepicker/datepicker.tsx | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 9e98a9b29..6b3bcbe70 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -999,9 +999,41 @@ export class Datepicker { processValueChange(val, emitChange = false) { // show error if not ISO format and not display format - const parsedDate = parse(val, this.displayFormat, new Date(), { - locale: this.langModule, - }); + let parsedDate; + if (this.langModule?.code === 'is' && this.dateFormat === 'dd MMM yyyy') { + const icelandicLanguageDisplayFormat = 'dd MMMM yyyy'; + const icelandicMonthMapper = { + 'jan.': 'jan.', + 'feb.': 'feb.', + 'mars': 'm', + 'apríl': 'apríl', + 'maí': 'maí', + 'júní': 'júní', + 'júlí': 'júlí', + 'ágúst': 'á', + 'sept.': 's', + 'okt.': 'ó', + 'nóv.': 'n', + 'des.': 'd', + }; + const correctedDate = val.replace( + /jan\.|feb\.|mars|apríl|maí|júní|júlí|ágúst|sept\.|okt\.|nóv\.|des\./g, + (match) => icelandicMonthMapper[match] + ); + + parsedDate = parse( + correctedDate, + icelandicLanguageDisplayFormat, + new Date(), + { + locale: this.langModule, + } + ); + } else { + parsedDate = parse(val, this.displayFormat, new Date(), { + locale: this.langModule, + }); + } const year = getYear( parse(val, this.displayFormat, new Date(), { locale: this.langModule, From e6a6f1911f526ee56461a263c424b08163575992 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Mon, 11 Nov 2024 10:39:43 +0530 Subject: [PATCH 02/36] chore: refactor the code related to datepicker --- .../src/components/datepicker/datepicker.tsx | 79 +++++++------------ 1 file changed, 27 insertions(+), 52 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 6b3bcbe70..e57e97744 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -81,6 +81,31 @@ const getWeekDays = (lang): any => { format(addDays(startOfWeek(new Date()), i), 'EEEEE', { locale: lang }) ); }; + +const parseIcelandicDate = (value, langModule) => { + const icelandicLanguageDisplayFormat = 'dd MMMM yyyy'; + const icelandicMonthMapper = { + 'jan.': 'jan.', + 'feb.': 'feb.', + 'mars': 'm', + 'apríl': 'apríl', + 'maí': 'maí', + 'júní': 'júní', + 'júlí': 'júlí', + 'ágúst': 'á', + 'sept.': 's', + 'okt.': 'ó', + 'nóv.': 'n', + 'des.': 'd', + }; + const correctedDate = value.replace( + /jan\.|feb\.|mars|apríl|maí|júní|júlí|ágúst|sept\.|okt\.|nóv\.|des\./g, + (match) => icelandicMonthMapper[match] + ); + return parse(correctedDate, icelandicLanguageDisplayFormat, new Date(), { + locale: langModule, + }); +}; @Component({ tag: 'fw-datepicker', styleUrl: 'datepicker.scss', shadow: true }) export class Datepicker { @State() showDatePicker: boolean; @@ -338,30 +363,7 @@ export class Datepicker { if (!value) return value; // For Icelandic language, the date format is different. There is a discrepency which is handled in this PR https://github.com/date-fns/date-fns/pull/3934 if (this.langModule?.code === 'is' && this.dateFormat === 'dd MMM yyyy') { - const icelandicLanguageDisplayFormat = 'dd MMMM yyyy'; - const icelandicMonthMapper = { - 'jan.': 'jan.', - 'feb.': 'feb.', - 'mars': 'm', - 'apríl': 'apríl', - 'maí': 'maí', - 'júní': 'júní', - 'júlí': 'júlí', - 'ágúst': 'á', - 'sept.': 's', - 'okt.': 'ó', - 'nóv.': 'n', - 'des.': 'd', - }; - const correctedDate = value.replace( - /jan\.|feb\.|mars|apríl|maí|júní|júlí|ágúst|sept\.|okt\.|nóv\.|des\./g, - (match) => icelandicMonthMapper[match] - ); - return formatISO( - parse(correctedDate, icelandicLanguageDisplayFormat, new Date(), { - locale: this.langModule, - }) - ); + return formatISO(parseIcelandicDate(value, this.langModule)); } return this.displayFormat @@ -1001,34 +1003,7 @@ export class Datepicker { // show error if not ISO format and not display format let parsedDate; if (this.langModule?.code === 'is' && this.dateFormat === 'dd MMM yyyy') { - const icelandicLanguageDisplayFormat = 'dd MMMM yyyy'; - const icelandicMonthMapper = { - 'jan.': 'jan.', - 'feb.': 'feb.', - 'mars': 'm', - 'apríl': 'apríl', - 'maí': 'maí', - 'júní': 'júní', - 'júlí': 'júlí', - 'ágúst': 'á', - 'sept.': 's', - 'okt.': 'ó', - 'nóv.': 'n', - 'des.': 'd', - }; - const correctedDate = val.replace( - /jan\.|feb\.|mars|apríl|maí|júní|júlí|ágúst|sept\.|okt\.|nóv\.|des\./g, - (match) => icelandicMonthMapper[match] - ); - - parsedDate = parse( - correctedDate, - icelandicLanguageDisplayFormat, - new Date(), - { - locale: this.langModule, - } - ); + parsedDate = parseIcelandicDate(val, this.langModule); } else { parsedDate = parse(val, this.displayFormat, new Date(), { locale: this.langModule, From 4edde18ce3c1b55a0a27ee7c79c424c11ac00565 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Mon, 11 Nov 2024 11:14:20 +0530 Subject: [PATCH 03/36] fix: parse date on filter --- .../src/components/datepicker/datepicker.tsx | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index e57e97744..5f0faeb32 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -896,13 +896,23 @@ export class Datepicker { fromDate = fromDate?.trim(); toDate = toDate?.trim(); - const parsedFromDate = parse(fromDate, this.displayFormat, new Date(), { - locale: this.langModule, - }); + let parsedFromDate; + if (this.langModule?.code === 'is' && this.dateFormat === 'dd MMM yyyy') { + parsedFromDate = parseIcelandicDate(fromDate, this.langModule); + } else { + parsedFromDate = parse(fromDate, this.displayFormat, new Date(), { + locale: this.langModule, + }); + } - const parsedToDate = parse(toDate, this.displayFormat, new Date(), { - locale: this.langModule, - }); + let parsedToDate; + if (this.langModule?.code === 'is' && this.dateFormat === 'dd MMM yyyy') { + parsedToDate = parseIcelandicDate(toDate, this.langModule); + } else { + parsedToDate = parse(toDate, this.displayFormat, new Date(), { + locale: this.langModule, + }); + } const isValidFromDate = isValid(parsedFromDate); const isValidToDate = isValid(parsedToDate); From 0a5c0e7f2ba0f1dfe1e584584ffc04087af02445 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Tue, 12 Nov 2024 11:25:51 +0530 Subject: [PATCH 04/36] fix: issue related to form builder empty search image changes --- .../custom-objects/src/components/form-builder/form-builder.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx b/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx index 1a41eaa66..ea61c1ca4 100644 --- a/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx +++ b/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx @@ -705,7 +705,7 @@ export class FormBuilder { }; cleanupSearchFlags(arrFieldElements); const arrResults = searchFields(arrFieldElements); // Get all matching results including those in nested sections - this.searching = arrResults.length > 0; + this.searching = true; // Set the searching flag to ensure the search results are displayed when the result is empty this.arrSearchedFields = arrResults.length ? deepCloneObject(arrResults) : null; From 20852fcc9e39c196bba81da8543d7c9222164046 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Tue, 12 Nov 2024 12:15:18 +0530 Subject: [PATCH 05/36] fix: datepicker year issue fix --- .../src/components/datepicker/datepicker.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 5f0faeb32..eebb6e789 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -1019,11 +1019,16 @@ export class Datepicker { locale: this.langModule, }); } - const year = getYear( - parse(val, this.displayFormat, new Date(), { - locale: this.langModule, - }) - ); + let year; + if (this.langModule?.code === 'is' && this.dateFormat === 'dd MMM yyyy') { + year = getYear(parseIcelandicDate(val, this.langModule)); + } else { + year = getYear( + parse(val, this.displayFormat, new Date(), { + locale: this.langModule, + }) + ); + } if ( year < this.minYear || year > this.maxYear || From d44532c6b7c20e602616582ddee292e8a64a6141 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Tue, 12 Nov 2024 12:32:41 +0530 Subject: [PATCH 06/36] fix: isMatch change issue for icelandic language --- packages/crayons-core/src/components/datepicker/datepicker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index eebb6e789..8f1312678 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -1033,7 +1033,7 @@ export class Datepicker { year < this.minYear || year > this.maxYear || !isValid(parsedDate) || - !isMatch(val, this.displayFormat, { + !isMatch(parsedDate, this.displayFormat, { locale: this.langModule, }) || !this.isDateWithinMinMaxDate(parsedDate.valueOf(), false) From 9fc9b739fae26d47b4872df2998522de0cfd31a0 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Tue, 12 Nov 2024 12:38:39 +0530 Subject: [PATCH 07/36] fix: parsed date for dateInvalid check --- packages/crayons-core/src/components/datepicker/datepicker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 8f1312678..aa79784c5 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -1038,7 +1038,7 @@ export class Datepicker { }) || !this.isDateWithinMinMaxDate(parsedDate.valueOf(), false) ) { - this.isDateInvalid = !!val; + this.isDateInvalid = !!parsedDate; this.state = this.showErrorOnInvalidDate && this.isDateInvalid ? 'error' From 99b4576715ed54dd3791df2ea85bc419c64c7709 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Tue, 12 Nov 2024 12:44:04 +0530 Subject: [PATCH 08/36] chore: test comment --- .../crayons-core/src/components/datepicker/datepicker.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index aa79784c5..8ac9e32fb 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -1038,6 +1038,14 @@ export class Datepicker { }) || !this.isDateWithinMinMaxDate(parsedDate.valueOf(), false) ) { + console.info( + year < this.minYear, + year > this.maxYear, + !isValid(parsedDate), + !isMatch(parsedDate, this.displayFormat, { + locale: this.langModule, + }) || !this.isDateWithinMinMaxDate(parsedDate.valueOf(), false) + ); this.isDateInvalid = !!parsedDate; this.state = this.showErrorOnInvalidDate && this.isDateInvalid From 1a2b66fb95832b10d5ebe37c88e1925f30caccf5 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Tue, 12 Nov 2024 12:51:04 +0530 Subject: [PATCH 09/36] fix: check for error handling for format related issue --- .../crayons-core/src/components/datepicker/datepicker.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 8ac9e32fb..03243159b 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -1033,9 +1033,10 @@ export class Datepicker { year < this.minYear || year > this.maxYear || !isValid(parsedDate) || - !isMatch(parsedDate, this.displayFormat, { - locale: this.langModule, - }) || + (this.langModule?.code !== 'is' && + !isMatch(parsedDate, this.displayFormat, { + locale: this.langModule, + })) || !this.isDateWithinMinMaxDate(parsedDate.valueOf(), false) ) { console.info( From ccf0af26640415bcfa2bd0d21d3e29cef58acd1d Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Tue, 12 Nov 2024 12:58:38 +0530 Subject: [PATCH 10/36] fix: is date validation and matching restriction --- .../crayons-core/src/components/datepicker/datepicker.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 03243159b..c037790d7 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -1032,9 +1032,9 @@ export class Datepicker { if ( year < this.minYear || year > this.maxYear || - !isValid(parsedDate) || + (this.langModule?.code !== 'is' && !isValid(val)) || (this.langModule?.code !== 'is' && - !isMatch(parsedDate, this.displayFormat, { + !isMatch(val, this.displayFormat, { locale: this.langModule, })) || !this.isDateWithinMinMaxDate(parsedDate.valueOf(), false) From 039369f71f1a309fd5d9dac2260104138032a647 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Tue, 12 Nov 2024 13:13:02 +0530 Subject: [PATCH 11/36] fix: datepicker issue --- packages/crayons-core/src/components/datepicker/datepicker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index c037790d7..841de2ece 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -1032,7 +1032,7 @@ export class Datepicker { if ( year < this.minYear || year > this.maxYear || - (this.langModule?.code !== 'is' && !isValid(val)) || + (this.langModule?.code !== 'is' && !isValid(parsedDate)) || (this.langModule?.code !== 'is' && !isMatch(val, this.displayFormat, { locale: this.langModule, From 5b9b68200d56202c16232f8f02a97014bce4cab2 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Tue, 12 Nov 2024 13:16:40 +0530 Subject: [PATCH 12/36] chore: remove console info --- .../crayons-core/src/components/datepicker/datepicker.tsx | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 841de2ece..f0d04771f 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -1039,14 +1039,6 @@ export class Datepicker { })) || !this.isDateWithinMinMaxDate(parsedDate.valueOf(), false) ) { - console.info( - year < this.minYear, - year > this.maxYear, - !isValid(parsedDate), - !isMatch(parsedDate, this.displayFormat, { - locale: this.langModule, - }) || !this.isDateWithinMinMaxDate(parsedDate.valueOf(), false) - ); this.isDateInvalid = !!parsedDate; this.state = this.showErrorOnInvalidDate && this.isDateInvalid From e4a721ea53431d39a28a65a04c3066cc4b2ac61c Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Tue, 12 Nov 2024 13:25:16 +0530 Subject: [PATCH 13/36] fix: reverse the changes on change value of datepicker --- packages/crayons-core/src/components/datepicker/datepicker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index f0d04771f..03c6fac76 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -1039,7 +1039,7 @@ export class Datepicker { })) || !this.isDateWithinMinMaxDate(parsedDate.valueOf(), false) ) { - this.isDateInvalid = !!parsedDate; + this.isDateInvalid = !!val; this.state = this.showErrorOnInvalidDate && this.isDateInvalid ? 'error' From 22d391fcf2345db9f1d1c16c73c9dc865e43a364 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Tue, 12 Nov 2024 14:19:46 +0530 Subject: [PATCH 14/36] fix: refresh handle popover parse on icelandic language issue fix --- .../src/components/datepicker/datepicker.tsx | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 03c6fac76..c5bfb89d9 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -1579,17 +1579,34 @@ export class Datepicker { this.value?.split(TranslationController.t('datepicker.to')) || []; fromDateStr = fromDateStr?.trim(); toDateStr = toDateStr?.trim(); - const parsedFromDate = parse( - fromDateStr, - this.displayFormat, - new Date(), - { + let parsedFromDate; + if ( + this.langModule?.code === 'is' && + this.dateFormat === 'dd MMM yyyy' + ) { + parsedFromDate = parseIcelandicDate( + fromDateStr, + this.langModule + ).valueOf(); + } else { + parsedFromDate = parse(fromDateStr, this.displayFormat, new Date(), { locale: this.langModule, - } - ).valueOf(); - const parsedToDate = parse(toDateStr, this.displayFormat, new Date(), { - locale: this.langModule, - }).valueOf(); + }).valueOf(); + } + let parsedToDate; + if ( + this.langModule?.code === 'is' && + this.dateFormat === 'dd MMM yyyy' + ) { + parsedToDate = parseIcelandicDate( + fromDateStr, + this.langModule + ).valueOf(); + } else { + parsedToDate = parse(toDateStr, this.displayFormat, new Date(), { + locale: this.langModule, + }).valueOf(); + } if (this.startDate !== parsedFromDate) { this.startDate = parsedFromDate; } From c8e9357b1f1ab258bab6d2062eb116f847143226 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Tue, 12 Nov 2024 16:26:41 +0530 Subject: [PATCH 15/36] chore: revert form builder changes --- .../custom-objects/src/components/form-builder/form-builder.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx b/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx index ea61c1ca4..1a41eaa66 100644 --- a/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx +++ b/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx @@ -705,7 +705,7 @@ export class FormBuilder { }; cleanupSearchFlags(arrFieldElements); const arrResults = searchFields(arrFieldElements); // Get all matching results including those in nested sections - this.searching = true; // Set the searching flag to ensure the search results are displayed when the result is empty + this.searching = arrResults.length > 0; this.arrSearchedFields = arrResults.length ? deepCloneObject(arrResults) : null; From 0cdd7bf6f573de7615207f117a59e751337bfa1d Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Tue, 12 Nov 2024 16:37:56 +0530 Subject: [PATCH 16/36] chore: refactor parseDate changes --- .../src/components/datepicker/datepicker.tsx | 131 +++++++----------- 1 file changed, 48 insertions(+), 83 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index c5bfb89d9..149184e18 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -106,6 +106,15 @@ const parseIcelandicDate = (value, langModule) => { locale: langModule, }); }; + +const parseDate = (value, displayFormat, langModule) => { + if (langModule?.code === 'is' && displayFormat === 'dd MMM yyyy') { + return parseIcelandicDate(value, langModule); + } + return parse(value, displayFormat, new Date(), { + locale: langModule, + }); +}; @Component({ tag: 'fw-datepicker', styleUrl: 'datepicker.scss', shadow: true }) export class Datepicker { @State() showDatePicker: boolean; @@ -361,14 +370,10 @@ export class Datepicker { private formatDate(value) { if (!value) return value; - // For Icelandic language, the date format is different. There is a discrepency which is handled in this PR https://github.com/date-fns/date-fns/pull/3934 - if (this.langModule?.code === 'is' && this.dateFormat === 'dd MMM yyyy') { - return formatISO(parseIcelandicDate(value, this.langModule)); - } return this.displayFormat ? formatISO( - parse(value, this.displayFormat, new Date(), { + parseDate(value, this.displayFormat, { locale: this.langModule, }) ) @@ -417,7 +422,7 @@ export class Datepicker { return ( (this.value && formatISO( - parse(this.value, this.displayFormat, new Date(), { + parseDate(this.value, this.displayFormat, { locale: this.langModule, }) )) || @@ -825,10 +830,10 @@ export class Datepicker { } setDateAndErrorState(checkDate = false) { if (this.mode === 'range' && this.fromDate && this.toDate) { - const fromDate = parse(this.fromDate, this.displayFormat, new Date(), { + const fromDate = parseDate(this.fromDate, this.displayFormat, { locale: this.langModule, }).valueOf(); - const toDate = parse(this.toDate, this.displayFormat, new Date(), { + const toDate = parseDate(this.toDate, this.displayFormat, { locale: this.langModule, }).valueOf(); this.isDateInvalid = !this.isDatewithinRange(fromDate, toDate); @@ -896,34 +901,24 @@ export class Datepicker { fromDate = fromDate?.trim(); toDate = toDate?.trim(); - let parsedFromDate; - if (this.langModule?.code === 'is' && this.dateFormat === 'dd MMM yyyy') { - parsedFromDate = parseIcelandicDate(fromDate, this.langModule); - } else { - parsedFromDate = parse(fromDate, this.displayFormat, new Date(), { - locale: this.langModule, - }); - } + const parsedFromDate = parseDate(fromDate, this.displayFormat, { + locale: this.langModule, + }); - let parsedToDate; - if (this.langModule?.code === 'is' && this.dateFormat === 'dd MMM yyyy') { - parsedToDate = parseIcelandicDate(toDate, this.langModule); - } else { - parsedToDate = parse(toDate, this.displayFormat, new Date(), { - locale: this.langModule, - }); - } + const parsedToDate = parseDate(toDate, this.displayFormat, { + locale: this.langModule, + }); const isValidFromDate = isValid(parsedFromDate); const isValidToDate = isValid(parsedToDate); const year = getYear( - parse(fromDate, this.displayFormat, new Date(), { + parseDate(fromDate, this.displayFormat, { locale: this.langModule, }) ); const toYear = getYear( - parse(toDate, this.displayFormat, new Date(), { + parseDate(toDate, this.displayFormat, { locale: this.langModule, }) ); @@ -958,12 +953,12 @@ export class Datepicker { this.fromDate = fromDate; this.toDate = toDate; const chosenFromMonth = getMonth( - parse(fromDate, this.displayFormat, new Date(), { + parseDate(fromDate, this.displayFormat, { locale: this.langModule, }) ); const chosenToMonth = getMonth( - parse(toDate, this.displayFormat, new Date(), { + parseDate(toDate, this.displayFormat, { locale: this.langModule, }) ); @@ -972,17 +967,17 @@ export class Datepicker { this.month = this.toMonth - 1; } else { this.month = getMonth( - parse(fromDate, this.displayFormat, new Date(), { + parseDate(fromDate, this.displayFormat, { locale: this.langModule, }) ); this.toMonth = this.month === 11 ? 0 : this.month + 1; } - this.startDate = parse(fromDate, this.displayFormat, new Date(), { + this.startDate = parseDate(fromDate, this.displayFormat, { locale: this.langModule, }).valueOf(); - this.endDate = parse(toDate, this.displayFormat, new Date(), { + this.endDate = parseDate(toDate, this.displayFormat, { locale: this.langModule, }).valueOf(); this.toYear = @@ -1011,24 +1006,16 @@ export class Datepicker { processValueChange(val, emitChange = false) { // show error if not ISO format and not display format - let parsedDate; - if (this.langModule?.code === 'is' && this.dateFormat === 'dd MMM yyyy') { - parsedDate = parseIcelandicDate(val, this.langModule); - } else { - parsedDate = parse(val, this.displayFormat, new Date(), { + const parsedDate = parseDate(val, this.displayFormat, { + locale: this.langModule, + }); + + const year = getYear( + parseDate(val, this.displayFormat, { locale: this.langModule, - }); - } - let year; - if (this.langModule?.code === 'is' && this.dateFormat === 'dd MMM yyyy') { - year = getYear(parseIcelandicDate(val, this.langModule)); - } else { - year = getYear( - parse(val, this.displayFormat, new Date(), { - locale: this.langModule, - }) - ); - } + }) + ); + if ( year < this.minYear || year > this.maxYear || @@ -1052,12 +1039,12 @@ export class Datepicker { this.year = year; this.month = getMonth( - parse(val, this.displayFormat, new Date(), { + parseDate(val, this.displayFormat, { locale: this.langModule, }) ); this.selectedDay = getDate( - parse(val, this.displayFormat, new Date(), { + parseDate(val, this.displayFormat, { locale: this.langModule, }) ); @@ -1179,10 +1166,9 @@ export class Datepicker { return !!(isDateSelected && this.selectedDay && this.timeValue); } if (this.clickedDateValue || this.value) { - const parsedDate = parse( + const parsedDate = parseDate( this.clickedDateValue || this.value || this.formatDateTime(), this.displayFormat, - new Date(), { locale: this.langModule, } @@ -1390,10 +1376,9 @@ export class Datepicker { isSelectedDay = ({ date, timestamp }) => { if (this.mode !== 'range') { - const parsedDate = parse( + const parsedDate = parseDate( this.clickedDateValue || this.value, this.displayFormat, - new Date(), { locale: this.langModule, } @@ -1579,34 +1564,14 @@ export class Datepicker { this.value?.split(TranslationController.t('datepicker.to')) || []; fromDateStr = fromDateStr?.trim(); toDateStr = toDateStr?.trim(); - let parsedFromDate; - if ( - this.langModule?.code === 'is' && - this.dateFormat === 'dd MMM yyyy' - ) { - parsedFromDate = parseIcelandicDate( - fromDateStr, - this.langModule - ).valueOf(); - } else { - parsedFromDate = parse(fromDateStr, this.displayFormat, new Date(), { - locale: this.langModule, - }).valueOf(); - } - let parsedToDate; - if ( - this.langModule?.code === 'is' && - this.dateFormat === 'dd MMM yyyy' - ) { - parsedToDate = parseIcelandicDate( - fromDateStr, - this.langModule - ).valueOf(); - } else { - parsedToDate = parse(toDateStr, this.displayFormat, new Date(), { - locale: this.langModule, - }).valueOf(); - } + const parsedFromDate = parseDate(fromDateStr, this.displayFormat, { + locale: this.langModule, + }).valueOf(); + + const parsedToDate = parseDate(toDateStr, this.displayFormat, { + locale: this.langModule, + }).valueOf(); + if (this.startDate !== parsedFromDate) { this.startDate = parsedFromDate; } @@ -1620,7 +1585,7 @@ export class Datepicker { // handle resetting of selectedDay on clicking cancel if (this.value) { this.clickedDateValue = this.value; - const parsedDate = parse(this.value, this.displayFormat, new Date(), { + const parsedDate = parseDate(this.value, this.displayFormat, { locale: this.langModule, }); const date = getDate(parsedDate); From ad2ecca42f25cf6d72b8c7fce2163fd43859c333 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Tue, 12 Nov 2024 17:02:58 +0530 Subject: [PATCH 17/36] chore: refactor parseDate changes --- .../crayons-core/src/components/datepicker/datepicker.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 149184e18..212e58140 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -901,11 +901,11 @@ export class Datepicker { fromDate = fromDate?.trim(); toDate = toDate?.trim(); - const parsedFromDate = parseDate(fromDate, this.displayFormat, { + const parsedFromDate = parse(fromDate, this.displayFormat, new Date(), { locale: this.langModule, }); - const parsedToDate = parseDate(toDate, this.displayFormat, { + const parsedToDate = parse(toDate, this.displayFormat, new Date(), { locale: this.langModule, }); From bd256a0915497f1c39e7b6c82f39a4da6be68aa7 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 10:00:05 +0530 Subject: [PATCH 18/36] refactor: change parse function to ensure we get parsed date on icelandic lang --- .../src/components/datepicker/datepicker.tsx | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 212e58140..965f39618 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -12,7 +12,7 @@ import { } from '@stencil/core'; import { isValid, - parse, + parse as parseDate, parseISO, getYear, getMonth, @@ -102,16 +102,16 @@ const parseIcelandicDate = (value, langModule) => { /jan\.|feb\.|mars|apríl|maí|júní|júlí|ágúst|sept\.|okt\.|nóv\.|des\./g, (match) => icelandicMonthMapper[match] ); - return parse(correctedDate, icelandicLanguageDisplayFormat, new Date(), { + return parseDate(correctedDate, icelandicLanguageDisplayFormat, new Date(), { locale: langModule, }); }; -const parseDate = (value, displayFormat, langModule) => { +const parse = (value, displayFormat, langModule) => { if (langModule?.code === 'is' && displayFormat === 'dd MMM yyyy') { return parseIcelandicDate(value, langModule); } - return parse(value, displayFormat, new Date(), { + return parseDate(value, displayFormat, new Date(), { locale: langModule, }); }; @@ -373,7 +373,7 @@ export class Datepicker { return this.displayFormat ? formatISO( - parseDate(value, this.displayFormat, { + parse(value, this.displayFormat, { locale: this.langModule, }) ) @@ -395,7 +395,6 @@ export class Datepicker { locale: this.langModule, }), this.displayFormat, - new Date(), { locale: this.langModule, } @@ -410,7 +409,6 @@ export class Datepicker { locale: this.langModule, }), this.displayFormat, - new Date(), { locale: this.langModule, } @@ -422,7 +420,7 @@ export class Datepicker { return ( (this.value && formatISO( - parseDate(this.value, this.displayFormat, { + parse(this.value, this.displayFormat, { locale: this.langModule, }) )) || @@ -830,10 +828,10 @@ export class Datepicker { } setDateAndErrorState(checkDate = false) { if (this.mode === 'range' && this.fromDate && this.toDate) { - const fromDate = parseDate(this.fromDate, this.displayFormat, { + const fromDate = parse(this.fromDate, this.displayFormat, { locale: this.langModule, }).valueOf(); - const toDate = parseDate(this.toDate, this.displayFormat, { + const toDate = parse(this.toDate, this.displayFormat, { locale: this.langModule, }).valueOf(); this.isDateInvalid = !this.isDatewithinRange(fromDate, toDate); @@ -901,11 +899,11 @@ export class Datepicker { fromDate = fromDate?.trim(); toDate = toDate?.trim(); - const parsedFromDate = parse(fromDate, this.displayFormat, new Date(), { + const parsedFromDate = parse(fromDate, this.displayFormat, { locale: this.langModule, }); - const parsedToDate = parse(toDate, this.displayFormat, new Date(), { + const parsedToDate = parse(toDate, this.displayFormat, { locale: this.langModule, }); @@ -913,12 +911,12 @@ export class Datepicker { const isValidToDate = isValid(parsedToDate); const year = getYear( - parseDate(fromDate, this.displayFormat, { + parse(fromDate, this.displayFormat, { locale: this.langModule, }) ); const toYear = getYear( - parseDate(toDate, this.displayFormat, { + parse(toDate, this.displayFormat, { locale: this.langModule, }) ); @@ -953,12 +951,12 @@ export class Datepicker { this.fromDate = fromDate; this.toDate = toDate; const chosenFromMonth = getMonth( - parseDate(fromDate, this.displayFormat, { + parse(fromDate, this.displayFormat, { locale: this.langModule, }) ); const chosenToMonth = getMonth( - parseDate(toDate, this.displayFormat, { + parse(toDate, this.displayFormat, { locale: this.langModule, }) ); @@ -967,17 +965,17 @@ export class Datepicker { this.month = this.toMonth - 1; } else { this.month = getMonth( - parseDate(fromDate, this.displayFormat, { + parse(fromDate, this.displayFormat, { locale: this.langModule, }) ); this.toMonth = this.month === 11 ? 0 : this.month + 1; } - this.startDate = parseDate(fromDate, this.displayFormat, { + this.startDate = parse(fromDate, this.displayFormat, { locale: this.langModule, }).valueOf(); - this.endDate = parseDate(toDate, this.displayFormat, { + this.endDate = parse(toDate, this.displayFormat, { locale: this.langModule, }).valueOf(); this.toYear = @@ -1006,12 +1004,12 @@ export class Datepicker { processValueChange(val, emitChange = false) { // show error if not ISO format and not display format - const parsedDate = parseDate(val, this.displayFormat, { + const parsedDate = parse(val, this.displayFormat, { locale: this.langModule, }); const year = getYear( - parseDate(val, this.displayFormat, { + parse(val, this.displayFormat, { locale: this.langModule, }) ); @@ -1039,12 +1037,12 @@ export class Datepicker { this.year = year; this.month = getMonth( - parseDate(val, this.displayFormat, { + parse(val, this.displayFormat, { locale: this.langModule, }) ); this.selectedDay = getDate( - parseDate(val, this.displayFormat, { + parse(val, this.displayFormat, { locale: this.langModule, }) ); @@ -1166,7 +1164,7 @@ export class Datepicker { return !!(isDateSelected && this.selectedDay && this.timeValue); } if (this.clickedDateValue || this.value) { - const parsedDate = parseDate( + const parsedDate = parse( this.clickedDateValue || this.value || this.formatDateTime(), this.displayFormat, { @@ -1376,7 +1374,7 @@ export class Datepicker { isSelectedDay = ({ date, timestamp }) => { if (this.mode !== 'range') { - const parsedDate = parseDate( + const parsedDate = parse( this.clickedDateValue || this.value, this.displayFormat, { @@ -1564,11 +1562,11 @@ export class Datepicker { this.value?.split(TranslationController.t('datepicker.to')) || []; fromDateStr = fromDateStr?.trim(); toDateStr = toDateStr?.trim(); - const parsedFromDate = parseDate(fromDateStr, this.displayFormat, { + const parsedFromDate = parse(fromDateStr, this.displayFormat, { locale: this.langModule, }).valueOf(); - const parsedToDate = parseDate(toDateStr, this.displayFormat, { + const parsedToDate = parse(toDateStr, this.displayFormat, { locale: this.langModule, }).valueOf(); @@ -1585,7 +1583,7 @@ export class Datepicker { // handle resetting of selectedDay on clicking cancel if (this.value) { this.clickedDateValue = this.value; - const parsedDate = parseDate(this.value, this.displayFormat, { + const parsedDate = parse(this.value, this.displayFormat, { locale: this.langModule, }); const date = getDate(parsedDate); From 56776579250a8967a9bab5772fe66e1a5e5ff881 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 10:50:41 +0530 Subject: [PATCH 19/36] fix: refresh handle popover parse on icelandic language issue fix --- .../src/components/datepicker/datepicker.tsx | 62 +++++++++++-------- .../components/form-builder/form-builder.tsx | 2 +- 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 965f39618..a9dfc2763 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -12,7 +12,7 @@ import { } from '@stencil/core'; import { isValid, - parse as parseDate, + parse, parseISO, getYear, getMonth, @@ -102,19 +102,20 @@ const parseIcelandicDate = (value, langModule) => { /jan\.|feb\.|mars|apríl|maí|júní|júlí|ágúst|sept\.|okt\.|nóv\.|des\./g, (match) => icelandicMonthMapper[match] ); - return parseDate(correctedDate, icelandicLanguageDisplayFormat, new Date(), { + return parse(correctedDate, icelandicLanguageDisplayFormat, new Date(), { locale: langModule, }); }; -const parse = (value, displayFormat, langModule) => { +const parseDate = (value, displayFormat, langModule) => { if (langModule?.code === 'is' && displayFormat === 'dd MMM yyyy') { return parseIcelandicDate(value, langModule); } - return parseDate(value, displayFormat, new Date(), { + return parse(value, displayFormat, new Date(), { locale: langModule, }); }; + @Component({ tag: 'fw-datepicker', styleUrl: 'datepicker.scss', shadow: true }) export class Datepicker { @State() showDatePicker: boolean; @@ -373,7 +374,7 @@ export class Datepicker { return this.displayFormat ? formatISO( - parse(value, this.displayFormat, { + parse(value, this.displayFormat, new Date(), { locale: this.langModule, }) ) @@ -395,6 +396,7 @@ export class Datepicker { locale: this.langModule, }), this.displayFormat, + new Date(), { locale: this.langModule, } @@ -409,6 +411,7 @@ export class Datepicker { locale: this.langModule, }), this.displayFormat, + new Date(), { locale: this.langModule, } @@ -420,7 +423,7 @@ export class Datepicker { return ( (this.value && formatISO( - parse(this.value, this.displayFormat, { + parse(this.value, this.displayFormat, new Date(), { locale: this.langModule, }) )) || @@ -828,10 +831,10 @@ export class Datepicker { } setDateAndErrorState(checkDate = false) { if (this.mode === 'range' && this.fromDate && this.toDate) { - const fromDate = parse(this.fromDate, this.displayFormat, { + const fromDate = parse(this.fromDate, this.displayFormat, new Date(), { locale: this.langModule, }).valueOf(); - const toDate = parse(this.toDate, this.displayFormat, { + const toDate = parse(this.toDate, this.displayFormat, new Date(), { locale: this.langModule, }).valueOf(); this.isDateInvalid = !this.isDatewithinRange(fromDate, toDate); @@ -899,11 +902,11 @@ export class Datepicker { fromDate = fromDate?.trim(); toDate = toDate?.trim(); - const parsedFromDate = parse(fromDate, this.displayFormat, { + const parsedFromDate = parse(fromDate, this.displayFormat, new Date(), { locale: this.langModule, }); - const parsedToDate = parse(toDate, this.displayFormat, { + const parsedToDate = parse(toDate, this.displayFormat, new Date(), { locale: this.langModule, }); @@ -911,12 +914,12 @@ export class Datepicker { const isValidToDate = isValid(parsedToDate); const year = getYear( - parse(fromDate, this.displayFormat, { + parse(fromDate, this.displayFormat, new Date(), { locale: this.langModule, }) ); const toYear = getYear( - parse(toDate, this.displayFormat, { + parse(toDate, this.displayFormat, new Date(), { locale: this.langModule, }) ); @@ -951,12 +954,12 @@ export class Datepicker { this.fromDate = fromDate; this.toDate = toDate; const chosenFromMonth = getMonth( - parse(fromDate, this.displayFormat, { + parse(fromDate, this.displayFormat, new Date(), { locale: this.langModule, }) ); const chosenToMonth = getMonth( - parse(toDate, this.displayFormat, { + parse(toDate, this.displayFormat, new Date(), { locale: this.langModule, }) ); @@ -965,17 +968,17 @@ export class Datepicker { this.month = this.toMonth - 1; } else { this.month = getMonth( - parse(fromDate, this.displayFormat, { + parse(fromDate, this.displayFormat, new Date(), { locale: this.langModule, }) ); this.toMonth = this.month === 11 ? 0 : this.month + 1; } - this.startDate = parse(fromDate, this.displayFormat, { + this.startDate = parse(fromDate, this.displayFormat, new Date(), { locale: this.langModule, }).valueOf(); - this.endDate = parse(toDate, this.displayFormat, { + this.endDate = parse(toDate, this.displayFormat, new Date(), { locale: this.langModule, }).valueOf(); this.toYear = @@ -1004,12 +1007,12 @@ export class Datepicker { processValueChange(val, emitChange = false) { // show error if not ISO format and not display format - const parsedDate = parse(val, this.displayFormat, { + const parsedDate = parseDate(val, this.displayFormat, { locale: this.langModule, }); const year = getYear( - parse(val, this.displayFormat, { + parseDate(val, this.displayFormat, { locale: this.langModule, }) ); @@ -1037,12 +1040,12 @@ export class Datepicker { this.year = year; this.month = getMonth( - parse(val, this.displayFormat, { + parse(val, this.displayFormat, new Date(), { locale: this.langModule, }) ); this.selectedDay = getDate( - parse(val, this.displayFormat, { + parse(val, this.displayFormat, new Date(), { locale: this.langModule, }) ); @@ -1167,6 +1170,7 @@ export class Datepicker { const parsedDate = parse( this.clickedDateValue || this.value || this.formatDateTime(), this.displayFormat, + new Date(), { locale: this.langModule, } @@ -1377,6 +1381,7 @@ export class Datepicker { const parsedDate = parse( this.clickedDateValue || this.value, this.displayFormat, + new Date(), { locale: this.langModule, } @@ -1562,11 +1567,16 @@ export class Datepicker { this.value?.split(TranslationController.t('datepicker.to')) || []; fromDateStr = fromDateStr?.trim(); toDateStr = toDateStr?.trim(); - const parsedFromDate = parse(fromDateStr, this.displayFormat, { - locale: this.langModule, - }).valueOf(); + const parsedFromDate = parse( + fromDateStr, + this.displayFormat, + new Date(), + { + locale: this.langModule, + } + ).valueOf(); - const parsedToDate = parse(toDateStr, this.displayFormat, { + const parsedToDate = parse(toDateStr, this.displayFormat, new Date(), { locale: this.langModule, }).valueOf(); @@ -1583,7 +1593,7 @@ export class Datepicker { // handle resetting of selectedDay on clicking cancel if (this.value) { this.clickedDateValue = this.value; - const parsedDate = parse(this.value, this.displayFormat, { + const parsedDate = parse(this.value, this.displayFormat, new Date(), { locale: this.langModule, }); const date = getDate(parsedDate); diff --git a/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx b/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx index ea61c1ca4..1a41eaa66 100644 --- a/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx +++ b/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx @@ -705,7 +705,7 @@ export class FormBuilder { }; cleanupSearchFlags(arrFieldElements); const arrResults = searchFields(arrFieldElements); // Get all matching results including those in nested sections - this.searching = true; // Set the searching flag to ensure the search results are displayed when the result is empty + this.searching = arrResults.length > 0; this.arrSearchedFields = arrResults.length ? deepCloneObject(arrResults) : null; From 314f9028dbef1c18186420518494c99b4b61e8ae Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 10:52:15 +0530 Subject: [PATCH 20/36] fix: form builder changes --- .../custom-objects/src/components/form-builder/form-builder.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx b/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx index 1a41eaa66..ea61c1ca4 100644 --- a/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx +++ b/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx @@ -705,7 +705,7 @@ export class FormBuilder { }; cleanupSearchFlags(arrFieldElements); const arrResults = searchFields(arrFieldElements); // Get all matching results including those in nested sections - this.searching = arrResults.length > 0; + this.searching = true; // Set the searching flag to ensure the search results are displayed when the result is empty this.arrSearchedFields = arrResults.length ? deepCloneObject(arrResults) : null; From 26b7a1830782f5cf4beca9d90ad60434b9760383 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 11:00:14 +0530 Subject: [PATCH 21/36] fix: datepicker issue fix --- packages/crayons-core/src/components/datepicker/datepicker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index a9dfc2763..fb5348a00 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -374,7 +374,7 @@ export class Datepicker { return this.displayFormat ? formatISO( - parse(value, this.displayFormat, new Date(), { + parseDate(value, this.displayFormat, { locale: this.langModule, }) ) From 45f7ddb781c9ebd320d9ebdc7db9575bf5947fd5 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 11:02:24 +0530 Subject: [PATCH 22/36] test: changes on date picker test case --- .../crayons-core/src/components/datepicker/datepicker.e2e.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.e2e.ts b/packages/crayons-core/src/components/datepicker/datepicker.e2e.ts index 61d659ad0..988fa7a37 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.e2e.ts +++ b/packages/crayons-core/src/components/datepicker/datepicker.e2e.ts @@ -825,7 +825,7 @@ describe('fw-datepicker', () => { await dp.setProperty('value', '2022-04-20'); await page.waitForChanges(); const val = await dp.getProperty('value'); - expect(val).toBe('20.04.2022'); + expect(val).toBe('2022-04-20'); const shadow = await page.find( 'fw-datepicker >>> fw-input >>> :first-child' ); @@ -843,7 +843,7 @@ describe('fw-datepicker', () => { await dp.setProperty('value', '2022-11-20'); await page.waitForChanges(); const val = await dp.getProperty('value'); - expect(val).toBe('20.11.2022'); + expect(val).toBe('2022-11-20'); const shadow = await page.find( 'fw-datepicker >>> fw-input >>> :first-child' ); From f4228764b0187dd8bd21358684526cb9ea315eca Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 11:36:50 +0530 Subject: [PATCH 23/36] fix: datepicker issue on filter changes --- .../src/components/datepicker/datepicker.tsx | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index fb5348a00..9ca0a208a 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -102,18 +102,19 @@ const parseIcelandicDate = (value, langModule) => { /jan\.|feb\.|mars|apríl|maí|júní|júlí|ágúst|sept\.|okt\.|nóv\.|des\./g, (match) => icelandicMonthMapper[match] ); - return parse(correctedDate, icelandicLanguageDisplayFormat, new Date(), { - locale: langModule, - }); + return parse( + correctedDate, + icelandicLanguageDisplayFormat, + new Date(), + langModule + ); }; const parseDate = (value, displayFormat, langModule) => { - if (langModule?.code === 'is' && displayFormat === 'dd MMM yyyy') { + if (langModule?.locale?.code === 'is' && displayFormat === 'dd MMM yyyy') { return parseIcelandicDate(value, langModule); } - return parse(value, displayFormat, new Date(), { - locale: langModule, - }); + return parse(value, displayFormat, new Date(), langModule); }; @Component({ tag: 'fw-datepicker', styleUrl: 'datepicker.scss', shadow: true }) @@ -902,11 +903,11 @@ export class Datepicker { fromDate = fromDate?.trim(); toDate = toDate?.trim(); - const parsedFromDate = parse(fromDate, this.displayFormat, new Date(), { + const parsedFromDate = parseDate(fromDate, this.displayFormat, { locale: this.langModule, }); - const parsedToDate = parse(toDate, this.displayFormat, new Date(), { + const parsedToDate = parseDate(toDate, this.displayFormat, { locale: this.langModule, }); @@ -926,12 +927,14 @@ export class Datepicker { if ( !isValidFromDate || !isValidToDate || - !isMatch(fromDate, this.displayFormat, { - locale: this.langModule, - }) || - !isMatch(toDate, this.displayFormat, { - locale: this.langModule, - }) || + (this.langModule?.code !== 'is' && + !isMatch(fromDate, this.displayFormat, { + locale: this.langModule, + })) || + (this.langModule?.code !== 'is' && + !isMatch(toDate, this.displayFormat, { + locale: this.langModule, + })) || year < this.minYear || year > this.maxYear || toYear < this.minYear || From d00f87bf533abc3f7d3c6494dff363d91e35b715 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 11:59:52 +0530 Subject: [PATCH 24/36] fix: generalising the datepicker for icelandic language --- .../src/components/datepicker/datepicker.tsx | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 9ca0a208a..5f0a13c71 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -12,7 +12,7 @@ import { } from '@stencil/core'; import { isValid, - parse, + parse as parseDate, parseISO, getYear, getMonth, @@ -83,6 +83,7 @@ const getWeekDays = (lang): any => { }; const parseIcelandicDate = (value, langModule) => { + if (!value) return value; const icelandicLanguageDisplayFormat = 'dd MMMM yyyy'; const icelandicMonthMapper = { 'jan.': 'jan.', @@ -98,11 +99,11 @@ const parseIcelandicDate = (value, langModule) => { 'nóv.': 'n', 'des.': 'd', }; - const correctedDate = value.replace( + const correctedDate = value?.replace( /jan\.|feb\.|mars|apríl|maí|júní|júlí|ágúst|sept\.|okt\.|nóv\.|des\./g, (match) => icelandicMonthMapper[match] ); - return parse( + return parseDate( correctedDate, icelandicLanguageDisplayFormat, new Date(), @@ -110,11 +111,12 @@ const parseIcelandicDate = (value, langModule) => { ); }; -const parseDate = (value, displayFormat, langModule) => { +const parse = (value, displayFormat, date, langModule) => { + if (!value) return value; if (langModule?.locale?.code === 'is' && displayFormat === 'dd MMM yyyy') { return parseIcelandicDate(value, langModule); } - return parse(value, displayFormat, new Date(), langModule); + return parseDate(value, displayFormat, date, langModule); }; @Component({ tag: 'fw-datepicker', styleUrl: 'datepicker.scss', shadow: true }) @@ -375,7 +377,7 @@ export class Datepicker { return this.displayFormat ? formatISO( - parseDate(value, this.displayFormat, { + parse(value, this.displayFormat, new Date(), { locale: this.langModule, }) ) @@ -903,11 +905,11 @@ export class Datepicker { fromDate = fromDate?.trim(); toDate = toDate?.trim(); - const parsedFromDate = parseDate(fromDate, this.displayFormat, { + const parsedFromDate = parse(fromDate, this.displayFormat, new Date(), { locale: this.langModule, }); - const parsedToDate = parseDate(toDate, this.displayFormat, { + const parsedToDate = parse(toDate, this.displayFormat, new Date(), { locale: this.langModule, }); @@ -1010,12 +1012,12 @@ export class Datepicker { processValueChange(val, emitChange = false) { // show error if not ISO format and not display format - const parsedDate = parseDate(val, this.displayFormat, { + const parsedDate = parse(val, this.displayFormat, new Date(), { locale: this.langModule, }); const year = getYear( - parseDate(val, this.displayFormat, { + parse(val, this.displayFormat, new Date(), { locale: this.langModule, }) ); From c4ec2fa40efa7f086a96aef8c021ea7d1dda49ca Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 12:16:55 +0530 Subject: [PATCH 25/36] test: revert datepicker test case --- .../crayons-core/src/components/datepicker/datepicker.e2e.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.e2e.ts b/packages/crayons-core/src/components/datepicker/datepicker.e2e.ts index 988fa7a37..61d659ad0 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.e2e.ts +++ b/packages/crayons-core/src/components/datepicker/datepicker.e2e.ts @@ -825,7 +825,7 @@ describe('fw-datepicker', () => { await dp.setProperty('value', '2022-04-20'); await page.waitForChanges(); const val = await dp.getProperty('value'); - expect(val).toBe('2022-04-20'); + expect(val).toBe('20.04.2022'); const shadow = await page.find( 'fw-datepicker >>> fw-input >>> :first-child' ); @@ -843,7 +843,7 @@ describe('fw-datepicker', () => { await dp.setProperty('value', '2022-11-20'); await page.waitForChanges(); const val = await dp.getProperty('value'); - expect(val).toBe('2022-11-20'); + expect(val).toBe('20.11.2022'); const shadow = await page.find( 'fw-datepicker >>> fw-input >>> :first-child' ); From b9dc9393861f3f330b1e839efc7cfbbbfe228581 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 12:18:29 +0530 Subject: [PATCH 26/36] chore: add additional data for datepicker --- packages/crayons-core/src/components/datepicker/datepicker.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 5f0a13c71..baa543526 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -83,6 +83,7 @@ const getWeekDays = (lang): any => { }; const parseIcelandicDate = (value, langModule) => { + // For Icelandic language, the date format is different. There is a discrepency which is handled in this PR https://github.com/date-fns/date-fns/pull/3934 if (!value) return value; const icelandicLanguageDisplayFormat = 'dd MMMM yyyy'; const icelandicMonthMapper = { From 04f5b2bcdf39f12c410358ab1851513f6800ff92 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 12:24:15 +0530 Subject: [PATCH 27/36] chore: remove spaces in the file on format --- .../crayons-core/src/components/datepicker/datepicker.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index baa543526..589621810 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -1016,13 +1016,11 @@ export class Datepicker { const parsedDate = parse(val, this.displayFormat, new Date(), { locale: this.langModule, }); - const year = getYear( parse(val, this.displayFormat, new Date(), { locale: this.langModule, }) ); - if ( year < this.minYear || year > this.maxYear || @@ -1581,11 +1579,9 @@ export class Datepicker { locale: this.langModule, } ).valueOf(); - const parsedToDate = parse(toDateStr, this.displayFormat, new Date(), { locale: this.langModule, }).valueOf(); - if (this.startDate !== parsedFromDate) { this.startDate = parsedFromDate; } From e51919cf6764b60cf44130c1f3469965b8d33750 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 12:44:07 +0530 Subject: [PATCH 28/36] fix: remove condition changes for datepicker --- .../src/components/datepicker/datepicker.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 589621810..1e1f8ea3b 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -1024,11 +1024,10 @@ export class Datepicker { if ( year < this.minYear || year > this.maxYear || - (this.langModule?.code !== 'is' && !isValid(parsedDate)) || - (this.langModule?.code !== 'is' && - !isMatch(val, this.displayFormat, { - locale: this.langModule, - })) || + !isValid(parsedDate) || + !isMatch(val, this.displayFormat, { + locale: this.langModule, + }) || !this.isDateWithinMinMaxDate(parsedDate.valueOf(), false) ) { this.isDateInvalid = !!val; From 2ba68f4820c4936b788bdbb8e7a27dac03a15c68 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 12:51:45 +0530 Subject: [PATCH 29/36] fix: isValid changes for datefixer --- .../crayons-core/src/components/datepicker/datepicker.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 1e1f8ea3b..a8f183e0e 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -1025,9 +1025,10 @@ export class Datepicker { year < this.minYear || year > this.maxYear || !isValid(parsedDate) || - !isMatch(val, this.displayFormat, { - locale: this.langModule, - }) || + (this.langModule?.code !== 'is' && + !isMatch(val, this.displayFormat, { + locale: this.langModule, + })) || !this.isDateWithinMinMaxDate(parsedDate.valueOf(), false) ) { this.isDateInvalid = !!val; From 38d84f842d4160e9ef7cf3d62d1e78e59c3d4c28 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 12:57:30 +0530 Subject: [PATCH 30/36] fix: datepicket changes on isMatch --- .../src/components/datepicker/datepicker.tsx | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index a8f183e0e..3d415755e 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -21,7 +21,7 @@ import { startOfDay, getDaysInMonth, format, - isMatch, + isMatch as parseIsMatch, formatISO, addDays, startOfWeek, @@ -120,6 +120,13 @@ const parse = (value, displayFormat, date, langModule) => { return parseDate(value, displayFormat, date, langModule); }; +const isMatch = (value, displayFormat, langModule) => { + return ( + langModule?.locale?.code !== 'is' && + parseIsMatch(value, displayFormat, langModule) + ); +}; + @Component({ tag: 'fw-datepicker', styleUrl: 'datepicker.scss', shadow: true }) export class Datepicker { @State() showDatePicker: boolean; @@ -930,14 +937,12 @@ export class Datepicker { if ( !isValidFromDate || !isValidToDate || - (this.langModule?.code !== 'is' && - !isMatch(fromDate, this.displayFormat, { - locale: this.langModule, - })) || - (this.langModule?.code !== 'is' && - !isMatch(toDate, this.displayFormat, { - locale: this.langModule, - })) || + !isMatch(fromDate, this.displayFormat, { + locale: this.langModule, + }) || + !isMatch(toDate, this.displayFormat, { + locale: this.langModule, + }) || year < this.minYear || year > this.maxYear || toYear < this.minYear || @@ -1025,10 +1030,9 @@ export class Datepicker { year < this.minYear || year > this.maxYear || !isValid(parsedDate) || - (this.langModule?.code !== 'is' && - !isMatch(val, this.displayFormat, { - locale: this.langModule, - })) || + !isMatch(val, this.displayFormat, { + locale: this.langModule, + }) || !this.isDateWithinMinMaxDate(parsedDate.valueOf(), false) ) { this.isDateInvalid = !!val; From 411088792a8fccdff2bc2a7dd2201069f5c1dd9b Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 13:32:04 +0530 Subject: [PATCH 31/36] fix: add validation for is language for isValid --- packages/crayons-core/src/components/datepicker/datepicker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 3d415755e..d7391e9bc 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -1029,7 +1029,7 @@ export class Datepicker { if ( year < this.minYear || year > this.maxYear || - !isValid(parsedDate) || + (this.langModule.code !== 'is' && !isValid(parsedDate)) || !isMatch(val, this.displayFormat, { locale: this.langModule, }) || From d077d858b4e4a71316edbf0e0943cfd200907d58 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 13:36:01 +0530 Subject: [PATCH 32/36] fix: datepicker issue changes on isValid --- .../src/components/datepicker/datepicker.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index d7391e9bc..93792b619 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -120,10 +120,10 @@ const parse = (value, displayFormat, date, langModule) => { return parseDate(value, displayFormat, date, langModule); }; -const isMatch = (value, displayFormat, langModule) => { +const isNoMatch = (value, displayFormat, langModule) => { return ( langModule?.locale?.code !== 'is' && - parseIsMatch(value, displayFormat, langModule) + !parseIsMatch(value, displayFormat, langModule) ); }; @@ -937,10 +937,10 @@ export class Datepicker { if ( !isValidFromDate || !isValidToDate || - !isMatch(fromDate, this.displayFormat, { + isNoMatch(fromDate, this.displayFormat, { locale: this.langModule, }) || - !isMatch(toDate, this.displayFormat, { + isNoMatch(toDate, this.displayFormat, { locale: this.langModule, }) || year < this.minYear || @@ -1029,8 +1029,8 @@ export class Datepicker { if ( year < this.minYear || year > this.maxYear || - (this.langModule.code !== 'is' && !isValid(parsedDate)) || - !isMatch(val, this.displayFormat, { + !isValid(parsedDate) || + isNoMatch(val, this.displayFormat, { locale: this.langModule, }) || !this.isDateWithinMinMaxDate(parsedDate.valueOf(), false) From 1be7cac16adf67c8749791b229dad0148f5b1a45 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 13:51:56 +0530 Subject: [PATCH 33/36] fix: retain isMatch funtionality and change in custom function --- .../src/components/datepicker/datepicker.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 93792b619..d9015d6fe 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -120,10 +120,10 @@ const parse = (value, displayFormat, date, langModule) => { return parseDate(value, displayFormat, date, langModule); }; -const isNoMatch = (value, displayFormat, langModule) => { +const isMatch = (value, displayFormat, langModule) => { return ( - langModule?.locale?.code !== 'is' && - !parseIsMatch(value, displayFormat, langModule) + !(langModule?.locale?.code !== 'is') && + parseIsMatch(value, displayFormat, langModule) ); }; @@ -937,10 +937,10 @@ export class Datepicker { if ( !isValidFromDate || !isValidToDate || - isNoMatch(fromDate, this.displayFormat, { + !isMatch(fromDate, this.displayFormat, { locale: this.langModule, }) || - isNoMatch(toDate, this.displayFormat, { + !isMatch(toDate, this.displayFormat, { locale: this.langModule, }) || year < this.minYear || @@ -1030,7 +1030,7 @@ export class Datepicker { year < this.minYear || year > this.maxYear || !isValid(parsedDate) || - isNoMatch(val, this.displayFormat, { + !isMatch(val, this.displayFormat, { locale: this.langModule, }) || !this.isDateWithinMinMaxDate(parsedDate.valueOf(), false) From 802d6142954c4c9e8bdb0f1024e98f1ee1971197 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 13:59:57 +0530 Subject: [PATCH 34/36] fix: isMatch changes retaining --- .../crayons-core/src/components/datepicker/datepicker.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index d9015d6fe..f617c909e 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -121,9 +121,9 @@ const parse = (value, displayFormat, date, langModule) => { }; const isMatch = (value, displayFormat, langModule) => { - return ( - !(langModule?.locale?.code !== 'is') && - parseIsMatch(value, displayFormat, langModule) + return !( + langModule?.locale?.code !== 'is' && + !parseIsMatch(value, displayFormat, langModule) ); }; From 4a145bc7505954f9ce71d9661c2122e7e214f6b7 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Wed, 13 Nov 2024 14:08:19 +0530 Subject: [PATCH 35/36] fix: isMatch negation changes --- .../crayons-core/src/components/datepicker/datepicker.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index f617c909e..1bfe19eca 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -121,10 +121,10 @@ const parse = (value, displayFormat, date, langModule) => { }; const isMatch = (value, displayFormat, langModule) => { - return !( - langModule?.locale?.code !== 'is' && - !parseIsMatch(value, displayFormat, langModule) - ); + if (langModule?.locale?.code !== 'is') { + parseIsMatch(value, displayFormat, langModule); + } + return false; }; @Component({ tag: 'fw-datepicker', styleUrl: 'datepicker.scss', shadow: true }) From 81e488b9b0d5512b3b49d8b382f312f399af0016 Mon Sep 17 00:00:00 2001 From: Harshith Venkatesh Date: Thu, 14 Nov 2024 11:53:10 +0530 Subject: [PATCH 36/36] fix: test cases failing on isMatch changes completed --- .../crayons-core/src/components/datepicker/datepicker.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/crayons-core/src/components/datepicker/datepicker.tsx b/packages/crayons-core/src/components/datepicker/datepicker.tsx index 1bfe19eca..deb8fdc26 100644 --- a/packages/crayons-core/src/components/datepicker/datepicker.tsx +++ b/packages/crayons-core/src/components/datepicker/datepicker.tsx @@ -122,9 +122,9 @@ const parse = (value, displayFormat, date, langModule) => { const isMatch = (value, displayFormat, langModule) => { if (langModule?.locale?.code !== 'is') { - parseIsMatch(value, displayFormat, langModule); + return parseIsMatch(value, displayFormat, langModule); } - return false; + return true; }; @Component({ tag: 'fw-datepicker', styleUrl: 'datepicker.scss', shadow: true })