@epam/ai-dial-quotations 1.2.0-dev.176 → 1.2.0-dev.181
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/CitationCard/CitationCard.d.ts +7 -5
- package/components/CitationCard/CitationCard.d.ts.map +1 -1
- package/components/CitationDropdown/CitationDropdown.d.ts +2 -0
- package/components/CitationDropdown/CitationDropdown.d.ts.map +1 -1
- package/hooks/useCitationMarkdownComponents/useCitationMarkdownComponents.d.ts +2 -0
- package/hooks/useCitationMarkdownComponents/useCitationMarkdownComponents.d.ts.map +1 -1
- package/index.css +1 -1
- package/index.js +249 -208
- package/package.json +2 -2
- package/utils/group-annotations-by-source.d.ts +3 -1
- package/utils/group-annotations-by-source.d.ts.map +1 -1
|
@@ -15,8 +15,10 @@ export interface CitationCardLabels {
|
|
|
15
15
|
preview: string;
|
|
16
16
|
/** Label for the "Open in browser" button. */
|
|
17
17
|
openInBrowser: string;
|
|
18
|
-
/** Label for the
|
|
19
|
-
|
|
18
|
+
/** Label for the toggle that expands a quote cut off at the collapsed height. */
|
|
19
|
+
showMore: string;
|
|
20
|
+
/** Label for the toggle that collapses an expanded quote. */
|
|
21
|
+
showLess: string;
|
|
20
22
|
}
|
|
21
23
|
/** Color overrides for `CitationCard`, applied as CSS custom properties with app theme fallbacks. */
|
|
22
24
|
export interface CitationCardColors {
|
|
@@ -55,12 +57,12 @@ export interface CitationCardProps {
|
|
|
55
57
|
/**
|
|
56
58
|
* Called when the user clicks the "Preview" button. Omit when the group has
|
|
57
59
|
* nothing previewable (e.g. reference-only chunks) — the "Preview" button is
|
|
58
|
-
* hidden and
|
|
60
|
+
* hidden and an "Open in browser" button is shown instead.
|
|
59
61
|
*/
|
|
60
62
|
onPreview?: (annotation: Annotation) => void;
|
|
61
|
-
/** Called when the user clicks the "Open in browser"
|
|
63
|
+
/** Called when the user clicks the "Open in browser" button, shown for web links and non-previewable sources. */
|
|
62
64
|
onOpenInBrowser: (annotation: Annotation) => void;
|
|
63
|
-
/** Optional icon rendered before the
|
|
65
|
+
/** Optional icon rendered before the header text (the file extension for a previewable file, otherwise the source name). */
|
|
64
66
|
headerIcon?: ReactNode;
|
|
65
67
|
/** User-visible strings. */
|
|
66
68
|
labels: CitationCardLabels;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CitationCard.d.ts","sourceRoot":"","sources":["../../../src/components/CitationCard/CitationCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"CitationCard.d.ts","sourceRoot":"","sources":["../../../src/components/CitationCard/CitationCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAgB5D,OAAO,EACL,EAAE,EACF,SAAS,EAMV,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,yCAAyC,CAAC;AAGjD,+CAA+C;AAC/C,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,gBAAgB,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IACrB,2GAA2G;IAC3G,kBAAkB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/D,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,aAAa,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qGAAqG;AACrG,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,oEAAoE;AACpE,MAAM,WAAW,sBAAsB;IACrC,qFAAqF;IACrF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sFAAsF;IACtF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iKAAiK;IACjK,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,yFAAyF;IACzF,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,8CAA8C;AAC9C,MAAM,WAAW,iBAAiB;IAChC,wEAAwE;IACxE,KAAK,EAAE,eAAe,CAAC;IACvB,kFAAkF;IAClF,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,iHAAiH;IACjH,eAAe,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAClD,4HAA4H;IAC5H,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,4BAA4B;IAC5B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,2CAA2C;IAC3C,UAAU,CAAC,EAAE,sBAAsB,CAAC;IACpC,gCAAgC;IAChC,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B;AAED,yFAAyF;AACzF,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAwM9C,CAAC"}
|
|
@@ -16,6 +16,8 @@ export interface CitationDropdownProps {
|
|
|
16
16
|
isPreviewable?: (annotation: Annotation) => boolean;
|
|
17
17
|
/** Called when the user clicks "Open in browser" for an annotation. */
|
|
18
18
|
onOpenInBrowser: (annotation: Annotation) => void;
|
|
19
|
+
/** Whether the host's preview panel is open; a marker click then previews the active annotation directly instead of showing the card. Defaults to `false`. */
|
|
20
|
+
isPreviewOpen?: boolean;
|
|
19
21
|
/** Optional icon rendered before the marker's label. */
|
|
20
22
|
icon?: ReactNode;
|
|
21
23
|
/** Optional icon rendered in the card header. When absent, no header icon is shown. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CitationDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/CitationDropdown/CitationDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG5D,OAAO,EAAE,EAAE,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AAGnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,kCAAkC,CAAC;AAG1C,kDAAkD;AAClD,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,KAAK,EAAE,eAAe,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,qHAAqH;IACrH,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAAC;IACpD,uEAAuE;IACvE,eAAe,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAClD,wDAAwD;IACxD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,uFAAuF;IACvF,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,+CAA+C;IAC/C,UAAU,EAAE,kBAAkB,CAAC;IAC/B,yDAAyD;IACzD,YAAY,EAAE,oBAAoB,CAAC;IACnC,2DAA2D;IAC3D,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACxC,gGAAgG;IAChG,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,8HAA8H;AAC9H,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"CitationDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/CitationDropdown/CitationDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG5D,OAAO,EAAE,EAAE,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AAGnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,kCAAkC,CAAC;AAG1C,kDAAkD;AAClD,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,KAAK,EAAE,eAAe,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,qHAAqH;IACrH,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAAC;IACpD,uEAAuE;IACvE,eAAe,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAClD,8JAA8J;IAC9J,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wDAAwD;IACxD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,uFAAuF;IACvF,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,+CAA+C;IAC/C,UAAU,EAAE,kBAAkB,CAAC;IAC/B,yDAAyD;IACzD,YAAY,EAAE,oBAAoB,CAAC;IACnC,2DAA2D;IAC3D,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACxC,gGAAgG;IAChG,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,8HAA8H;AAC9H,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAyFtD,CAAC"}
|
|
@@ -11,6 +11,8 @@ export interface UseCitationMarkdownComponentsCallbacks {
|
|
|
11
11
|
isPreviewable?(annotation: Annotation): boolean;
|
|
12
12
|
/** Called when a citation marker's open-in-browser action is invoked. */
|
|
13
13
|
onOpenInBrowser(annotation: Annotation): void;
|
|
14
|
+
/** Whether the host's preview panel is open; a marker click then previews directly instead of showing the card. Defaults to `false`. */
|
|
15
|
+
isPreviewOpen?: boolean;
|
|
14
16
|
/** Builds the translated label bundles used by a given citation group's card and marker. */
|
|
15
17
|
buildLabels(group: AnnotationGroup): {
|
|
16
18
|
cardLabels: CitationCardLabels;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCitationMarkdownComponents.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCitationMarkdownComponents/useCitationMarkdownComponents.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EAEhB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAErF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAO3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE/E,6FAA6F;AAC7F,MAAM,WAAW,sCAAsC;IACrD,4GAA4G;IAC5G,SAAS,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IAChE,gFAAgF;IAChF,aAAa,CAAC,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC;IAChD,yEAAyE;IACzE,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9C,4FAA4F;IAC5F,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG;QACnC,UAAU,EAAE,kBAAkB,CAAC;QAC/B,YAAY,EAAE,oBAAoB,CAAC;KACpC,CAAC;CACH;AAwCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,6BAA6B,GACxC,SAAS,MAAM,EACf,QAAQ,eAAe,EAAE,EACzB,WAAW,sCAAsC,EACjD,qBAAmB,EACnB,6BAA2B,EAC3B,iBAAgB,eAAe,EAA0B,KACxD;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"useCitationMarkdownComponents.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCitationMarkdownComponents/useCitationMarkdownComponents.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EAEhB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAErF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAO3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE/E,6FAA6F;AAC7F,MAAM,WAAW,sCAAsC;IACrD,4GAA4G;IAC5G,SAAS,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IAChE,gFAAgF;IAChF,aAAa,CAAC,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC;IAChD,yEAAyE;IACzE,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9C,wIAAwI;IACxI,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,4FAA4F;IAC5F,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG;QACnC,UAAU,EAAE,kBAAkB,CAAC;QAC/B,YAAY,EAAE,oBAAoB,CAAC;KACpC,CAAC;CACH;AAwCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,6BAA6B,GACxC,SAAS,MAAM,EACf,QAAQ,eAAe,EAAE,EACzB,WAAW,sCAAsC,EACjD,qBAAmB,EACnB,6BAA2B,EAC3B,iBAAgB,eAAe,EAA0B,KACxD;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,UAAU,CAAA;CAiH5D,CAAC"}
|
package/index.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
._card_1kph1_1{background:var(--cc-card-bg,var(--bg-layer-raised,#fcfcfc))}._quote_1kph1_5{color:var(--cc-quote-text,var(--text-secondary,#57647a))}._title_1kph1_9{color:var(--cc-title-text,var(--text-primary,#161b2d))}._switcher_1kph1_13{color:var(--cc-switcher-text,var(--text-secondary,#57647a))}._sourceName_1kph1_17{color:var(--cc-source-name-text,var(--text-primary,#161b2d))}td ._trigger_3ev9j_1,th ._trigger_3ev9j_1{max-width:100%;margin-inline-start:0}td ._trigger_3ev9j_1>*,th ._trigger_3ev9j_1>*{min-width:0;max-width:100%}._content_3ev9j_10>svg{fill:var(--cc-card-bg,var(--bg-layer-raised,#fcfcfc));stroke:#0000}
|
|
2
|
-
/*$vite$:1*/.visible{visibility:visible}.collapse{visibility:collapse}.fixed{position:fixed}.absolute{position:absolute}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-3{margin-bottom:.75rem}.ms-1{margin-inline-start:.25rem}.line-clamp-6{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:6}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table-cell{display:table-cell}.table-row{display:table-row}.hidden{display:none}.min-h-\[3lh\]{min-height:3lh}.w-\[400px\]{width:400px}.min-w-0{min-width:0}.\!max-w-none{max-width:none!important}.max-w-\[240px\]{max-width:240px}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-start{justify-content:flex-start}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.break-words{overflow-wrap:break-word}.\!rounded-none{border-radius:0!important}.rounded-lg{border-radius:.5rem}.\!border-0{border-width:0!important}.\!bg-transparent{background-color:transparent!important}.\!p-0{padding:0!important}.p-4{padding:1rem}.ps-3{padding-inline-start:.75rem}.align-middle{vertical-align:middle}.\!shadow-none{--tw-shadow:0 0 #0000!important;--tw-shadow-colored:0 0 #0000!important;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)!important}.shadow-lg{--tw-shadow:0 8px 44px 0 var(--shadow-lg,#2764d914);--tw-shadow-colored:0 8px 44px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\[overflow-wrap\:anywhere\]{overflow-wrap:anywhere}.\[text-wrap\:pretty\]{text-wrap:pretty}.last\:mb-0:last-child{margin-bottom:0}.rtl\:scale-x-\[-1\]:where([dir=rtl],[dir=rtl] *){--tw-scale-x:-1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}
|
|
2
|
+
/*$vite$:1*/.visible{visibility:visible}.collapse{visibility:collapse}.fixed{position:fixed}.absolute{position:absolute}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-3{margin-bottom:.75rem}.ms-1{margin-inline-start:.25rem}.line-clamp-6{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:6}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table-cell{display:table-cell}.table-row{display:table-row}.hidden{display:none}.max-h-\[min\(20rem\2c 50vh\)\]{max-height:min(20rem,50vh)}.min-h-\[3lh\]{min-height:3lh}.w-\[400px\]{width:400px}.w-full{width:100%}.min-w-0{min-width:0}.\!max-w-none{max-width:none!important}.max-w-\[240px\]{max-width:240px}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.resize{resize:both}.flex-col{flex-direction:column}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-start{justify-content:flex-start}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.break-words{overflow-wrap:break-word}.\!rounded-none{border-radius:0!important}.rounded-lg{border-radius:.5rem}.\!border-0{border-width:0!important}.\!bg-transparent{background-color:transparent!important}.\!p-0{padding:0!important}.p-4{padding:1rem}.ps-3{padding-inline-start:.75rem}.align-middle{vertical-align:middle}.\!shadow-none{--tw-shadow:0 0 #0000!important;--tw-shadow-colored:0 0 #0000!important;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)!important}.shadow-lg{--tw-shadow:0 8px 44px 0 var(--shadow-lg,#2764d914);--tw-shadow-colored:0 8px 44px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\[overflow-wrap\:anywhere\]{overflow-wrap:anywhere}.\[text-wrap\:pretty\]{text-wrap:pretty}.last\:mb-0:last-child{margin-bottom:0}.rtl\:scale-x-\[-1\]:where([dir=rtl],[dir=rtl] *){--tw-scale-x:-1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}
|
package/index.js
CHANGED
|
@@ -1,158 +1,249 @@
|
|
|
1
1
|
import { MIMEType as e, MarkdownRenderer as t, buildCssVars as n, isAnnotationSelector as r, mergeClasses as i, normalizePersistedHtmlTagAttachmentType as a, normalizeRawAnnotations as o } from "@epam/ai-dial-chat-shared";
|
|
2
|
-
import { DIAL_KIT_ICON_STROKE as s, ElementSize as c, EllipsisTooltip as l, GhostIconButton as u,
|
|
3
|
-
import { IconChevronLeft as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { DIAL_KIT_ICON_STROKE as s, ElementSize as c, EllipsisTooltip as l, GhostIconButton as u, LinkButton as d, NeutralButton as f, PrimaryButton as p, Tooltip as m } from "@epam/ai-dial-ui-kit";
|
|
3
|
+
import { IconChevronLeft as ee, IconChevronRight as h } from "@tabler/icons-react";
|
|
4
|
+
import { createContext as g, useCallback as _, useContext as v, useEffect as y, useId as b, useLayoutEffect as x, useMemo as S, useRef as C, useState as w } from "react";
|
|
5
|
+
import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
|
|
6
6
|
//#region src/constants/public-class-names.ts
|
|
7
|
-
var
|
|
7
|
+
var O = {
|
|
8
8
|
citationCard: "dial-quotations-citation-card",
|
|
9
9
|
citationDropdown: "dial-quotations-citation-dropdown",
|
|
10
10
|
citationMarker: "dial-quotations-citation-marker"
|
|
11
|
-
},
|
|
11
|
+
}, k = (e) => {
|
|
12
|
+
try {
|
|
13
|
+
return decodeURIComponent(e);
|
|
14
|
+
} catch {
|
|
15
|
+
return e;
|
|
16
|
+
}
|
|
17
|
+
}, A = (e) => {
|
|
18
|
+
try {
|
|
19
|
+
let t = new URL(e);
|
|
20
|
+
return t.pathname.split("/").map((e) => k(e)).filter(Boolean).at(-1) ?? t.hostname;
|
|
21
|
+
} catch {
|
|
22
|
+
return e.split("/").map((e) => k(e)).filter(Boolean).at(-1) ?? e;
|
|
23
|
+
}
|
|
24
|
+
}, j = /\.([a-z0-9]{1,10})$/i, M = (e) => {
|
|
25
|
+
let t = e == null ? null : j.exec(e.trim());
|
|
26
|
+
return t == null ? void 0 : `.${t[1].toLowerCase()}`;
|
|
27
|
+
}, te = (e) => {
|
|
28
|
+
let t = e.body?.source?.attachment, n = t?.url;
|
|
29
|
+
return (n == null ? void 0 : M(A(n))) ?? M(t?.title);
|
|
30
|
+
}, N = (e, t) => e.body?.source?.attachment?.title ?? A(t), P = (e) => {
|
|
31
|
+
let t = e.target?.selector;
|
|
32
|
+
return t?.type === "html_tag" ? t : void 0;
|
|
33
|
+
}, F = (e) => P(e) != null, I = (e) => {
|
|
34
|
+
let t = /* @__PURE__ */ new Map();
|
|
35
|
+
for (let n of e) {
|
|
36
|
+
if (F(n)) continue;
|
|
37
|
+
let e = n.body?.source?.attachment?.url;
|
|
38
|
+
if (e == null) continue;
|
|
39
|
+
let r = t.get(e);
|
|
40
|
+
r ? r.annotations.push(n) : t.set(e, {
|
|
41
|
+
groupKey: e,
|
|
42
|
+
sourceUrl: e,
|
|
43
|
+
sourceName: N(n, e),
|
|
44
|
+
annotations: [n],
|
|
45
|
+
primaryAnnotation: n
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return Array.from(t.values());
|
|
49
|
+
}, L = (e) => {
|
|
50
|
+
let t = /* @__PURE__ */ new Map();
|
|
51
|
+
for (let n of e) {
|
|
52
|
+
let e = P(n)?.id;
|
|
53
|
+
if (e == null) continue;
|
|
54
|
+
let r = n.body?.source?.attachment?.url;
|
|
55
|
+
if (r == null) continue;
|
|
56
|
+
let i = t.get(e);
|
|
57
|
+
i ? i.annotations.push(n) : t.set(e, {
|
|
58
|
+
groupKey: `cit:${e}`,
|
|
59
|
+
sourceUrl: r,
|
|
60
|
+
sourceName: N(n, r),
|
|
61
|
+
annotations: [n],
|
|
62
|
+
primaryAnnotation: n
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return Array.from(t.values());
|
|
66
|
+
}, R = (e) => [...L(e), ...I(e)], z = (e, t) => {
|
|
67
|
+
let n = e.body?.source?.attachment?.url;
|
|
68
|
+
return n == null || !t.includes(e) ? [e] : t.filter((e) => e.body?.source?.attachment?.url === n);
|
|
69
|
+
}, B = {
|
|
12
70
|
card: "_card_1kph1_1",
|
|
13
71
|
quote: "_quote_1kph1_5",
|
|
14
72
|
title: "_title_1kph1_9",
|
|
15
73
|
switcher: "_switcher_1kph1_13",
|
|
16
74
|
sourceName: "_sourceName_1kph1_17"
|
|
17
|
-
},
|
|
18
|
-
let
|
|
19
|
-
"--cc-card-bg":
|
|
20
|
-
"--cc-quote-text":
|
|
21
|
-
"--cc-title-text":
|
|
22
|
-
"--cc-switcher-text":
|
|
23
|
-
"--cc-source-name-text":
|
|
24
|
-
});
|
|
25
|
-
return
|
|
75
|
+
}, V = ({ group: r, activeIndex: a, onIndexChange: o, onPreview: f, onOpenInBrowser: m, headerIcon: g, labels: _, typography: v, colors: S }) => {
|
|
76
|
+
let T = r.annotations.length, k = r.annotations[a] ?? r.primaryAnnotation, A = T > 1, j = k.body?.source?.attachment?.type, M = f == null || j === e.HTML || j === e.XHTML, N = (M ? void 0 : te(k)) ?? r.sourceName, P = v?.sourceNameClassName ?? "dial-tiny-text", F = v?.titleClassName ?? "dial-body-semi-text", I = v?.quoteClassName ?? "dial-small-text", L = v?.quoteStrongClassName ?? "dial-small-semi-text", R = v?.switcherClassName ?? "dial-tiny-text", z = n({
|
|
77
|
+
"--cc-card-bg": S?.cardBackground,
|
|
78
|
+
"--cc-quote-text": S?.quoteText,
|
|
79
|
+
"--cc-title-text": S?.titleText,
|
|
80
|
+
"--cc-switcher-text": S?.switcherText,
|
|
81
|
+
"--cc-source-name-text": S?.sourceNameText
|
|
82
|
+
}), V = k.body?.quote, H = b(), U = C(null), [W, G] = w(!1), [K, q] = w(!1);
|
|
83
|
+
return y(() => {
|
|
84
|
+
G(!1);
|
|
85
|
+
}, [a, V]), x(() => {
|
|
86
|
+
let e = U.current;
|
|
87
|
+
if (!e || W) return;
|
|
88
|
+
let t = () => q(e.scrollHeight > e.clientHeight + 1);
|
|
89
|
+
t();
|
|
90
|
+
let n = new ResizeObserver(t);
|
|
91
|
+
return n.observe(e), () => n.disconnect();
|
|
92
|
+
}, [V, W]), /* @__PURE__ */ D("div", {
|
|
26
93
|
role: "dialog",
|
|
27
94
|
"aria-modal": "true",
|
|
28
|
-
"aria-label":
|
|
29
|
-
style:
|
|
30
|
-
className: i("flex w-[400px] flex-col gap-3 rounded-lg p-4 shadow-lg",
|
|
95
|
+
"aria-label": _.ariaLabel,
|
|
96
|
+
style: z,
|
|
97
|
+
className: i("flex w-[400px] flex-col gap-3 rounded-lg p-4 shadow-lg", B.card, O.citationCard),
|
|
31
98
|
children: [
|
|
32
|
-
/* @__PURE__ */
|
|
99
|
+
/* @__PURE__ */ D("div", {
|
|
33
100
|
className: "flex items-center justify-between gap-2",
|
|
34
|
-
children: [/* @__PURE__ */
|
|
101
|
+
children: [/* @__PURE__ */ D("div", {
|
|
35
102
|
className: "flex min-w-0 items-center gap-1",
|
|
36
|
-
children: [g, /* @__PURE__ */
|
|
37
|
-
text:
|
|
38
|
-
className: i(
|
|
103
|
+
children: [g, /* @__PURE__ */ E(l, {
|
|
104
|
+
text: N,
|
|
105
|
+
className: i(P, "min-w-0", B.sourceName)
|
|
39
106
|
})]
|
|
40
|
-
}),
|
|
107
|
+
}), A && /* @__PURE__ */ D("div", {
|
|
41
108
|
className: "flex shrink-0 items-center gap-1",
|
|
42
109
|
children: [
|
|
43
|
-
/* @__PURE__ */
|
|
44
|
-
icon: /* @__PURE__ */
|
|
110
|
+
/* @__PURE__ */ E(u, {
|
|
111
|
+
icon: /* @__PURE__ */ E(ee, {
|
|
45
112
|
size: 14,
|
|
46
113
|
className: "rtl:scale-x-[-1]",
|
|
47
114
|
stroke: s
|
|
48
115
|
}),
|
|
49
116
|
size: c.Small,
|
|
50
|
-
"aria-label":
|
|
51
|
-
onClick: () => o((a - 1 +
|
|
117
|
+
"aria-label": _.previousCitation,
|
|
118
|
+
onClick: () => o((a - 1 + T) % T)
|
|
52
119
|
}),
|
|
53
|
-
/* @__PURE__ */
|
|
54
|
-
className: i(
|
|
55
|
-
children:
|
|
120
|
+
/* @__PURE__ */ E("span", {
|
|
121
|
+
className: i(R, B.switcher),
|
|
122
|
+
children: _.formatSwitcherText(a + 1, T)
|
|
56
123
|
}),
|
|
57
|
-
/* @__PURE__ */
|
|
58
|
-
icon: /* @__PURE__ */
|
|
124
|
+
/* @__PURE__ */ E(u, {
|
|
125
|
+
icon: /* @__PURE__ */ E(h, {
|
|
59
126
|
size: 14,
|
|
60
127
|
className: "rtl:scale-x-[-1]",
|
|
61
128
|
stroke: s
|
|
62
129
|
}),
|
|
63
130
|
size: c.Small,
|
|
64
|
-
"aria-label":
|
|
65
|
-
onClick: () => o((a + 1) %
|
|
131
|
+
"aria-label": _.nextCitation,
|
|
132
|
+
onClick: () => o((a + 1) % T)
|
|
66
133
|
})
|
|
67
134
|
]
|
|
68
135
|
})]
|
|
69
136
|
}),
|
|
70
|
-
(
|
|
137
|
+
(k.body?.title || k.body?.quote || A) && /* @__PURE__ */ D("div", {
|
|
71
138
|
className: "flex flex-col gap-3",
|
|
72
|
-
children: [
|
|
73
|
-
className: i(
|
|
74
|
-
children:
|
|
75
|
-
}), (
|
|
76
|
-
className:
|
|
77
|
-
children:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
139
|
+
children: [k.body?.title && /* @__PURE__ */ E("p", {
|
|
140
|
+
className: i(F, B.title, "break-words"),
|
|
141
|
+
children: k.body.title
|
|
142
|
+
}), (V || A) && /* @__PURE__ */ D("div", {
|
|
143
|
+
className: "flex flex-col items-start gap-1",
|
|
144
|
+
children: [/* @__PURE__ */ E("div", {
|
|
145
|
+
ref: U,
|
|
146
|
+
id: H,
|
|
147
|
+
tabIndex: W ? 0 : void 0,
|
|
148
|
+
className: i(I, B.quote, "w-full break-words", W ? "max-h-[min(20rem,50vh)] overflow-y-auto" : "line-clamp-6", A && "min-h-[3lh]"),
|
|
149
|
+
children: V && /* @__PURE__ */ E(t, {
|
|
150
|
+
content: V,
|
|
151
|
+
classNames: {
|
|
152
|
+
p: i(I, B.quote),
|
|
153
|
+
ul: i(I, "ps-3"),
|
|
154
|
+
ol: i(I, "ps-3"),
|
|
155
|
+
strong: L
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
}), K && /* @__PURE__ */ E(d, {
|
|
159
|
+
label: W ? _.showLess : _.showMore,
|
|
160
|
+
size: c.Small,
|
|
161
|
+
"aria-expanded": W,
|
|
162
|
+
"aria-controls": H,
|
|
163
|
+
onClick: () => G((e) => !e)
|
|
164
|
+
})]
|
|
86
165
|
})]
|
|
87
166
|
}),
|
|
88
|
-
/* @__PURE__ */
|
|
167
|
+
/* @__PURE__ */ D("div", {
|
|
89
168
|
className: "flex justify-start gap-2",
|
|
90
|
-
children: [
|
|
91
|
-
label:
|
|
169
|
+
children: [f && /* @__PURE__ */ E(p, {
|
|
170
|
+
label: _.preview,
|
|
92
171
|
size: c.Small,
|
|
93
|
-
onClick: () =>
|
|
94
|
-
}), /* @__PURE__ */
|
|
95
|
-
label:
|
|
172
|
+
onClick: () => f(k)
|
|
173
|
+
}), M && /* @__PURE__ */ E(p, {
|
|
174
|
+
label: _.openInBrowser,
|
|
96
175
|
size: c.Small,
|
|
97
|
-
onClick: () =>
|
|
176
|
+
onClick: () => m(k)
|
|
98
177
|
})]
|
|
99
178
|
})
|
|
100
179
|
]
|
|
101
180
|
});
|
|
102
|
-
},
|
|
181
|
+
}, H = ({ annotationCount: e, onOpen: t, icon: n, labels: r, labelClassName: a = "dial-caption-text" }) => /* @__PURE__ */ E(f, {
|
|
103
182
|
size: c.Small,
|
|
104
|
-
className: i("max-w-[240px]",
|
|
183
|
+
className: i("max-w-[240px]", O.citationMarker),
|
|
105
184
|
textClassName: "min-w-0 truncate",
|
|
106
185
|
iconBefore: n,
|
|
107
|
-
label: /* @__PURE__ */
|
|
186
|
+
label: /* @__PURE__ */ E("span", {
|
|
108
187
|
className: a,
|
|
109
188
|
children: e > 1 ? r.labelWithOverflow : r.label
|
|
110
189
|
}),
|
|
111
190
|
"aria-label": r.ariaLabel,
|
|
112
191
|
onClick: t
|
|
113
|
-
}),
|
|
114
|
-
let e =
|
|
192
|
+
}), U = g(null), W = U.Provider, G = () => {
|
|
193
|
+
let e = v(U);
|
|
115
194
|
if (e == null) throw Error("useCitationCardContext must be used within a CitationCardProvider");
|
|
116
195
|
return e;
|
|
117
|
-
},
|
|
196
|
+
}, K = {
|
|
118
197
|
trigger: "_trigger_3ev9j_1",
|
|
119
198
|
content: "_content_3ev9j_10"
|
|
120
|
-
},
|
|
121
|
-
let
|
|
122
|
-
e ||
|
|
123
|
-
}, [
|
|
124
|
-
t(e),
|
|
199
|
+
}, q = ({ group: e, onPreview: t, isPreviewable: n, onOpenInBrowser: r, isPreviewOpen: a = !1, icon: o, headerIcon: s, cardLabels: c, markerLabels: l, cardTypography: u, markerLabelClassName: d }) => {
|
|
200
|
+
let f = G(), p = b(), ee = f.isOpen(p), h = f.getActiveIndex(e.groupKey), g = e.annotations[h] ?? e.primaryAnnotation, v = n?.(g) ?? !0, y = _((e) => {
|
|
201
|
+
e || f.closePopup(p);
|
|
202
|
+
}, [f, p]), x = S(() => t && v ? (e) => {
|
|
203
|
+
t(e), f.closePopup(p);
|
|
125
204
|
} : void 0, [
|
|
126
205
|
t,
|
|
127
206
|
v,
|
|
128
|
-
|
|
129
|
-
|
|
207
|
+
f,
|
|
208
|
+
p
|
|
209
|
+
]), C = _(() => {
|
|
210
|
+
if (a && x) {
|
|
211
|
+
x(g);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
f.openPopup(p);
|
|
215
|
+
}, [
|
|
216
|
+
a,
|
|
217
|
+
x,
|
|
218
|
+
g,
|
|
219
|
+
f,
|
|
220
|
+
p
|
|
130
221
|
]);
|
|
131
|
-
return /* @__PURE__ */
|
|
132
|
-
open:
|
|
222
|
+
return /* @__PURE__ */ E(m, {
|
|
223
|
+
open: ee,
|
|
133
224
|
onOpenChange: y,
|
|
134
|
-
triggerClassName: i("ms-1 inline-flex align-middle",
|
|
135
|
-
contentClassName: i("!p-0 !bg-transparent !border-0 !shadow-none !max-w-none !rounded-none",
|
|
136
|
-
tooltip: /* @__PURE__ */
|
|
225
|
+
triggerClassName: i("ms-1 inline-flex align-middle", K.trigger),
|
|
226
|
+
contentClassName: i("!p-0 !bg-transparent !border-0 !shadow-none !max-w-none !rounded-none", K.content, O.citationDropdown),
|
|
227
|
+
tooltip: /* @__PURE__ */ E(V, {
|
|
137
228
|
group: e,
|
|
138
229
|
activeIndex: h,
|
|
139
|
-
onIndexChange: (t) =>
|
|
230
|
+
onIndexChange: (t) => f.setActiveIndex(e.groupKey, t),
|
|
140
231
|
onPreview: x,
|
|
141
232
|
onOpenInBrowser: r,
|
|
142
|
-
headerIcon:
|
|
143
|
-
labels:
|
|
144
|
-
typography:
|
|
233
|
+
headerIcon: s,
|
|
234
|
+
labels: c,
|
|
235
|
+
typography: u
|
|
145
236
|
}),
|
|
146
|
-
children: /* @__PURE__ */
|
|
237
|
+
children: /* @__PURE__ */ E(H, {
|
|
147
238
|
sourceName: e.sourceName,
|
|
148
239
|
annotationCount: e.annotations.length,
|
|
149
|
-
onOpen:
|
|
150
|
-
icon:
|
|
151
|
-
labels:
|
|
152
|
-
labelClassName:
|
|
240
|
+
onOpen: C,
|
|
241
|
+
icon: o,
|
|
242
|
+
labels: l,
|
|
243
|
+
labelClassName: d
|
|
153
244
|
})
|
|
154
245
|
});
|
|
155
|
-
},
|
|
246
|
+
}, ne = (e) => {
|
|
156
247
|
let t = e.trim();
|
|
157
248
|
if (!t.startsWith("|") || !t.endsWith("|") || /[\r\n]/.test(t)) return;
|
|
158
249
|
let n = [], r = "";
|
|
@@ -161,11 +252,11 @@ var T = {
|
|
|
161
252
|
i === "\\" && a != null && /[!-/:-@[-`{-~]/.test(a) ? (r += a, e += 1) : i === "|" ? (n.push(r.trim()), r = "") : r += i;
|
|
162
253
|
}
|
|
163
254
|
if (!(r !== "" || n.length < 2 || n.every((e) => e === "" || /^:?-{3,}:?$/.test(e)))) return n;
|
|
164
|
-
},
|
|
255
|
+
}, re = (e) => {
|
|
165
256
|
if (e.type !== "docx_text_anchor" && e.type !== "pptx_text_anchor") return;
|
|
166
257
|
let { text: t, occurrence: n, slide: r } = e;
|
|
167
258
|
if (typeof t != "string" || typeof n != "number" || !Number.isSafeInteger(n) || n < 1) return;
|
|
168
|
-
let i =
|
|
259
|
+
let i = ne(t);
|
|
169
260
|
if (i != null) {
|
|
170
261
|
if (e.type === "docx_text_anchor") return {
|
|
171
262
|
type: "docx_text_anchor",
|
|
@@ -179,13 +270,13 @@ var T = {
|
|
|
179
270
|
slide: r
|
|
180
271
|
};
|
|
181
272
|
}
|
|
182
|
-
},
|
|
273
|
+
}, ie = {
|
|
183
274
|
backgroundColor: "transparent",
|
|
184
275
|
borderColor: "var(--stroke-accent, #1D4ED8)",
|
|
185
276
|
borderWidth: "2px",
|
|
186
277
|
opacity: .5,
|
|
187
278
|
hoverOpacity: .5
|
|
188
|
-
},
|
|
279
|
+
}, ae = (e) => {
|
|
189
280
|
if (typeof e != "object" || !e) return;
|
|
190
281
|
let t = e, { lt: n, wh: r } = t;
|
|
191
282
|
if (Array.isArray(n) && Array.isArray(r) && n.length >= 2 && r.length >= 2) {
|
|
@@ -204,7 +295,7 @@ var T = {
|
|
|
204
295
|
x2: i + o,
|
|
205
296
|
y2: a + s
|
|
206
297
|
};
|
|
207
|
-
},
|
|
298
|
+
}, J = (e) => {
|
|
208
299
|
if (!r(e)) return;
|
|
209
300
|
let t = e, n;
|
|
210
301
|
if (t.type === "pdf_bbox") {
|
|
@@ -215,7 +306,7 @@ var T = {
|
|
|
215
306
|
x2: i,
|
|
216
307
|
y2: a
|
|
217
308
|
});
|
|
218
|
-
} else t.type === "pdf_region" && (n =
|
|
309
|
+
} else t.type === "pdf_region" && (n = ae(t.bbox));
|
|
219
310
|
if (n == null) return;
|
|
220
311
|
let i = t.page;
|
|
221
312
|
if (!(typeof i != "number" || !Number.isInteger(i) || i < 1) && [
|
|
@@ -230,63 +321,63 @@ var T = {
|
|
|
230
321
|
x2: n.x2,
|
|
231
322
|
y2: n.y2
|
|
232
323
|
};
|
|
233
|
-
},
|
|
324
|
+
}, Y = (e) => typeof e != "object" || !e ? String(e) : Array.isArray(e) ? `[${e.map(Y).join(",")}]` : `{${Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, t]) => `${e}=${Y(t)}`).join(",")}}`, oe = (e) => {
|
|
234
325
|
let t = 5381;
|
|
235
326
|
for (let n = 0; n < e.length; n += 1) t = t * 33 + e.charCodeAt(n) | 0;
|
|
236
327
|
return (t >>> 0).toString(36);
|
|
237
|
-
},
|
|
328
|
+
}, se = (e) => {
|
|
238
329
|
let t = e.body?.selector;
|
|
239
330
|
if (t == null) return;
|
|
240
331
|
let n = (Array.isArray(t) ? t : [t]).flatMap((e) => {
|
|
241
|
-
let t =
|
|
332
|
+
let t = J(e);
|
|
242
333
|
return t == null ? [] : [t];
|
|
243
|
-
}), r =
|
|
244
|
-
if (!(n.length === 0 && r.length === 0)) return
|
|
245
|
-
},
|
|
246
|
-
let t = e.target?.selector, n = t?.type === "html_tag" ? t.id : void 0, r = typeof n == "string" ? n : void 0, i =
|
|
247
|
-
if (!(r == null && i == null)) return
|
|
248
|
-
},
|
|
334
|
+
}), r = _e(e);
|
|
335
|
+
if (!(n.length === 0 && r.length === 0)) return Y([n, r]);
|
|
336
|
+
}, ce = (e) => {
|
|
337
|
+
let t = e.target?.selector, n = t?.type === "html_tag" ? t.id : void 0, r = typeof n == "string" ? n : void 0, i = se(e);
|
|
338
|
+
if (!(r == null && i == null)) return oe(`${r ?? ""}|${i ?? ""}`);
|
|
339
|
+
}, le = (e) => e.flatMap((e, t) => {
|
|
249
340
|
let n = e.body?.selector;
|
|
250
341
|
if (n == null) return [];
|
|
251
342
|
let i = (Array.isArray(n) ? n : [n]).flatMap((e) => {
|
|
252
343
|
if (!r(e)) return [];
|
|
253
|
-
let t =
|
|
344
|
+
let t = J(e);
|
|
254
345
|
return t == null ? [] : [t];
|
|
255
346
|
});
|
|
256
347
|
return i.length === 0 ? [] : [{
|
|
257
|
-
id:
|
|
348
|
+
id: X(e, t),
|
|
258
349
|
bboxes: i,
|
|
259
|
-
style:
|
|
350
|
+
style: ie
|
|
260
351
|
}];
|
|
261
|
-
}),
|
|
352
|
+
}), X = (e, t) => e.index == null ? ce(e) ?? String(t) : String(e.index), ue = (e) => {
|
|
262
353
|
let t = e.body?.selector;
|
|
263
354
|
if (t == null) return;
|
|
264
355
|
let n = Array.isArray(t) ? t : [t];
|
|
265
356
|
for (let e of n) {
|
|
266
357
|
if (!r(e)) continue;
|
|
267
|
-
let t =
|
|
358
|
+
let t = J(e);
|
|
268
359
|
if (t != null) return t.page;
|
|
269
360
|
}
|
|
270
|
-
},
|
|
361
|
+
}, Z = (e) => {
|
|
271
362
|
let t = e.custom_content?.annotations;
|
|
272
363
|
if (t?.length) return t.filter((e) => e != null && e.body?.source?.attachment?.url != null).map(a);
|
|
273
364
|
let n = e.custom_fields;
|
|
274
365
|
if (typeof n != "object" || !n) return [];
|
|
275
366
|
let r = n.annotations;
|
|
276
367
|
return !Array.isArray(r) || r.length === 0 ? [] : o(r, e.custom_content?.attachments ?? []).map(a);
|
|
277
|
-
},
|
|
368
|
+
}, Q = (e) => {
|
|
278
369
|
if (e.type !== "docx_text_range") return !1;
|
|
279
370
|
let t = e;
|
|
280
371
|
return typeof t.story == "string" && Array.isArray(t.path) && t.path.every((e) => typeof e == "number") && typeof t.start == "number" && typeof t.end == "number" && typeof t.text == "string";
|
|
281
|
-
},
|
|
372
|
+
}, de = (e) => {
|
|
282
373
|
if (e.type !== "pptx_text_range") return !1;
|
|
283
374
|
let t = e;
|
|
284
375
|
return typeof t.slide == "number" && typeof t.shape_id == "string" && typeof t.start == "number" && typeof t.end == "number" && typeof t.text == "string";
|
|
285
|
-
},
|
|
376
|
+
}, fe = (e) => typeof e == "object" && !!e && typeof e.row == "number" && typeof e.col == "number", pe = (e) => {
|
|
286
377
|
if (e.type !== "excel_rc_range") return !1;
|
|
287
378
|
let t = e;
|
|
288
|
-
return typeof t.sheet == "string" &&
|
|
289
|
-
},
|
|
379
|
+
return typeof t.sheet == "string" && fe(t.start) && (t.end === void 0 || t.end === null || fe(t.end));
|
|
380
|
+
}, me = (e) => {
|
|
290
381
|
let { story: t, path: n, start: r, end: i, text: a } = e;
|
|
291
382
|
if (!(!n.every((e) => Number.isInteger(e)) || !Number.isInteger(r) || !Number.isInteger(i) || r < 0 || i < r)) return {
|
|
292
383
|
type: "docx_text_range",
|
|
@@ -296,7 +387,7 @@ var T = {
|
|
|
296
387
|
endExclusive: i,
|
|
297
388
|
text: a
|
|
298
389
|
};
|
|
299
|
-
},
|
|
390
|
+
}, he = (e) => {
|
|
300
391
|
let { slide: t, shape_id: n, start: r, end: i, text: a } = e;
|
|
301
392
|
if (!(!Number.isInteger(t) || t < 1 || !Number.isInteger(r) || !Number.isInteger(i) || r < 0 || i < r)) return {
|
|
302
393
|
type: "pptx_text_range",
|
|
@@ -306,7 +397,7 @@ var T = {
|
|
|
306
397
|
endExclusive: i,
|
|
307
398
|
text: a
|
|
308
399
|
};
|
|
309
|
-
},
|
|
400
|
+
}, ge = (e) => {
|
|
310
401
|
let { sheet: t, start: n, end: r } = e;
|
|
311
402
|
if (!(t.length === 0 || !Number.isInteger(n.row) || !Number.isInteger(n.col) || n.row < 1 || n.col < 1)) {
|
|
312
403
|
if (r == null) return {
|
|
@@ -321,40 +412,40 @@ var T = {
|
|
|
321
412
|
end: r
|
|
322
413
|
};
|
|
323
414
|
}
|
|
324
|
-
},
|
|
415
|
+
}, _e = (e) => {
|
|
325
416
|
let t = e.body?.selector;
|
|
326
417
|
return t == null ? [] : (Array.isArray(t) ? t : [t]).flatMap((e) => {
|
|
327
418
|
if (!r(e)) return [];
|
|
328
|
-
if (
|
|
329
|
-
let t =
|
|
419
|
+
if (Q(e)) {
|
|
420
|
+
let t = me(e);
|
|
330
421
|
return t ? [t] : [];
|
|
331
422
|
}
|
|
332
|
-
if (
|
|
333
|
-
let t =
|
|
423
|
+
if (de(e)) {
|
|
424
|
+
let t = he(e);
|
|
334
425
|
return t ? [t] : [];
|
|
335
426
|
}
|
|
336
|
-
if (
|
|
337
|
-
let t =
|
|
427
|
+
if (pe(e)) {
|
|
428
|
+
let t = ge(e);
|
|
338
429
|
return t ? [t] : [];
|
|
339
430
|
}
|
|
340
|
-
let t =
|
|
431
|
+
let t = re(e);
|
|
341
432
|
return t ? [t] : [];
|
|
342
433
|
});
|
|
343
|
-
},
|
|
434
|
+
}, ve = (e, t) => S(() => t ? [] : Z(e), [t, e]), ye = {
|
|
344
435
|
openOwnerKey: null,
|
|
345
436
|
activeIndexByGroup: {}
|
|
346
|
-
},
|
|
347
|
-
let [e, t] = w(
|
|
437
|
+
}, be = () => {
|
|
438
|
+
let [e, t] = w(ye), n = _((e) => {
|
|
348
439
|
t((t) => ({
|
|
349
440
|
...t,
|
|
350
441
|
openOwnerKey: e
|
|
351
442
|
}));
|
|
352
|
-
}, []), r =
|
|
443
|
+
}, []), r = _((e) => {
|
|
353
444
|
t((t) => t.openOwnerKey === e ? {
|
|
354
445
|
...t,
|
|
355
446
|
openOwnerKey: null
|
|
356
447
|
} : t);
|
|
357
|
-
}, []), i =
|
|
448
|
+
}, []), i = _((e, n) => {
|
|
358
449
|
t((t) => ({
|
|
359
450
|
...t,
|
|
360
451
|
activeIndexByGroup: {
|
|
@@ -363,7 +454,7 @@ var T = {
|
|
|
363
454
|
}
|
|
364
455
|
}));
|
|
365
456
|
}, []);
|
|
366
|
-
return
|
|
457
|
+
return S(() => ({
|
|
367
458
|
openPopup: n,
|
|
368
459
|
closePopup: r,
|
|
369
460
|
setActiveIndex: i,
|
|
@@ -375,7 +466,7 @@ var T = {
|
|
|
375
466
|
i,
|
|
376
467
|
e
|
|
377
468
|
]);
|
|
378
|
-
},
|
|
469
|
+
}, xe = /⟦C(\d+)⟧/g, Se = (e, t) => {
|
|
379
470
|
let n = t.map((e, t) => ({
|
|
380
471
|
g: e,
|
|
381
472
|
idx: t
|
|
@@ -388,9 +479,9 @@ var T = {
|
|
|
388
479
|
}).sort((e, t) => t.pos - e.pos), r = e;
|
|
389
480
|
for (let { idx: e, pos: t } of n) r = `${r.slice(0, t)}⟦C${e}⟧${r.slice(t)}`;
|
|
390
481
|
return r;
|
|
391
|
-
},
|
|
482
|
+
}, Ce = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>/g, we = /^<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>$/, Te = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>|<\/?cit\b[^>]*>|<\/?cit\b[^>]*$/gi, Ee = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), De = (e) => e.replace(Te, (e) => we.test(e) ? e : Ee(e)), Oe = (e) => De(e).replace(Ce, ""), $ = (e, t) => {
|
|
392
483
|
if (typeof e == "string") {
|
|
393
|
-
let n = e.split(
|
|
484
|
+
let n = e.split(xe);
|
|
394
485
|
if (n.length === 1) return e;
|
|
395
486
|
let r = [];
|
|
396
487
|
return n.forEach((e, n) => {
|
|
@@ -398,62 +489,63 @@ var T = {
|
|
|
398
489
|
}), r;
|
|
399
490
|
}
|
|
400
491
|
return Array.isArray(e) ? e.flatMap((e) => {
|
|
401
|
-
let n =
|
|
492
|
+
let n = $(e, t);
|
|
402
493
|
return Array.isArray(n) ? n : [n];
|
|
403
494
|
}) : e;
|
|
404
|
-
},
|
|
495
|
+
}, ke = {}, Ae = [], je = (e) => {
|
|
405
496
|
let t = e.primaryAnnotation.target?.selector;
|
|
406
497
|
return t?.type === "html_tag" ? t.id : void 0;
|
|
407
|
-
},
|
|
498
|
+
}, Me = (e, t) => /* @__PURE__ */ D(T, { children: [
|
|
408
499
|
e == null ? "<cit>" : `<cit data-id="${e}">`,
|
|
409
500
|
t,
|
|
410
501
|
"</cit>"
|
|
411
|
-
] }),
|
|
412
|
-
let { onPreview: s, isPreviewable: c, onOpenInBrowser: l,
|
|
502
|
+
] }), Ne = (e, t, n, r = !1, a = !1, o = Ae) => {
|
|
503
|
+
let { onPreview: s, isPreviewable: c, onOpenInBrowser: l, isPreviewOpen: u = !1, buildLabels: d } = n, f = S(() => r ? Oe(e) : De(t.length > 0 ? Se(e, t) : e), [
|
|
413
504
|
e,
|
|
414
505
|
t,
|
|
415
506
|
r
|
|
416
|
-
]),
|
|
507
|
+
]), p = f.includes("<cit");
|
|
417
508
|
return {
|
|
418
|
-
processedContent:
|
|
419
|
-
markdownComponents:
|
|
509
|
+
processedContent: f,
|
|
510
|
+
markdownComponents: S(() => {
|
|
420
511
|
let e = /* @__PURE__ */ new Map();
|
|
421
512
|
for (let t of o) {
|
|
422
|
-
let n =
|
|
513
|
+
let n = je(t);
|
|
423
514
|
n != null && e.set(n, t);
|
|
424
515
|
}
|
|
425
516
|
for (let n of t) {
|
|
426
|
-
let t =
|
|
517
|
+
let t = je(n);
|
|
427
518
|
t != null && e.set(t, n);
|
|
428
519
|
}
|
|
429
520
|
let n = (e) => {
|
|
430
|
-
let { cardLabels: t, markerLabels: n } =
|
|
431
|
-
return /* @__PURE__ */
|
|
521
|
+
let { cardLabels: t, markerLabels: n } = d(e);
|
|
522
|
+
return /* @__PURE__ */ E(q, {
|
|
432
523
|
group: e,
|
|
433
524
|
onPreview: (t) => s(t, e),
|
|
434
525
|
isPreviewable: c,
|
|
435
526
|
onOpenInBrowser: l,
|
|
527
|
+
isPreviewOpen: u,
|
|
436
528
|
cardLabels: t,
|
|
437
529
|
markerLabels: n
|
|
438
530
|
}, `citation-${e.groupKey}`);
|
|
439
531
|
}, r = (e) => {
|
|
440
532
|
let r = t[e];
|
|
441
533
|
return r ? n(r) : null;
|
|
442
|
-
},
|
|
534
|
+
}, f = { cit: (t) => {
|
|
443
535
|
let r = t["data-id"] == null ? void 0 : e.get(t["data-id"]);
|
|
444
|
-
return r ? n(r) :
|
|
536
|
+
return r ? n(r) : Me(t["data-id"], t.children);
|
|
445
537
|
} };
|
|
446
|
-
return t.length === 0 && o.length === 0 ?
|
|
447
|
-
...
|
|
448
|
-
p: ({ children: e, ...t }) => /* @__PURE__ */
|
|
538
|
+
return t.length === 0 && o.length === 0 ? p ? f : ke : {
|
|
539
|
+
...f,
|
|
540
|
+
p: ({ children: e, ...t }) => /* @__PURE__ */ E("p", {
|
|
449
541
|
...t,
|
|
450
542
|
className: i(a ? "dial-small-paragraph-text" : "dial-body-paragraph-text", "mb-3 [overflow-wrap:anywhere] [text-wrap:pretty] last:mb-0"),
|
|
451
|
-
children:
|
|
543
|
+
children: $(e, r)
|
|
452
544
|
}),
|
|
453
|
-
li: ({ children: e, ...t }) => /* @__PURE__ */
|
|
545
|
+
li: ({ children: e, ...t }) => /* @__PURE__ */ E("li", {
|
|
454
546
|
...t,
|
|
455
547
|
className: "mb-1.5 last:mb-0",
|
|
456
|
-
children:
|
|
548
|
+
children: $(e, r)
|
|
457
549
|
})
|
|
458
550
|
};
|
|
459
551
|
}, [
|
|
@@ -463,70 +555,19 @@ var T = {
|
|
|
463
555
|
c,
|
|
464
556
|
l,
|
|
465
557
|
u,
|
|
558
|
+
d,
|
|
466
559
|
a,
|
|
467
|
-
|
|
560
|
+
p
|
|
468
561
|
])
|
|
469
562
|
};
|
|
470
|
-
},
|
|
471
|
-
|
|
472
|
-
return decodeURIComponent(e);
|
|
473
|
-
} catch {
|
|
474
|
-
return e;
|
|
475
|
-
}
|
|
476
|
-
}, Ce = (e) => {
|
|
477
|
-
try {
|
|
478
|
-
let t = new URL(e);
|
|
479
|
-
return t.pathname.split("/").map((e) => Y(e)).filter(Boolean).at(-1) ?? t.hostname;
|
|
480
|
-
} catch {
|
|
481
|
-
return e.split("/").map((e) => Y(e)).filter(Boolean).at(-1) ?? e;
|
|
482
|
-
}
|
|
483
|
-
}, X = (e, t) => e.body?.source?.attachment?.title ?? Ce(t), Z = (e) => {
|
|
484
|
-
let t = e.target?.selector;
|
|
485
|
-
return t?.type === "html_tag" ? t : void 0;
|
|
486
|
-
}, we = (e) => Z(e) != null, Q = (e) => {
|
|
487
|
-
let t = /* @__PURE__ */ new Map();
|
|
488
|
-
for (let n of e) {
|
|
489
|
-
if (we(n)) continue;
|
|
490
|
-
let e = n.body?.source?.attachment?.url;
|
|
491
|
-
if (e == null) continue;
|
|
492
|
-
let r = t.get(e);
|
|
493
|
-
r ? r.annotations.push(n) : t.set(e, {
|
|
494
|
-
groupKey: e,
|
|
495
|
-
sourceUrl: e,
|
|
496
|
-
sourceName: X(n, e),
|
|
497
|
-
annotations: [n],
|
|
498
|
-
primaryAnnotation: n
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
return Array.from(t.values());
|
|
502
|
-
}, Te = (e) => {
|
|
503
|
-
let t = /* @__PURE__ */ new Map();
|
|
504
|
-
for (let n of e) {
|
|
505
|
-
let e = Z(n)?.id;
|
|
506
|
-
if (e == null) continue;
|
|
507
|
-
let r = n.body?.source?.attachment?.url;
|
|
508
|
-
if (r == null) continue;
|
|
509
|
-
let i = t.get(e);
|
|
510
|
-
i ? i.annotations.push(n) : t.set(e, {
|
|
511
|
-
groupKey: `cit:${e}`,
|
|
512
|
-
sourceUrl: r,
|
|
513
|
-
sourceName: X(n, r),
|
|
514
|
-
annotations: [n],
|
|
515
|
-
primaryAnnotation: n
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
return Array.from(t.values());
|
|
519
|
-
}, Ee = (e) => [...Te(e), ...Q(e)], De = (e, t) => {
|
|
520
|
-
let n = e.body?.source?.attachment?.url;
|
|
521
|
-
return n == null || !t.includes(e) ? [e] : t.filter((e) => e.body?.source?.attachment?.url === n);
|
|
522
|
-
}, Oe = (e) => e.url == null && e.reference_url != null, ke = /^(.*\.pdf)(?:#page=(\d+))?$/i, $ = (e) => {
|
|
523
|
-
let t = ke.exec(e);
|
|
563
|
+
}, Pe = (e) => e.url == null && e.reference_url != null, Fe = /^(.*\.pdf)(?:#page=(\d+))?$/i, Ie = (e) => {
|
|
564
|
+
let t = Fe.exec(e);
|
|
524
565
|
return t ? {
|
|
525
566
|
baseUrl: t[1],
|
|
526
567
|
page: t[2] == null ? null : Number(t[2])
|
|
527
568
|
} : null;
|
|
528
|
-
},
|
|
529
|
-
let n = t.reference_url, r =
|
|
569
|
+
}, Le = (t) => I((t ?? []).filter(Pe).map((t) => {
|
|
570
|
+
let n = t.reference_url, r = Ie(n) != null;
|
|
530
571
|
return { body: {
|
|
531
572
|
quote: t.data,
|
|
532
573
|
source: {
|
|
@@ -540,4 +581,4 @@ var T = {
|
|
|
540
581
|
} };
|
|
541
582
|
}));
|
|
542
583
|
//#endregion
|
|
543
|
-
export {
|
|
584
|
+
export { V as CitationCard, W as CitationCardProvider, q as CitationDropdown, H as CitationMarker, O as QUOTATIONS_CLASS, X as annotationHighlightId, _e as annotationToOfficeHighlightLocations, le as annotationsToPdfHighlights, z as gatherSameSourceAnnotations, ue as getAnnotationPdfPage, Le as getReferenceAttachmentGroups, R as groupAnnotations, L as groupAnnotationsByCitId, I as groupAnnotationsBySource, Se as injectCitationSentinels, Q as isDocxRangeSelector, pe as isExcelRcRangeSelector, de as isPptxRangeSelector, Pe as isReferenceOnlyAttachment, Ie as parsePdfPageReference, $ as replaceSentinelsInChildren, Z as resolveMessageAnnotations, Oe as stripCitTagsWhileStreaming, ve as useAnnotations, be as useCitationCard, G as useCitationCardContext, Ne as useCitationMarkdownComponents };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-quotations",
|
|
3
3
|
"description": "Citation and annotation components, hooks, and utilities for AI DIAL conversations",
|
|
4
|
-
"version": "1.2.0-dev.
|
|
4
|
+
"version": "1.2.0-dev.181",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"react": "^19.2.8",
|
|
26
|
-
"@epam/ai-dial-chat-shared": "1.2.0-dev.
|
|
26
|
+
"@epam/ai-dial-chat-shared": "1.2.0-dev.181",
|
|
27
27
|
"@epam/ai-dial-ui-kit": "^0.15.0-dev.21"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
@@ -8,7 +8,7 @@ export interface AnnotationGroup {
|
|
|
8
8
|
* cit ids citing the same document never share popup state.
|
|
9
9
|
*/
|
|
10
10
|
groupKey: string;
|
|
11
|
-
/** The cited attachment's URL — used for Preview/
|
|
11
|
+
/** The cited attachment's URL — used for Preview/Open in browser. */
|
|
12
12
|
sourceUrl: string;
|
|
13
13
|
/**
|
|
14
14
|
* Human-readable name derived from the URL: the last non-empty path segment
|
|
@@ -20,6 +20,8 @@ export interface AnnotationGroup {
|
|
|
20
20
|
/** The first annotation in the group — used for the inline citation marker position. */
|
|
21
21
|
primaryAnnotation: Annotation;
|
|
22
22
|
}
|
|
23
|
+
/** Returns the cited file's extension with a leading dot (e.g. `'.pdf'`), read from its URL and then its title, or `undefined` when neither carries one. */
|
|
24
|
+
export declare const getSourceFileExtension: (annotation: Annotation) => string | undefined;
|
|
23
25
|
/**
|
|
24
26
|
* Groups annotations by their source attachment URL. Annotations without a
|
|
25
27
|
* `body.source.attachment.url` are excluded, as are `html_tag`-selector
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-annotations-by-source.d.ts","sourceRoot":"","sources":["../../src/utils/group-annotations-by-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,2BAA2B,CAAC;AAE7E,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,
|
|
1
|
+
{"version":3,"file":"group-annotations-by-source.d.ts","sourceRoot":"","sources":["../../src/utils/group-annotations-by-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,2BAA2B,CAAC;AAE7E,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,wFAAwF;IACxF,iBAAiB,EAAE,UAAU,CAAC;CAC/B;AAkCD,4JAA4J;AAC5J,eAAO,MAAM,sBAAsB,GACjC,YAAY,UAAU,KACrB,MAAM,GAAG,SAOX,CAAC;AAyBF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,aAAa,UAAU,EAAE,KACxB,eAAe,EAuBjB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAClC,aAAa,UAAU,EAAE,KACxB,eAAe,EAwBjB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAC3B,aAAa,UAAU,EAAE,KACxB,eAAe,EAGjB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GACtC,SAAS,UAAU,EACnB,aAAa,UAAU,EAAE,KACxB,UAAU,EAKZ,CAAC"}
|