@cimulate/copilot-widget 0.6.0
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/README.md +11 -0
- package/dist/cimulate-copilot-widget.css +1 -0
- package/dist/cimulate-copilot-widget.d.ts +126 -0
- package/dist/cimulate-copilot-widget.es.js +30684 -0
- package/dist/cimulate-copilot-widget.umd.js +75 -0
- package/package.json +101 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.cim-widget-icon-button{display:inline-flex;align-items:center;justify-content:center;min-width:32px;background-color:transparent;border:1px solid transparent;border-radius:4px;padding:6px;cursor:pointer;color:#333;font-size:18px;&:hover{background-color:#f0f0f0}&:disabled,&[disabled]{opacity:.6;background-color:#f9f9f9;cursor:not-allowed}}.cim-widget-search-bar{display:flex;align-items:center;justify-content:space-between;padding:1px;border:1px solid var(--cim-widget-border-color);border-radius:4px;font-family:var(--cim-widget-font-family)}.cim-widget-search-input{width:100%;height:100%;margin-left:8px;background-color:transparent;border:none;outline:none}.cim-widget-product-tile{display:inline-flex;flex-direction:column;background-color:var(--cim-widget-background-color, #ffffff);border-radius:4px;box-shadow:0 1px 3px #0000001a}.cim-widget-product-tile.embedded,.cim-widget-product-tile.standalone{min-width:15dvw;max-width:30dvw}.cim-widget-product-tile-image{object-fit:contain;width:100%;height:auto;max-height:25dvh;border-top-left-radius:4px;border-top-right-radius:4px}.cim-widget-product-tile-details{height:100%;display:flex;flex-direction:column;justify-content:space-between;padding:.5rem}.cim-widget-product-tile-brand{color:var(--cim-widget-primary-color)}.cim-widget-product-tile-pdp,.cim-widget-product-tile-name,.cim-widget-product-tile-price,.cim-widget-product-tile-pid{font-size:.875rem}.cim-widget-product-tile-name{font-weight:700}.cim-widget-product-tile-pdp{color:color-mix(in hsl decreasing hue,var(--cim-widget-font-color) 85%,black);text-decoration:none;&:hover{text-decoration:underline}}.cim-widget-product-tile-pdp-arrow{display:inline-block;transform:rotate(-45deg)}.cim-widget-product-tile-footer{display:flex;justify-content:space-between;align-items:center;padding-top:.5rem;gap:.5rem}.cim-widget-product-tile-price{font-weight:700}@media (max-width: 576px){.cim-widget-product-tile.embedded,.cim-widget-product-tile.standalone{min-width:30dvw;max-width:45dvw}.cim-widget-product-tile-pdp,.cim-widget-product-tile-name{display:-webkit-box;line-clamp:3;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}}.cim-widget-display-products{flex-direction:column;overflow-x:hidden}.cim-widget-product-list{flex:1;display:inline-flex;gap:.5rem;padding:.5rem .5rem .5rem 0;overflow-x:auto}.cim-widget-error-message-text{display:inline-flex;align-items:center;gap:.5rem;color:#e53e3e;&.embedded svg{min-width:1.25rem;height:1.25rem}}.cim-widget-button{padding:.5rem;background-color:var(--cim-widget-primary-color, #3182ce);border-radius:4px;border-color:var(--cim-widget-primary-color, #3182ce);border-style:solid;color:#fff;font-family:var(--cim-widget-font-family, inherit);cursor:pointer;&:disabled,&[disabled]{cursor:not-allowed}}.cim-widget-close-button{display:flex;align-items:center;justify-content:center;padding:.5rem;border-radius:4px;border:1px solid transparent;background-color:transparent;cursor:pointer;&:hover{background-color:#f0f0f0}}.cim-widget-suggestion-container.embedded{display:inline-flex;flex-wrap:wrap;gap:.5rem}.cim-widget-suggestion-button.embedded{height:auto;padding:.2rem .5rem;border:1px solid var(--cim-widget-primary-color);border-radius:4px;background-color:transparent;font-size:.875rem;font-weight:600;font-family:inherit;color:var(--cim-widget-primary-color);white-space:normal;word-break:break-word;text-align:left;cursor:pointer}.cim-widget-suggestion-button.embedded:hover{background-color:#fff;color:color-mix(in hsl decreasing hue,var(--cim-widget-primary-color) 85%,black)}.cim-widget-suggestion-container.standalone{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:.5rem;padding:.5rem 0}@media (max-width: 768px){.cim-widget-suggestion-container.standalone{grid-template-columns:repeat(1,1fr)}}.cim-widget-suggestion-button.standalone{display:inline-flex;align-items:center;padding:.5rem 1rem;border:1px solid var(--cim-widget-primary-color);background-color:color-mix(in hsl decreasing hue,var(--cim-widget-primary-color) 5%,transparent);font-weight:700;color:var(--cim-widget-primary-color);text-align:left;white-space:normal;word-break:break-word}.cim-widget-suggestion-button.standalone:hover{background-color:color-mix(in hsl decreasing hue,var(--cim-widget-primary-color) 15%,transparent);color:color-mix(in hsl decreasing hue,var(--cim-widget-primary-color) 85%,black)}.cim-widget-blinking-cursor{display:inline-flex;margin-left:2px;line-height:0;animation:cursor-blink 1.5s steps(2) infinite}@keyframes cursor-blink{0%{opacity:0}}.cim-widget-ul{list-style-type:disc;padding-left:1.5rem}.cim-widget-ol{list-style-type:decimal;padding-left:1.5rem}.cim-widget-table{width:100%;margin-top:1rem;margin-bottom:1rem;border-radius:.5rem;border:1px solid #8a8a8a;border-collapse:collapse}.cim-widget-thead{background-color:#f0f0f0;border-bottom-width:2px;border-color:#8a8a8a}.cim-widget-tr{border-bottom-width:1px;border-color:#8a8a8a}.cim-widget-th{padding:.5rem 1rem;text-align:left;font-weight:700;border-bottom-width:1px;border-color:#8a8a8a}.cim-widget-td{padding:.5rem 1rem;border-bottom-width:1px;border-color:#8a8a8a}.cim-widget-message-container pre{margin:0}.cim-widget-progress-message.embedded,.cim-widget-progress-message.standalone{display:flex;align-items:center}.cim-widget-progress-text.embedded{font-size:.85rem;font-style:italic;color:color-mix(in hsl decreasing hue,var(--cim-widget-font-color) 80%,white);line-height:1rem;line-clamp:3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.cim-widget-progress-text.standalone{font-size:inherit;font-style:italic;color:color-mix(in hsl decreasing hue,var(--cim-widget-font-color) 85%,white)}.cim-widget-thought-container{padding-left:.5rem;margin:.5rem;border-left:2px solid var(--cim-widget-primary-color)}p.cim-widget-progress-thought{margin-bottom:1rem;color:color-mix(in hsl decreasing hue,var(--cim-widget-font-color) 70%,white);line-height:1;font-size:.875rem}.cim-widget-thought-context-button{display:inline-flex;align-items:center;justify-content:space-between;padding:.25rem;min-width:84px;background-color:transparent;border-color:transparent;color:var(--cim-widget-primary-color);font-weight:700;cursor:pointer;&:hover{background-color:color-mix(in hsl decreasing hue,var(--cim-widget-primary-color) 5%,transparent);color:color-mix(in hsl decreasing hue,var(--cim-widget-primary-color) 85%,black)}}.cim-widget-message-icon.progress-icon.embedded{color:color-mix(in hsl decreasing hue,var(--cim-widget-font-color) 50%,white)}.cim-widget-refined-search{display:flex;flex-direction:column}.cim-widget-refined-search-query{display:inline-flex;align-items:center;color:var(--cim-widget-secondary-color)}.cim-widget-message-icon.refined-search-icon{font-size:1.5rem;&.embedded,&.standalone{color:var(--cim-widget-primary-color)}}.cim-widget-user-message{display:flex;align-items:center}.cim-widget-user-message.embedded{display:inline-flex;align-self:flex-end;border-radius:8px;padding:.5rem 1rem;background-color:color-mix(in hsl decreasing hue,var(--cim-widget-primary-color) 10%,transparent);max-width:80%;min-width:30%}.cim-widget-user-message.standalone{margin:.5rem 0}.cim-widget-user-message-text{font-weight:700;margin-bottom:.5rem}.cim-widget-message-icon.user-message-icon{margin-right:.5rem}.cim-widget-message-icon.user-message-icon.embedded{color:var(--cim-widget-primary-color)}.cim-widget-user-search{display:flex}.cim-widget-user-search.embedded{display:inline-flex;align-self:flex-end;border-radius:8px;padding:.5rem 1rem;background-color:color-mix(in hsl decreasing hue,var(--cim-widget-primary-color) 10%,transparent);max-width:80%;min-width:30%;gap:4px}.cim-widget-user-search.standalone{flex-direction:column;padding-top:.5rem;padding-bottom:.5rem}.cim-widget-user-search-query{display:inline-flex}.cim-widget-message-icon.user-search-icon.embedded,.cim-widget-message-icon.user-search-icon.standalone{font-size:1.5rem;color:var(--cim-widget-primary-color)}.cim-widget-user-search-facet-filters{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:.25rem}.cim-widget-user-search-facets{display:flex;flex-direction:column;padding:.25rem}.cim-widget-facet-pill{display:inline-flex;align-items:center;margin-left:4px;padding:.25rem .5rem;color:var(--cim-widget-primary-color);border-radius:9999px;font-size:.75rem;font-weight:700;&.embedded{background-color:#ffffff90}&.standalone{background-color:color-mix(in hsl decreasing hue,var(--cim-widget-primary-color) 5%,transparent)}}.cim-widget-user-search-facet-category{font-size:.875rem;font-weight:700;word-wrap:break-word}.cim-widget-user-search-facet-values{font-size:.675rem}.message{border-radius:.5rem}.widget-message{display:flex;align-self:flex-start}.user-message{display:flex;align-self:flex-end;padding:1rem}.cim-widget-message-group,.cim-widget-message{display:flex;flex-direction:column}.cim-widget-message-group{gap:.5rem;padding:1rem;margin-bottom:1rem;border-radius:8px;&.standalone{padding:0 1rem}.cim-widget-message-group-child{max-width:100%;margin-bottom:.25rem}}.cim-widget-message-group.embedded{max-width:80%;background-color:color-mix(in hsl decreasing hue,var(--cim-widget-secondary-color) 5%,transparent)}.cim-widget-message{margin-bottom:1rem}.cim-widget-message.standalone{border-radius:0;background-color:transparent;padding:0 1rem}.cim-widget-message.embedded{margin-bottom:1rem}.cim-widget-embedded-chat{width:100%;height:100%;margin:0 auto;border-radius:8px;border:1px solid var(--cim-widget-border-color)}.cim-widget-embedded-chat>.cim-widget-message-container{padding-left:1rem;padding-right:1rem}.cim-widget-dialog{position:fixed;width:35dvw;height:55dvh;padding:1rem;border-radius:.5rem;border:1px solid var(--cim-widget-border-color);font-size:.875rem;&.bottom-left{bottom:.5rem;left:.5rem}&.bottom-right{bottom:.5rem;right:.5rem}}.cim-widget-dialog-content{display:flex;flex-direction:column;height:100%}.cim-widget-dialog-header{display:inline-flex;align-items:center;width:100%;margin-bottom:.5rem;gap:8px}.cim-widget-dialog-controls{position:absolute;top:4px;right:4px;display:inline-flex;align-items:center}.cim-widget-dialog-logo{object-fit:contain;max-width:50%;max-height:3rem}.cim-widget-dialog-title{margin-top:0;margin-bottom:0}@media (576px <= width <= 768px){.cim-widget-dialog{width:50%;border-radius:0}}@media (max-width: 576px){.cim-widget-dialog{height:100%;width:100%;border-radius:0;&.bottom-left{bottom:0;left:0}&.bottom-right{bottom:0;right:0}}}.cim-widget-modal-container{display:flex;align-items:center;justify-content:center;position:fixed;top:0;left:0;height:100dvh;width:100dvw}.cim-widget-modal-backdrop{position:absolute;top:0;left:0;height:100%;width:100%;background:#00000080}.cim-widget-modal{position:fixed;width:70dvw;height:80dvh;padding:1rem;border-radius:.5rem;border:1px solid var(--cim-widget-border-color);overflow-y:hidden;&.fullscreen{height:100%;width:100%;border-radius:0}}.cim-widget-modal-content{display:flex;flex-direction:column;height:100%}.cim-widget-modal-header{display:inline-flex;align-items:center;width:100%;margin-bottom:1rem;gap:8px}.cim-widget-modal-controls{position:absolute;top:4px;right:4px;display:inline-flex;align-items:center}.cim-widget-modal-logo{object-fit:contain;max-width:50%;max-height:3rem}.cim-widget-modal-title{margin-top:0;margin-bottom:0}@media (max-width: 576px){.cim-widget-modal{height:100%;width:100%;border-radius:0}}.cim-widget-container{box-sizing:border-box;display:flex;flex-direction:column;background-color:var(--cim-widget-background-color);font-family:var(--cim-widget-font-family, inherit);color:var(--cim-widget-font-color, inherit)}.cim-widget-message-container p{margin:.25rem 0;padding:0;+p{margin-top:.5rem}}.cim-widget-message-container span{line-height:1}.cim-widget-header{font-weight:700;color:inherit}.cim-widget-header.h1{margin-top:2rem;margin-bottom:2rem;font-size:2rem}.cim-widget-header.h2{margin-top:1.5rem;margin-bottom:1.5rem;font-size:1.5rem}.cim-widget-header.h3{margin-top:1rem;margin-bottom:1rem;font-size:1.2rem}.cim-widget-link{color:var(--cim-widget-primary-color);text-decoration:underline;cursor:pointer}.cim-widget-link:hover{color:var(--cim-widget-secondary-color);text-decoration:none}.cim-widget-text{line-height:1.5;color:inherit;margin-bottom:.25rem}.cim-widget-text.italic{font-style:italic}.cim-widget-text.bold{font-weight:700}.cim-widget-message-container{flex:1;overflow-y:auto;padding:1rem 0}.cim-widget-message-icon{display:inline-flex;align-items:center;margin-right:.25rem}.cim-widget-message-icon.embedded{font-size:1rem;color:var(--cim-widget-secondary-color)}.cim-widget-message-icon.standalone{font-size:1.5rem;color:var(--cim-widget-primary-color)}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { ConnectAck } from '@cimulate/copilot-sdk';
|
|
2
|
+
import { DialogPosition } from './models';
|
|
3
|
+
import { FacetFilters } from './models';
|
|
4
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
|
+
import { SearchPayload as SearchPayload_2 } from './models';
|
|
7
|
+
import { SocketSdkContextType } from './SocketSdkContext';
|
|
8
|
+
|
|
9
|
+
declare type CimCopilotSdkConfig = {
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
apiToken?: string;
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export declare type ComponentType = "chat" | "dialog" | "modal";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This component is the compact version of the Copilot Modal component.
|
|
19
|
+
* Unlike the Modal, the Dialog does not have a backdrop and permits user interaction
|
|
20
|
+
* on the main page.
|
|
21
|
+
*/
|
|
22
|
+
export declare const CopilotDialog: () => JSX_2.Element | null;
|
|
23
|
+
|
|
24
|
+
export declare const CopilotEmbed: () => JSX_2.Element | null;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* This component is the expanded version of the Copilot Dialog component.
|
|
28
|
+
* Unlike the Dialog, the Modal has a backdrop that blocks user interaction
|
|
29
|
+
* on the main page and will toggle the Modal off when clicked.
|
|
30
|
+
*/
|
|
31
|
+
export declare const CopilotModal: () => JSX_2.Element | null;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A fully self-contained Copilot widget component.
|
|
35
|
+
* This component includes all necessary context providers and UI components.
|
|
36
|
+
* Its behaviors can be controlled via events.
|
|
37
|
+
*
|
|
38
|
+
* @param {CopilotWidgetProps} props - Properties for the Copilot widget
|
|
39
|
+
* @returns JSX.Element
|
|
40
|
+
*/
|
|
41
|
+
export declare const CopilotWidget: (props: CopilotWidgetProps) => JSX_2.Element;
|
|
42
|
+
|
|
43
|
+
export declare interface CopilotWidgetProps extends CimCopilotSdkConfig {
|
|
44
|
+
isDevelopment?: boolean;
|
|
45
|
+
globalClassName?: string;
|
|
46
|
+
logoUrl?: string;
|
|
47
|
+
headerText?: string;
|
|
48
|
+
theme?: ThemeConfig;
|
|
49
|
+
onConnect?: (event: ConnectAck) => void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export declare const eventHandlers: {
|
|
53
|
+
search: {
|
|
54
|
+
setSearchContext: (context: SearchPayload_2["searchParams"]) => void;
|
|
55
|
+
updateSearchQuery: (query: string) => void;
|
|
56
|
+
updateFacetFilter: (field: string, value: string) => void;
|
|
57
|
+
updateFacetFilters: (facetFilters: FacetFilters) => void;
|
|
58
|
+
updateRangeFilter: ({ field, value }: {
|
|
59
|
+
field: string;
|
|
60
|
+
value: [number, number];
|
|
61
|
+
}) => void;
|
|
62
|
+
updateRangeFilters: (rangeFilters: {
|
|
63
|
+
field: string;
|
|
64
|
+
min: number;
|
|
65
|
+
max: number;
|
|
66
|
+
}[]) => void;
|
|
67
|
+
updateCatalogSegment: (segment: string | null) => void;
|
|
68
|
+
};
|
|
69
|
+
components: {
|
|
70
|
+
toggleWidgetOpen: (isOpen: boolean) => void;
|
|
71
|
+
toggleModalFullscreen: (isFullscreen: boolean) => void;
|
|
72
|
+
setWidgetType: (type: "chat" | "dialog" | "modal") => void;
|
|
73
|
+
setWidgetDialogPosition: (position: DialogPosition) => void;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
declare type FacetFilters_2 = Record<string, string[]>;
|
|
78
|
+
|
|
79
|
+
export declare const injectCopilotWidget: ({ timeout, elementId, ...props }: CopilotWidgetProps & {
|
|
80
|
+
timeout?: number;
|
|
81
|
+
elementId: string;
|
|
82
|
+
}) => void;
|
|
83
|
+
|
|
84
|
+
declare type RangeFilters = Array<{
|
|
85
|
+
field: string;
|
|
86
|
+
min: number;
|
|
87
|
+
max: number;
|
|
88
|
+
}>;
|
|
89
|
+
|
|
90
|
+
export declare interface SearchPayload {
|
|
91
|
+
userPrompt?: string;
|
|
92
|
+
searchParams: {
|
|
93
|
+
query: string;
|
|
94
|
+
facetFilters?: FacetFilters_2;
|
|
95
|
+
rangeFilters?: RangeFilters;
|
|
96
|
+
catalogSegment?: string | null;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare interface ThemeConfig {
|
|
101
|
+
primaryColor?: string;
|
|
102
|
+
secondaryColor?: string;
|
|
103
|
+
fontColor?: string;
|
|
104
|
+
fontFamily?: string;
|
|
105
|
+
backgroundColor?: string;
|
|
106
|
+
borderColor?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export declare const useCopilot: () => SocketSdkContextType;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Contains all of the context providers needed for the widget.
|
|
113
|
+
*
|
|
114
|
+
* Config >
|
|
115
|
+
* ApiService >
|
|
116
|
+
* SearchContext >
|
|
117
|
+
* UIStateContext >
|
|
118
|
+
* CopilotState (redux state) >
|
|
119
|
+
* CopilotDispatch (redux dispatch) >
|
|
120
|
+
* SocketSdk (copilot-sdk)
|
|
121
|
+
*/
|
|
122
|
+
export declare const WidgetProvider: ({ apiKey, apiToken, baseUrl, logoUrl, headerText, isDevelopment, onConnect, children, }: CopilotWidgetProps & {
|
|
123
|
+
children: ReactNode;
|
|
124
|
+
}) => JSX_2.Element;
|
|
125
|
+
|
|
126
|
+
export { }
|