@bikdotai/bik-component-library 0.0.777-beta.18 → 0.0.777-beta.2
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/dist/cjs/components/TablePagination/TablePagination.d.ts +1 -0
- package/dist/cjs/components/TablePagination/TablePagination.js +1 -1
- package/dist/cjs/components/WhatsAppTextEditor/CustomEditor.styled.d.ts +0 -13
- package/dist/cjs/components/WhatsAppTextEditor/CustomEditor.styled.js +1 -1
- package/dist/cjs/components/WhatsAppTextEditor/WhatsAppTextEditor.d.ts +3 -126
- package/dist/cjs/components/WhatsAppTextEditor/WhatsAppTextEditor.js +1 -5
- package/dist/cjs/components/WhatsAppTextEditor/WhatsAppTextEditorHeader.d.ts +1 -42
- package/dist/cjs/components/WhatsAppTextEditor/WhatsAppTextEditorHeader.js +1 -1
- package/dist/cjs/components/alerts/Alert.styled.js +0 -1
- package/dist/cjs/components/feature-announcements/MajorUpdatePopup.js +1 -1
- package/dist/cjs/components/feature-announcements/MinorUpdatePopup.js +1 -1
- package/dist/cjs/components/multi-level-dropdown/GroupedMenuList.d.ts +0 -4
- package/dist/cjs/components/multi-level-dropdown/GroupedMenuList.js +1 -1
- package/dist/cjs/components/multi-level-dropdown/MenuItem.d.ts +0 -3
- package/dist/cjs/components/multi-level-dropdown/MenuItem.js +1 -1
- package/dist/cjs/components/multi-level-dropdown/MenuList.d.ts +0 -4
- package/dist/cjs/components/multi-level-dropdown/MenuList.js +1 -1
- package/dist/cjs/components/multi-level-dropdown/MultiLevelDropdown.js +1 -1
- package/dist/cjs/components/multi-level-dropdown/type.d.ts +0 -3
- package/dist/cjs/components/radioButton/RadioButton.d.ts +0 -1
- package/dist/cjs/components/radioButton/RadioButton.js +1 -1
- package/dist/cjs/components/tag/Tag.d.ts +1 -1
- package/dist/cjs/components/tag/Tag.js +1 -1
- package/dist/cjs/components/tag/Tag.stories.d.ts +5 -5
- package/dist/cjs/components/tag/Tag.styled.d.ts +0 -3
- package/dist/cjs/components/tag/Tag.styled.js +1 -1
- package/dist/cjs/components/tag/model.d.ts +0 -15
- package/dist/cjs/components/template-preview/TemplatePreview.js +1 -1
- package/dist/cjs/helpers/BaseWhatsappContentLang.helper.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/esm/components/TablePagination/TablePagination.d.ts +1 -0
- package/dist/esm/components/TablePagination/TablePagination.js +1 -1
- package/dist/esm/components/WhatsAppTextEditor/CustomEditor.styled.d.ts +0 -13
- package/dist/esm/components/WhatsAppTextEditor/CustomEditor.styled.js +1 -1
- package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditor.d.ts +3 -126
- package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditor.js +1 -5
- package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditorHeader.d.ts +1 -42
- package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditorHeader.js +1 -1
- package/dist/esm/components/alerts/Alert.styled.js +8 -9
- package/dist/esm/components/feature-announcements/MajorUpdatePopup.js +1 -1
- package/dist/esm/components/feature-announcements/MinorUpdatePopup.js +1 -1
- package/dist/esm/components/multi-level-dropdown/GroupedMenuList.d.ts +0 -4
- package/dist/esm/components/multi-level-dropdown/GroupedMenuList.js +1 -1
- package/dist/esm/components/multi-level-dropdown/MenuItem.d.ts +0 -3
- package/dist/esm/components/multi-level-dropdown/MenuItem.js +1 -1
- package/dist/esm/components/multi-level-dropdown/MenuList.d.ts +0 -4
- package/dist/esm/components/multi-level-dropdown/MenuList.js +1 -1
- package/dist/esm/components/multi-level-dropdown/MultiLevelDropdown.js +1 -1
- package/dist/esm/components/multi-level-dropdown/type.d.ts +0 -3
- package/dist/esm/components/radioButton/RadioButton.d.ts +0 -1
- package/dist/esm/components/radioButton/RadioButton.js +1 -1
- package/dist/esm/components/tag/Tag.d.ts +1 -1
- package/dist/esm/components/tag/Tag.js +1 -1
- package/dist/esm/components/tag/Tag.stories.d.ts +5 -5
- package/dist/esm/components/tag/Tag.styled.d.ts +0 -3
- package/dist/esm/components/tag/Tag.styled.js +1 -1
- package/dist/esm/components/tag/model.d.ts +0 -15
- package/dist/esm/components/template-preview/TemplatePreview.js +1 -1
- package/dist/esm/helpers/BaseWhatsappContentLang.helper.js +1 -1
- package/dist/esm/index.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/assets/icons/magic-line.svg.js +0 -1
- package/dist/cjs/assets/icons/rewind.svg.js +0 -1
- package/dist/cjs/assets/icons/thumbs_down.svg.js +0 -1
- package/dist/cjs/assets/icons/thumbs_up.svg.js +0 -1
- package/dist/cjs/components/WhatsAppTextEditor/AIRephrase.styled.d.ts +0 -10
- package/dist/cjs/components/WhatsAppTextEditor/AIRephrase.styled.js +0 -1
- package/dist/cjs/components/WhatsAppTextEditor/AIRephraseButton.d.ts +0 -17
- package/dist/cjs/components/WhatsAppTextEditor/AIRephraseButton.js +0 -1
- package/dist/cjs/components/WhatsAppTextEditor/BorderAnimation.d.ts +0 -11
- package/dist/cjs/components/WhatsAppTextEditor/BorderAnimation.js +0 -1
- package/dist/cjs/components/WhatsAppTextEditor/ai/actionRegistry.d.ts +0 -14
- package/dist/cjs/components/WhatsAppTextEditor/ai/actionRegistry.js +0 -1
- package/dist/cjs/components/WhatsAppTextEditor/ai/aiTag.d.ts +0 -58
- package/dist/cjs/components/WhatsAppTextEditor/ai/aiTag.js +0 -1
- package/dist/cjs/components/WhatsAppTextEditor/ai/api.d.ts +0 -22
- package/dist/cjs/components/WhatsAppTextEditor/ai/api.js +0 -1
- package/dist/esm/assets/icons/magic-line.svg.js +0 -1
- package/dist/esm/assets/icons/rewind.svg.js +0 -1
- package/dist/esm/assets/icons/thumbs_down.svg.js +0 -1
- package/dist/esm/assets/icons/thumbs_up.svg.js +0 -1
- package/dist/esm/components/WhatsAppTextEditor/AIRephrase.styled.d.ts +0 -10
- package/dist/esm/components/WhatsAppTextEditor/AIRephrase.styled.js +0 -1
- package/dist/esm/components/WhatsAppTextEditor/AIRephraseButton.d.ts +0 -17
- package/dist/esm/components/WhatsAppTextEditor/AIRephraseButton.js +0 -1
- package/dist/esm/components/WhatsAppTextEditor/BorderAnimation.d.ts +0 -11
- package/dist/esm/components/WhatsAppTextEditor/BorderAnimation.js +0 -1
- package/dist/esm/components/WhatsAppTextEditor/ai/actionRegistry.d.ts +0 -14
- package/dist/esm/components/WhatsAppTextEditor/ai/actionRegistry.js +0 -1
- package/dist/esm/components/WhatsAppTextEditor/ai/aiTag.d.ts +0 -58
- package/dist/esm/components/WhatsAppTextEditor/ai/aiTag.js +0 -1
- package/dist/esm/components/WhatsAppTextEditor/ai/api.d.ts +0 -22
- package/dist/esm/components/WhatsAppTextEditor/ai/api.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{useState as e,useEffect as t}from"react";import{BorderAnimationContainer as o}from"./AIRephrase.styled.js";const n=5e3,i=16,s=2,a=a=>{let{children:d,showAnimation:l,disabled:u=!1,onAnimationStart:c,borderRadius:m=12,borderSize:b=2}=a;const[f,h]=e(0);return t((()=>{if(!l||u)return;null==c||c();const r=setInterval((()=>{h((r=>(r+s)%360))}),i);return()=>clearInterval(r)}),[l,u,c]),t((()=>{if(!l||u)return;const r=setTimeout((()=>{h(0)}),n);return()=>clearTimeout(r)}),[l,u]),r(o,Object.assign({rotation:f,show:l,borderRadius:m,borderSize:b},{children:d}))};export{a as default};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type AIActionToneOption, type AIEditorActionType } from '../WhatsAppTextEditorHeader';
|
|
2
|
-
export type TemplateType = 'marketing' | 'utility' | string;
|
|
3
|
-
export type AIActionPromptConfig = {
|
|
4
|
-
label: string;
|
|
5
|
-
basePrompt: string;
|
|
6
|
-
defaultToneId?: string;
|
|
7
|
-
tones?: AIActionToneOption[];
|
|
8
|
-
tonePromptFragments?: Record<string, string>;
|
|
9
|
-
};
|
|
10
|
-
export type AIActionPromptRegistry = Partial<Record<AIEditorActionType, AIActionPromptConfig>>;
|
|
11
|
-
export declare const DEFAULT_TONES: AIActionToneOption[];
|
|
12
|
-
export declare const DEFAULT_INSTRUCTION_SUGGESTIONS: string[];
|
|
13
|
-
export declare const DEFAULT_AI_ACTION_MIN_CHARS: Record<AIEditorActionType, number>;
|
|
14
|
-
export declare function resolveActionPrompts(templateType: TemplateType, promptOverrides?: AIActionPromptRegistry, rephraseTones?: AIActionToneOption[]): Record<AIEditorActionType, AIActionPromptConfig>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{AIEditorActionTypes as e}from"../WhatsAppTextEditorHeader.js";const a=[{id:"professional",label:"Professional🙂"},{id:"simple",label:"Simple😉"},{id:"friendly",label:"Friendly😁"},{id:"empathetic",label:"Empathetic☺️"}],i=["Create a high-conversion campaign message","Write an engaging campaign message","Write a short marketing message"],s={[e.REPHRASE]:50,[e.SHORTEN]:50,[e.EXPAND]:50,[e.EMOJIFY]:50},t={[e.REPHRASE]:{label:"Rephrase",basePrompt:"Rephrase this WhatsApp marketing message while preserving intent, variables, and compliance.",defaultToneId:"professional",tones:a,tonePromptFragments:{professional:"Use a professional and trustworthy tone.",simple:"Use simple, short, clear language.",friendly:"Use a friendly and approachable tone.",empathetic:"Use an empathetic and supportive tone."}},[e.SHORTEN]:{label:"Shorten",basePrompt:"Shorten this WhatsApp message while preserving variables, key intent, and compliance."},[e.EXPAND]:{label:"Expand",basePrompt:"Expand this WhatsApp message with stronger clarity while preserving variables and compliance."},[e.EMOJIFY]:{label:"Emojify",basePrompt:"Add relevant emojis to this WhatsApp message without changing meaning, variables, or compliance."}},n=Object.assign(Object.assign({},t),{[e.REPHRASE]:Object.assign(Object.assign({},t[e.REPHRASE]),{label:"Meta safe rewrite",basePrompt:"Rewrite this WhatsApp utility template to be Meta-safe, policy-compliant, and clear while preserving variables, intent, and factual meaning. Avoid prohibited claims, misleading urgency, spammy language, and policy-risk wording."})});function l(a,i,s){const l="utility"===a?n:t,r={[e.REPHRASE]:Object.assign(Object.assign({},l[e.REPHRASE]),null==i?void 0:i[e.REPHRASE]),[e.SHORTEN]:Object.assign(Object.assign({},l[e.SHORTEN]),null==i?void 0:i[e.SHORTEN]),[e.EXPAND]:Object.assign(Object.assign({},l[e.EXPAND]),null==i?void 0:i[e.EXPAND]),[e.EMOJIFY]:Object.assign(Object.assign({},l[e.EMOJIFY]),null==i?void 0:i[e.EMOJIFY])};return(null==s?void 0:s.length)&&(r[e.REPHRASE].tones=s),r}export{s as DEFAULT_AI_ACTION_MIN_CHARS,i as DEFAULT_INSTRUCTION_SUGGESTIONS,a as DEFAULT_TONES,l as resolveActionPrompts};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AI template tag: show only when the edit distance between what the user had
|
|
3
|
-
* (baseline) and what they accepted is at least half of the longer of the two strings.
|
|
4
|
-
*
|
|
5
|
-
* **Wiring:** `WhatsAppTextEditor` calls `onAITagComputed` with this result when the user
|
|
6
|
-
* Accepts a suggestion — the editor does not return the tag from `ref.get()`. Host apps
|
|
7
|
-
* should store `isAiTagged` (and optional full payload) in their own state and send it on
|
|
8
|
-
* save. See `MERCHANT_ADMIN_REACT_INTEGRATION.md` → “AI tag — where it comes from…”.
|
|
9
|
-
*/
|
|
10
|
-
export declare const AI_TAG_CHANGE_RATIO_THRESHOLD = 0.5;
|
|
11
|
-
export type AITagPayload = {
|
|
12
|
-
changedCharacters: number;
|
|
13
|
-
templateLength: number;
|
|
14
|
-
changePercent: number;
|
|
15
|
-
/** True when changedCharacters / templateLength >= {@link AI_TAG_CHANGE_RATIO_THRESHOLD} */
|
|
16
|
-
isAiTagged: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* True when this accept occurred during the “initial AI prefill” phase: the host
|
|
19
|
-
* indicated the editor was loaded with a fully AI-generated body, and this is the
|
|
20
|
-
* first accepted suggestion since load. After this accept, normal baseline-vs-accepted
|
|
21
|
-
* tracking applies.
|
|
22
|
-
*/
|
|
23
|
-
initialAiPrefillPhase: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Source of AI tag computation.
|
|
26
|
-
* - `accept`: emitted when user accepts AI suggestion.
|
|
27
|
-
* - `post_edit_debounce`: emitted after user edits accepted text and stops typing briefly.
|
|
28
|
-
*/
|
|
29
|
-
source?: 'accept' | 'post_edit_debounce';
|
|
30
|
-
};
|
|
31
|
-
export type ComputeAiTagOnAcceptInput = {
|
|
32
|
-
baselineText: string;
|
|
33
|
-
acceptedText: string;
|
|
34
|
-
/**
|
|
35
|
-
* Whether the editor is still in the first-accept cycle after a full-AI prefill.
|
|
36
|
-
* Caller sets this from ref/state; the function copies it onto the payload and does
|
|
37
|
-
* not mutate it.
|
|
38
|
-
*/
|
|
39
|
-
initialAiPrefillPhase: boolean;
|
|
40
|
-
};
|
|
41
|
-
export type ComputeAiTagOnPostEditInput = {
|
|
42
|
-
acceptedAiText: string;
|
|
43
|
-
currentEditedText: string;
|
|
44
|
-
};
|
|
45
|
-
/** Levenshtein distance (minimum single-character edits). */
|
|
46
|
-
export declare function levenshteinDistance(a: string, b: string): number;
|
|
47
|
-
/**
|
|
48
|
-
* Computes AI tag eligibility when the user accepts an AI suggestion.
|
|
49
|
-
* Tag applies only if changed characters (edit distance) are >= 50% of template length
|
|
50
|
-
* (max of baseline and accepted lengths).
|
|
51
|
-
*/
|
|
52
|
-
export declare function computeAiTagOnAccept(input: ComputeAiTagOnAcceptInput): AITagPayload;
|
|
53
|
-
/**
|
|
54
|
-
* Computes AI tag after user edits an accepted AI suggestion.
|
|
55
|
-
* For post-edit flow, we still apply the same tag rule:
|
|
56
|
-
* changedCharacters / templateLength >= AI_TAG_CHANGE_RATIO_THRESHOLD => AI-tagged.
|
|
57
|
-
*/
|
|
58
|
-
export declare function computeAiTagOnPostEdit(input: ComputeAiTagOnPostEditInput): AITagPayload;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=.5;function t(e,t){const n=e.length,a=t.length,i=Array(a+1).fill(0).map(((e,t)=>t));for(let l=1;l<=n;l++){let n=i[0];i[0]=l;for(let r=1;r<=a;r++){const a=i[r];e[l-1]===t[r-1]?i[r]=n:i[r]=Math.min(i[r-1],i[r],n)+1,n=a}}return i[a]}function n(e){const{baselineText:n,acceptedText:a,initialAiPrefillPhase:i}=e,l=t(n,a),r=Math.max(n.length,a.length,1),c=l/r;return{changedCharacters:l,templateLength:r,changePercent:c,isAiTagged:c>=.5,initialAiPrefillPhase:i}}function a(e){const{acceptedAiText:n,currentEditedText:a}=e,i=t(n,a),l=Math.max(n.length,a.length,1),r=i/l;return{changedCharacters:i,templateLength:l,changePercent:r,isAiTagged:r>=.5,initialAiPrefillPhase:!1}}export{e as AI_TAG_CHANGE_RATIO_THRESHOLD,n as computeAiTagOnAccept,a as computeAiTagOnPostEdit,t as levenshteinDistance};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { ApiRequestExecutor } from '../../bik-chatbot/types';
|
|
2
|
-
import type { APIAdapter } from '../../bik-chatbot/types/ai';
|
|
3
|
-
import type { AIActionPromptConfig } from './actionRegistry';
|
|
4
|
-
export declare function buildActionPrompt(args: {
|
|
5
|
-
config: AIActionPromptConfig;
|
|
6
|
-
currentText: string;
|
|
7
|
-
selectedToneId?: string;
|
|
8
|
-
instructionText?: string;
|
|
9
|
-
}): string;
|
|
10
|
-
export declare function extractBodyFromAIResponse(rawResponse: string): string;
|
|
11
|
-
export declare function requestAISuggestion(args: {
|
|
12
|
-
apiAdapter?: APIAdapter;
|
|
13
|
-
requestExecutor?: ApiRequestExecutor;
|
|
14
|
-
baseUrl?: string;
|
|
15
|
-
endpointPath?: string;
|
|
16
|
-
prompt: string;
|
|
17
|
-
intent: string;
|
|
18
|
-
conversationId: string;
|
|
19
|
-
systemId: string;
|
|
20
|
-
useCase?: string;
|
|
21
|
-
storeId?: string;
|
|
22
|
-
}): Promise<string>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{__awaiter as t}from"../../../_virtual/_tslib.js";import{callToChatbot as o,createExecutorApiAdapter as r}from"../../bik-chatbot/services/callToChatbot.js";function i(t){var o;const{config:r,currentText:i,selectedToneId:e,instructionText:n}=t,s=e&&(null===(o=r.tonePromptFragments)||void 0===o?void 0:o[e])||"";return[r.basePrompt,s,n?`Additional instruction: ${n}`:"",`Current message:\n${i}`,'Return only valid JSON with format: {"body":"..."}'].filter(Boolean).join("\n\n")}function e(t){const o=(t||"").trim();if(!o)return"";const r=o.replace(/^```json\s*/i,"").replace(/^```\s*/i,"").replace(/\s*```$/i,"").trim();try{const t=JSON.parse(r);if("string"==typeof(null==t?void 0:t.body))return t.body.trim()}catch(t){}const i=r.match(/"body"\s*:\s*"([\s\S]*?)"/i);return(null==i?void 0:i[1])?i[1].replace(/\\"/g,'"').replace(/\\n/g,"\n").replace(/\\t/g,"\t").trim():r}function n(i){return t(this,void 0,void 0,(function*(){const{apiAdapter:t,requestExecutor:n,baseUrl:s,endpointPath:a,prompt:c,intent:l,conversationId:d,systemId:u,useCase:p,storeId:m}=i,v=t||(n&&s?r(n,s,a||"/bik-ai/call-chatbot"):null);if(!v)throw new Error("AI adapter configuration is missing");return e((yield o([{role:"user",text:c}],l,d,u,v,void 0,void 0,void 0,void 0,void 0,void 0,p,m)).assistantText)}))}export{i as buildActionPrompt,e as extractBodyFromAIResponse,n as requestAISuggestion};
|