diff --git a/packages/atomic/src/components.d.ts b/packages/atomic/src/components.d.ts index 3648e3c0f9b..34e27081d32 100644 --- a/packages/atomic/src/components.d.ts +++ b/packages/atomic/src/components.d.ts @@ -254,7 +254,7 @@ export namespace Components { /** * A list of fields to include with the citations used to generate the answer. */ - "fieldsToIncludeInCitations"?: string; + "fieldsToIncludeInCitations"?: string | string[]; /** * The maximum height (in rem units) of the answer when collapsed. */ @@ -2764,7 +2764,7 @@ declare namespace LocalJSX { /** * A list of fields to include with the citations used to generate the answer. */ - "fieldsToIncludeInCitations"?: string; + "fieldsToIncludeInCitations"?: string | string[]; /** * The maximum height (in rem units) of the answer when collapsed. */ diff --git a/packages/atomic/src/components/search/atomic-generated-answer/atomic-generated-answer.tsx b/packages/atomic/src/components/search/atomic-generated-answer/atomic-generated-answer.tsx index 171c3e0c4e4..2fcbfd8176a 100644 --- a/packages/atomic/src/components/search/atomic-generated-answer/atomic-generated-answer.tsx +++ b/packages/atomic/src/components/search/atomic-generated-answer/atomic-generated-answer.tsx @@ -131,7 +131,7 @@ export class AtomicGeneratedAnswer implements InitializableComponent { /** * A list of fields to include with the citations used to generate the answer. */ - @Prop() fieldsToIncludeInCitations?: string; + @Prop() fieldsToIncludeInCitations?: string | string[]; /** * Option to disable citation anchoring. @@ -306,9 +306,22 @@ export class AtomicGeneratedAnswer implements InitializableComponent { ); } + // TODO V4 (KIT-5306): Remove support for string value. + private getCitationFieldsInputArray(): string[] { + if (Array.isArray(this.fieldsToIncludeInCitations)) { + return this.fieldsToIncludeInCitations; + } else if (this.fieldsToIncludeInCitations) { + this.bindings.engine.logger.warn( + `Starting from Atomic v4, the "fields-to-include-in-citations" property will only accept an array of strings. Using a string value is now deprecated. Please update the value to be an array of strings. For example: fields-to-include-in-citations='["fieldA","fieldB"]'` + ); + return this.fieldsToIncludeInCitations.split(','); + } else { + return []; + } + } + private getCitationFields() { - return (this.fieldsToIncludeInCitations ?? '') - .split(',') + return this.getCitationFieldsInputArray() .map((field) => field.trim()) .filter((field) => field.length > 0) .concat(this.REQUIRED_FIELDS_TO_INCLUDE_IN_CITATIONS)