@dialstack/sdk-react 2.1.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/LICENSE +21 -0
- package/README.md +108 -0
- package/dist/ai-agent.cjs +2 -0
- package/dist/ai-agent.cjs.map +1 -0
- package/dist/ai-agent.d.cts +89 -0
- package/dist/ai-agent.d.ts +89 -0
- package/dist/ai-agent.mjs +2 -0
- package/dist/ai-agent.mjs.map +1 -0
- package/dist/call-history.cjs +2 -0
- package/dist/call-history.cjs.map +1 -0
- package/dist/call-history.d.cts +88 -0
- package/dist/call-history.d.ts +88 -0
- package/dist/call-history.mjs +2 -0
- package/dist/call-history.mjs.map +1 -0
- package/dist/call-logs.cjs +2 -0
- package/dist/call-logs.cjs.map +1 -0
- package/dist/call-logs.d.cts +104 -0
- package/dist/call-logs.d.ts +104 -0
- package/dist/call-logs.mjs +2 -0
- package/dist/call-logs.mjs.map +1 -0
- package/dist/dial-plan.cjs +2 -0
- package/dist/dial-plan.cjs.map +1 -0
- package/dist/dial-plan.d.cts +70 -0
- package/dist/dial-plan.d.ts +70 -0
- package/dist/dial-plan.mjs +2 -0
- package/dist/dial-plan.mjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +148 -0
- package/dist/index.d.ts +148 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/onboarding.cjs +2 -0
- package/dist/onboarding.cjs.map +1 -0
- package/dist/onboarding.d.cts +49 -0
- package/dist/onboarding.d.ts +49 -0
- package/dist/onboarding.mjs +2 -0
- package/dist/onboarding.mjs.map +1 -0
- package/dist/phone-number-ordering.cjs +2 -0
- package/dist/phone-number-ordering.cjs.map +1 -0
- package/dist/phone-number-ordering.d.cts +83 -0
- package/dist/phone-number-ordering.d.ts +83 -0
- package/dist/phone-number-ordering.mjs +2 -0
- package/dist/phone-number-ordering.mjs.map +1 -0
- package/dist/phone-numbers.cjs +2 -0
- package/dist/phone-numbers.cjs.map +1 -0
- package/dist/phone-numbers.d.cts +77 -0
- package/dist/phone-numbers.d.ts +77 -0
- package/dist/phone-numbers.mjs +2 -0
- package/dist/phone-numbers.mjs.map +1 -0
- package/dist/softphone.cjs +2 -0
- package/dist/softphone.cjs.map +1 -0
- package/dist/softphone.d.cts +610 -0
- package/dist/softphone.d.ts +610 -0
- package/dist/softphone.mjs +2 -0
- package/dist/softphone.mjs.map +1 -0
- package/dist/voicemails.cjs +2 -0
- package/dist/voicemails.cjs.map +1 -0
- package/dist/voicemails.d.cts +128 -0
- package/dist/voicemails.d.ts +128 -0
- package/dist/voicemails.mjs +2 -0
- package/dist/voicemails.mjs.map +1 -0
- package/package.json +192 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 DialStack
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# @dialstack/sdk-react
|
|
2
|
+
|
|
3
|
+
React components and hooks for the DialStack SDK — call logs, voicemails, call
|
|
4
|
+
history, phone numbers, number ordering, AI agent, the dial-plan editor, the
|
|
5
|
+
softphone and onboarding.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @dialstack/sdk-js @dialstack/sdk-react react react-dom
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Two of those need explaining.
|
|
14
|
+
|
|
15
|
+
**`@dialstack/sdk-js`** is a peer, not a dependency, the same way
|
|
16
|
+
`@stripe/react-connect-js` peers on `@stripe/connect-js`: you install both, and you
|
|
17
|
+
call the initializer yourself. npm 7+ installs a missing peer automatically, so in
|
|
18
|
+
practice this is one command.
|
|
19
|
+
|
|
20
|
+
**`@xyflow/react`** is a peer too, but only the dial-plan editor needs it. Install
|
|
21
|
+
it if you import `./dial-plan`:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @xyflow/react
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
It holds module-level state that must not be duplicated, which is why it resolves
|
|
28
|
+
to the one copy your app installs rather than a copy of ours.
|
|
29
|
+
|
|
30
|
+
You do **not** need to import any stylesheet. Components render into shadow roots
|
|
31
|
+
and carry the styles they need.
|
|
32
|
+
|
|
33
|
+
## One import path per component
|
|
34
|
+
|
|
35
|
+
Components are **not** exported from the package root. Each has its own subpath:
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { DialstackComponentsProvider } from '@dialstack/sdk-react';
|
|
39
|
+
import { CallLogs } from '@dialstack/sdk-react/call-logs';
|
|
40
|
+
import { Voicemails } from '@dialstack/sdk-react/voicemails';
|
|
41
|
+
|
|
42
|
+
<DialstackComponentsProvider dialstack={dialstack}>
|
|
43
|
+
<CallLogs />
|
|
44
|
+
<Voicemails userId={userId} />
|
|
45
|
+
</DialstackComponentsProvider>;
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
| Subpath | Exports |
|
|
49
|
+
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
50
|
+
| `@dialstack/sdk-react` | `DialstackComponentsProvider`, `useDialstack`, `useDialstackComponents`, `useCreateComponent`, `useAppearance`, `useUpdateWithSetter` |
|
|
51
|
+
| `./call-logs` | `CallLogs` |
|
|
52
|
+
| `./voicemails` | `Voicemails` |
|
|
53
|
+
| `./call-history` | `CallHistory` |
|
|
54
|
+
| `./phone-numbers` | `PhoneNumbers` |
|
|
55
|
+
| `./phone-number-ordering` | `PhoneNumberOrdering` |
|
|
56
|
+
| `./ai-agent` | `AIAgent`, the FAQ prefill helpers |
|
|
57
|
+
| `./dial-plan` | `DialPlan` and its types |
|
|
58
|
+
| `./softphone` | `SoftphoneProvider`, `Softphone`, the call hooks and UI primitives |
|
|
59
|
+
| `./onboarding` | `OnboardingPortal` |
|
|
60
|
+
|
|
61
|
+
**Why not a root barrel.** A barrel re-exporting every component makes the whole
|
|
62
|
+
module graph behind it reachable from any single import, so importing one thin
|
|
63
|
+
wrapper pulled in the dial-plan editor's `@xyflow/react`, `dagre` and `cmdk`
|
|
64
|
+
regardless. Measured: ~144 KB with all three, against ~58 KB for the softphone
|
|
65
|
+
alone and ~1.5 KB for an element wrapper when imported directly.
|
|
66
|
+
`sideEffects: false` cannot fix that — the code is genuinely reachable, not dead —
|
|
67
|
+
and neither does emitting per-module files. Splitting the entry point is the only
|
|
68
|
+
thing that works.
|
|
69
|
+
|
|
70
|
+
Every subpath resolves the same React context, so a provider your app renders is
|
|
71
|
+
visible to whatever it wraps.
|
|
72
|
+
|
|
73
|
+
## The softphone needs no initializer
|
|
74
|
+
|
|
75
|
+
It is the one component family that authenticates on its own — a short-lived
|
|
76
|
+
user-session token over a WebSocket, rather than the instance's client secret over
|
|
77
|
+
REST:
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { SoftphoneProvider, Softphone } from '@dialstack/sdk-react/softphone';
|
|
81
|
+
|
|
82
|
+
<SoftphoneProvider token={userSessionToken}>
|
|
83
|
+
<Softphone />
|
|
84
|
+
</SoftphoneProvider>;
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
No `loadDialstackAndInitialize`, no `<DialstackComponentsProvider>`. Passing an
|
|
88
|
+
instance is optional and only enables live appearance sync. Registration, dialling
|
|
89
|
+
and in-call control keep working when the REST API is unreachable, which is
|
|
90
|
+
deliberate.
|
|
91
|
+
|
|
92
|
+
## Everything else needs one
|
|
93
|
+
|
|
94
|
+
The remaining components read the REST API, so they need an initialized instance
|
|
95
|
+
above them — including `DialPlan`, which renders its own canvas rather than a web
|
|
96
|
+
component but is the heaviest consumer of the instance in the package.
|
|
97
|
+
|
|
98
|
+
If a component renders blank, that is what to check first. This package throws a
|
|
99
|
+
named error when the elements were never registered, which happens if
|
|
100
|
+
`@dialstack/sdk-js` is missing or your bundler dropped its side-effect imports.
|
|
101
|
+
|
|
102
|
+
## Documentation
|
|
103
|
+
|
|
104
|
+
Full documentation: <https://docs.dialstack.ai/sdks>
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
MIT
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("react"),t=require("@dialstack/sdk-react");function n(t,n){const s=e.useRef(null),[r,a]=e.useState(null);return{containerRef:e.useCallback(e=>{if(s.current&&s.current.parentNode&&(s.current.parentNode.removeChild(s.current),s.current=null,a(null)),!e)return;const r=t.create(n);try{!function(e,t){if(!e||"function"!=typeof e.setInstance)throw new Error(`<dialstack-${t}> was created but is not a registered custom element, so it would render nothing. Install @dialstack/sdk-js alongside @dialstack/sdk-react and import it once at your entry point — importing it is what registers the elements. On @dialstack/sdk-js/pure nothing registers on import: await registerComponents() before rendering. If it is installed, check that your bundler is not dropping its side effects.`)}(r,n)}catch(e){throw t.removeAppearanceTarget(r),e}try{r.setAttribute("data-dialstack-sdk-version",_NPM_PACKAGE_VERSION_)}catch(e){console.log("Error setting SDK version attribute:",e)}e.appendChild(r),s.current=r,a(r)},[t,n]),componentInstance:r}}const s=[],r="undefined"==typeof window?e.useEffect:e.useLayoutEffect;function a(e,t,n){r(()=>{if(e&&void 0!==t)try{n(e,t)}catch(e){console.error("DialStack: Error calling setter:",e)}},[e,t,n])}const o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function i(e){if(0===e.ranges.length)return"Please contact us for our current hours.";const t=new Map;for(const n of e.ranges)t.set(n.day,`${n.start} - ${n.end}`);const n=[];for(const[e,s]of[...t.entries()].sort((e,t)=>e[0]-t[0])){const t=n[n.length-1];t&&t.hours===s&&t.days[t.days.length-1]===e-1?t.days.push(e):n.push({days:[e],hours:s})}return n.map(e=>{var t,n,s,r,a;const i=null!==(t=e.days[0])&&void 0!==t?t:0,d=null!==(n=e.days[e.days.length-1])&&void 0!==n?n:i;return`${1===e.days.length?null!==(s=o[i])&&void 0!==s?s:`Day ${i}`:`${null!==(r=o[i])&&void 0!==r?r:`Day ${i}`} to ${null!==(a=o[d])&&void 0!==a?a:`Day ${d}`}`}: ${e.hours}`}).join("\n")}exports.AIAgent=({agentId:r,mode:o="edit",initialValues:i,secret:d,hideFields:l,onSaved:c,onCreateRequested:u,onSaveRequested:f,onCheckExtensionAvailability:h,onRotateSecretRequested:y,onCreated:g,onError:p,locale:v,className:m,style:k})=>{const{dialstack:E}=t.useDialstackComponents(),{containerRef:q,componentInstance:b}=n(E,"ai-agent"),w="create"===o||u||f?"host":"sdk";return a(b,o,(e,t)=>e.setMode(t)),a(b,w,(e,t)=>e.setSubmitMode(t)),a(b,i,(e,t)=>e.setInitialValues(t)),a(b,d,(e,t)=>e.setSecret(t)),a(b,u,(e,t)=>e.setOnCreateRequested(t)),a(b,f,(e,t)=>e.setOnSaveRequested(t)),a(b,h,(e,t)=>e.setOnCheckExtensionAvailability(t)),a(b,y,(e,t)=>e.setOnRotateSecretRequested(t)),a(b,r,(e,t)=>e.setAgentId(t)),a(b,null!=l?l:s,(e,t)=>e.setHideFields(t)),a(b,v,(e,t)=>e.setLocale(t)),e.useEffect(()=>{const e=b;if(!e)return;const t=e=>{const t=e.detail;null==c||c({id:t.agentId})},n=e=>{const t=e.detail;null==g||g(t)},s=e=>{const t=e.detail;null==p||p(t.error)};return e.addEventListener("dialstack:ai-agent:saved",t),e.addEventListener("dialstack:ai-agent:created",n),e.addEventListener("dialstack:ai-agent:error",s),()=>{e.removeEventListener("dialstack:ai-agent:saved",t),e.removeEventListener("dialstack:ai-agent:created",n),e.removeEventListener("dialstack:ai-agent:error",s)}},[b,c,g,p]),e.createElement("div",{ref:q,className:m,style:k})},exports.buildAIAgentPrefillFaq=function({locations:e,schedules:t,users:n}){const s=[],r=e[0];if(null==r?void 0:r.address){const e=r.address,t=e.formatted_address||[e.address_number,e.street,e.unit,e.city,e.state,e.postal_code].filter(Boolean).join(", ");t&&s.push({question:"What is your address?",answer:`We are located at ${t}.`})}const a=t[0];a&&s.push({question:"What are your business hours?",answer:i(a)});const o=n.map(e=>e.name).filter(e=>!!e);return o.length>0&&s.push({question:"Who are the members of your team?",answer:`Our team includes: ${o.join(", ")}.`}),s},exports.shouldApplyPrefillFaq=function({isCreate:e,prefillCount:t,faqDirty:n}){return e&&t>0&&!n};
|
|
2
|
+
//# sourceMappingURL=ai-agent.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-agent.cjs","sources":["../src/react/useCreateComponent.tsx","../src/react/AIAgent.tsx","../src/ai-agent/prefill-faq.ts"],"sourcesContent":[null,null,null],"names":["useCreateComponent","dialstack","tagName","componentRef","useRef","componentInstance","setComponentInstance","useState","containerRef","useCallback","container","current","parentNode","removeChild","component","create","element","setInstance","Error","assertUpgraded","err","removeAppearanceTarget","setAttribute","_NPM_PACKAGE_VERSION_","e","console","log","appendChild","EMPTY_HIDE_FIELDS","useIsomorphicLayoutEffect","window","useEffect","useLayoutEffect","useLayoutUpdateWithSetter","value","onUpdated","undefined","error","DAY_NAMES","formatScheduleAnswer","schedule","ranges","length","byDay","Map","r","set","day","start","end","groups","hours","entries","sort","a","b","last","days","push","map","g","firstDay","_a","lastDay","_b","_c","_d","_e","join","AIAgent","agentId","mode","initialValues","secret","hideFields","onSaved","onCreateRequested","onSaveRequested","onCheckExtensionAvailability","onRotateSecretRequested","onCreated","onError","locale","className","style","useDialstackComponents","submitMode","comp","val","setMode","setSubmitMode","setInitialValues","setSecret","setOnCreateRequested","setOnSaveRequested","setOnCheckExtensionAvailability","setOnRotateSecretRequested","setAgentId","setHideFields","setLocale","el","handleSaved","detail","id","handleCreated","handleError","addEventListener","removeEventListener","React","createElement","ref","locations","schedules","users","items","firstLocation","address","addr","formatted","formatted_address","address_number","street","unit","city","state","postal_code","filter","Boolean","question","answer","firstSchedule","names","u","name","isCreate","prefillCount","faqDirty"],"mappings":"sEAqEM,SAAUA,EACdC,EACAC,GAEA,MAAMC,EAAeC,EAAAA,OAAmC,OAEjDC,EAAmBC,GAAwBC,EAAAA,SAAqC,MA0CvF,MAAO,CACLC,aAxCmBC,EAAAA,YAClBC,IAQC,GANIP,EAAaQ,SAAWR,EAAaQ,QAAQC,aAC/CT,EAAaQ,QAAQC,WAAWC,YAAYV,EAAaQ,SACzDR,EAAaQ,QAAU,KACvBL,EAAqB,QAGlBI,EAAW,OAGhB,MAAMI,EAAYb,EAAUc,OAAOb,GACnC,KAvDN,SAAwBc,EAAkBd,GACxC,IAAIc,GAAyE,mBAAtDA,EAAsCC,YAG7D,MAAM,IAAIC,MACR,cAAchB,sZAOlB,CA4CQiB,CAAeL,EAAWZ,EAC5B,CAAE,MAAOkB,GAMP,MADAnB,EAAUoB,uBAAuBP,GAC3BM,CACR,CAGA,IACEN,EAAUQ,aAAa,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KyE,GAAMA,EAAEC,MAAMP,OAAQO,KAA2BA,GAQ1E,OAPIF,EAAMzF,OAAS,GACjBwE,EAAMxD,KAAK,CACTsE,SAAU,oCACVC,OAAQ,sBAAsBE,EAAM/D,KAAK,WAItC8C,CACT,gCAEM,UAAgCoB,SACpCA,EAAQC,aACRA,EAAYC,SACZA,IAMA,OAAOF,GAAYC,EAAe,IAAMC,CAC1C"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AIAgentFormValues, AIAgentField, AIAgentHostSubmitPayload, AIAgentHostCreateResult, AIAgentExtensionAvailabilityResult, Locale, FAQItem } from '@dialstack/sdk-js';
|
|
3
|
+
export { AIAgent as AIAgentData, AIAgentExtensionAvailabilityResult, AIAgentFormValues, AIAgentHostCreateResult, AIAgentHostSubmitPayload, FAQItem, UpdateAIAgentRequest } from '@dialstack/sdk-js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* AIAgent — thin React wrapper around the framework-agnostic
|
|
7
|
+
* `<dialstack-ai-agent>` Custom Element. Mirrors Voicemails.tsx /
|
|
8
|
+
* CallLogs.tsx: useCreateComponent instantiates the element and
|
|
9
|
+
* useUpdateWithSetter forwards each prop to its setter. `onSaved` /
|
|
10
|
+
* `onError` are wired via `addEventListener` on the element's
|
|
11
|
+
* `dialstack:ai-agent:saved` / `:error` events — the same path a non-React
|
|
12
|
+
* host would use — so the wrapper and a plain HTML drop-in stay in sync.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
interface AIAgentProps {
|
|
16
|
+
/** AI agent ID (`aia_…`) the host has resolved for the current account. */
|
|
17
|
+
agentId?: string;
|
|
18
|
+
/** Render an existing agent editor or a host-controlled create form. */
|
|
19
|
+
mode?: 'edit' | 'create';
|
|
20
|
+
/** Initial form values for host-controlled create/edit surfaces. */
|
|
21
|
+
initialValues?: AIAgentFormValues;
|
|
22
|
+
/** Host-provided webhook secret to display in full admin-style surfaces. */
|
|
23
|
+
secret?: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Fields the editor should not render. Spineline mounts with
|
|
26
|
+
* `hideFields={['name']}` because there is exactly one managed agent per
|
|
27
|
+
* practice and the back-office name is invisible to operators.
|
|
28
|
+
*/
|
|
29
|
+
hideFields?: AIAgentField[];
|
|
30
|
+
/** Optional callback invoked after a successful save. */
|
|
31
|
+
onSaved?: (agent: {
|
|
32
|
+
id: string;
|
|
33
|
+
}) => void;
|
|
34
|
+
/** Host-controlled create callback. When set, the component does not call the API itself. */
|
|
35
|
+
onCreateRequested?: (payload: AIAgentHostSubmitPayload) => AIAgentHostCreateResult | Promise<AIAgentHostCreateResult>;
|
|
36
|
+
/** Host-controlled save callback. When set, the component does not call the API itself. */
|
|
37
|
+
onSaveRequested?: (payload: AIAgentHostSubmitPayload) => void | Promise<void>;
|
|
38
|
+
/** Host-controlled extension availability callback for privileged extension surfaces. */
|
|
39
|
+
onCheckExtensionAvailability?: (extensionNumber: string) => AIAgentExtensionAvailabilityResult | Promise<AIAgentExtensionAvailabilityResult>;
|
|
40
|
+
/** Host-controlled secret rotation callback. */
|
|
41
|
+
onRotateSecretRequested?: () => void | Promise<void>;
|
|
42
|
+
/** Optional callback invoked after a successful host-controlled create. */
|
|
43
|
+
onCreated?: (agent: AIAgentHostCreateResult) => void;
|
|
44
|
+
/** Optional callback invoked when the load or save call rejects. */
|
|
45
|
+
onError?: (error: Error) => void;
|
|
46
|
+
/** Optional locale for translatable strings (labels, placeholders, errors). */
|
|
47
|
+
locale?: Locale;
|
|
48
|
+
/** Optional className applied to the container element. */
|
|
49
|
+
className?: string;
|
|
50
|
+
/** Optional inline styles applied to the container element. */
|
|
51
|
+
style?: React.CSSProperties;
|
|
52
|
+
}
|
|
53
|
+
declare const AIAgent: React.FC<AIAgentProps>;
|
|
54
|
+
|
|
55
|
+
interface TimeRange {
|
|
56
|
+
day: number;
|
|
57
|
+
start: string;
|
|
58
|
+
end: string;
|
|
59
|
+
}
|
|
60
|
+
interface ScheduleLike {
|
|
61
|
+
ranges: TimeRange[];
|
|
62
|
+
}
|
|
63
|
+
interface LocationLike {
|
|
64
|
+
address?: {
|
|
65
|
+
address_number?: string;
|
|
66
|
+
street?: string;
|
|
67
|
+
unit?: string;
|
|
68
|
+
city?: string;
|
|
69
|
+
state?: string;
|
|
70
|
+
postal_code?: string;
|
|
71
|
+
formatted_address?: string;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
interface UserLike {
|
|
75
|
+
name?: string | null;
|
|
76
|
+
}
|
|
77
|
+
declare function buildAIAgentPrefillFaq({ locations, schedules, users, }: {
|
|
78
|
+
locations: LocationLike[];
|
|
79
|
+
schedules: ScheduleLike[];
|
|
80
|
+
users: UserLike[];
|
|
81
|
+
}): FAQItem[];
|
|
82
|
+
declare function shouldApplyPrefillFaq({ isCreate, prefillCount, faqDirty, }: {
|
|
83
|
+
isCreate: boolean;
|
|
84
|
+
prefillCount: number;
|
|
85
|
+
faqDirty: boolean;
|
|
86
|
+
}): boolean;
|
|
87
|
+
|
|
88
|
+
export { AIAgent, buildAIAgentPrefillFaq, shouldApplyPrefillFaq };
|
|
89
|
+
export type { AIAgentProps };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AIAgentFormValues, AIAgentField, AIAgentHostSubmitPayload, AIAgentHostCreateResult, AIAgentExtensionAvailabilityResult, Locale, FAQItem } from '@dialstack/sdk-js';
|
|
3
|
+
export { AIAgent as AIAgentData, AIAgentExtensionAvailabilityResult, AIAgentFormValues, AIAgentHostCreateResult, AIAgentHostSubmitPayload, FAQItem, UpdateAIAgentRequest } from '@dialstack/sdk-js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* AIAgent — thin React wrapper around the framework-agnostic
|
|
7
|
+
* `<dialstack-ai-agent>` Custom Element. Mirrors Voicemails.tsx /
|
|
8
|
+
* CallLogs.tsx: useCreateComponent instantiates the element and
|
|
9
|
+
* useUpdateWithSetter forwards each prop to its setter. `onSaved` /
|
|
10
|
+
* `onError` are wired via `addEventListener` on the element's
|
|
11
|
+
* `dialstack:ai-agent:saved` / `:error` events — the same path a non-React
|
|
12
|
+
* host would use — so the wrapper and a plain HTML drop-in stay in sync.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
interface AIAgentProps {
|
|
16
|
+
/** AI agent ID (`aia_…`) the host has resolved for the current account. */
|
|
17
|
+
agentId?: string;
|
|
18
|
+
/** Render an existing agent editor or a host-controlled create form. */
|
|
19
|
+
mode?: 'edit' | 'create';
|
|
20
|
+
/** Initial form values for host-controlled create/edit surfaces. */
|
|
21
|
+
initialValues?: AIAgentFormValues;
|
|
22
|
+
/** Host-provided webhook secret to display in full admin-style surfaces. */
|
|
23
|
+
secret?: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Fields the editor should not render. Spineline mounts with
|
|
26
|
+
* `hideFields={['name']}` because there is exactly one managed agent per
|
|
27
|
+
* practice and the back-office name is invisible to operators.
|
|
28
|
+
*/
|
|
29
|
+
hideFields?: AIAgentField[];
|
|
30
|
+
/** Optional callback invoked after a successful save. */
|
|
31
|
+
onSaved?: (agent: {
|
|
32
|
+
id: string;
|
|
33
|
+
}) => void;
|
|
34
|
+
/** Host-controlled create callback. When set, the component does not call the API itself. */
|
|
35
|
+
onCreateRequested?: (payload: AIAgentHostSubmitPayload) => AIAgentHostCreateResult | Promise<AIAgentHostCreateResult>;
|
|
36
|
+
/** Host-controlled save callback. When set, the component does not call the API itself. */
|
|
37
|
+
onSaveRequested?: (payload: AIAgentHostSubmitPayload) => void | Promise<void>;
|
|
38
|
+
/** Host-controlled extension availability callback for privileged extension surfaces. */
|
|
39
|
+
onCheckExtensionAvailability?: (extensionNumber: string) => AIAgentExtensionAvailabilityResult | Promise<AIAgentExtensionAvailabilityResult>;
|
|
40
|
+
/** Host-controlled secret rotation callback. */
|
|
41
|
+
onRotateSecretRequested?: () => void | Promise<void>;
|
|
42
|
+
/** Optional callback invoked after a successful host-controlled create. */
|
|
43
|
+
onCreated?: (agent: AIAgentHostCreateResult) => void;
|
|
44
|
+
/** Optional callback invoked when the load or save call rejects. */
|
|
45
|
+
onError?: (error: Error) => void;
|
|
46
|
+
/** Optional locale for translatable strings (labels, placeholders, errors). */
|
|
47
|
+
locale?: Locale;
|
|
48
|
+
/** Optional className applied to the container element. */
|
|
49
|
+
className?: string;
|
|
50
|
+
/** Optional inline styles applied to the container element. */
|
|
51
|
+
style?: React.CSSProperties;
|
|
52
|
+
}
|
|
53
|
+
declare const AIAgent: React.FC<AIAgentProps>;
|
|
54
|
+
|
|
55
|
+
interface TimeRange {
|
|
56
|
+
day: number;
|
|
57
|
+
start: string;
|
|
58
|
+
end: string;
|
|
59
|
+
}
|
|
60
|
+
interface ScheduleLike {
|
|
61
|
+
ranges: TimeRange[];
|
|
62
|
+
}
|
|
63
|
+
interface LocationLike {
|
|
64
|
+
address?: {
|
|
65
|
+
address_number?: string;
|
|
66
|
+
street?: string;
|
|
67
|
+
unit?: string;
|
|
68
|
+
city?: string;
|
|
69
|
+
state?: string;
|
|
70
|
+
postal_code?: string;
|
|
71
|
+
formatted_address?: string;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
interface UserLike {
|
|
75
|
+
name?: string | null;
|
|
76
|
+
}
|
|
77
|
+
declare function buildAIAgentPrefillFaq({ locations, schedules, users, }: {
|
|
78
|
+
locations: LocationLike[];
|
|
79
|
+
schedules: ScheduleLike[];
|
|
80
|
+
users: UserLike[];
|
|
81
|
+
}): FAQItem[];
|
|
82
|
+
declare function shouldApplyPrefillFaq({ isCreate, prefillCount, faqDirty, }: {
|
|
83
|
+
isCreate: boolean;
|
|
84
|
+
prefillCount: number;
|
|
85
|
+
faqDirty: boolean;
|
|
86
|
+
}): boolean;
|
|
87
|
+
|
|
88
|
+
export { AIAgent, buildAIAgentPrefillFaq, shouldApplyPrefillFaq };
|
|
89
|
+
export type { AIAgentProps };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import e,{useRef as t,useState as n,useCallback as r,useEffect as s,useLayoutEffect as a}from"react";import{useDialstackComponents as o}from"@dialstack/sdk-react";function i(e,s){const a=t(null),[o,i]=n(null);return{containerRef:r(t=>{if(a.current&&a.current.parentNode&&(a.current.parentNode.removeChild(a.current),a.current=null,i(null)),!t)return;const n=e.create(s);try{!function(e,t){if(!e||"function"!=typeof e.setInstance)throw new Error(`<dialstack-${t}> was created but is not a registered custom element, so it would render nothing. Install @dialstack/sdk-js alongside @dialstack/sdk-react and import it once at your entry point — importing it is what registers the elements. On @dialstack/sdk-js/pure nothing registers on import: await registerComponents() before rendering. If it is installed, check that your bundler is not dropping its side effects.`)}(n,s)}catch(t){throw e.removeAppearanceTarget(n),t}try{n.setAttribute("data-dialstack-sdk-version",_NPM_PACKAGE_VERSION_)}catch(e){console.log("Error setting SDK version attribute:",e)}t.appendChild(n),a.current=n,i(n)},[e,s]),componentInstance:o}}const d=[],c="undefined"==typeof window?s:a;function l(e,t,n){c(()=>{if(e&&void 0!==t)try{n(e,t)}catch(e){console.error("DialStack: Error calling setter:",e)}},[e,t,n])}const u=({agentId:t,mode:n="edit",initialValues:r,secret:a,hideFields:c,onSaved:u,onCreateRequested:h,onSaveRequested:f,onCheckExtensionAvailability:y,onRotateSecretRequested:g,onCreated:m,onError:p,locale:v,className:k,style:E})=>{const{dialstack:w}=o(),{containerRef:S,componentInstance:$}=i(w,"ai-agent"),b="create"===n||h||f?"host":"sdk";return l($,n,(e,t)=>e.setMode(t)),l($,b,(e,t)=>e.setSubmitMode(t)),l($,r,(e,t)=>e.setInitialValues(t)),l($,a,(e,t)=>e.setSecret(t)),l($,h,(e,t)=>e.setOnCreateRequested(t)),l($,f,(e,t)=>e.setOnSaveRequested(t)),l($,y,(e,t)=>e.setOnCheckExtensionAvailability(t)),l($,g,(e,t)=>e.setOnRotateSecretRequested(t)),l($,t,(e,t)=>e.setAgentId(t)),l($,null!=c?c:d,(e,t)=>e.setHideFields(t)),l($,v,(e,t)=>e.setLocale(t)),s(()=>{const e=$;if(!e)return;const t=e=>{const t=e.detail;null==u||u({id:t.agentId})},n=e=>{const t=e.detail;null==m||m(t)},r=e=>{const t=e.detail;null==p||p(t.error)};return e.addEventListener("dialstack:ai-agent:saved",t),e.addEventListener("dialstack:ai-agent:created",n),e.addEventListener("dialstack:ai-agent:error",r),()=>{e.removeEventListener("dialstack:ai-agent:saved",t),e.removeEventListener("dialstack:ai-agent:created",n),e.removeEventListener("dialstack:ai-agent:error",r)}},[$,u,m,p]),e.createElement("div",{ref:S,className:k,style:E})},h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function f(e){if(0===e.ranges.length)return"Please contact us for our current hours.";const t=new Map;for(const n of e.ranges)t.set(n.day,`${n.start} - ${n.end}`);const n=[];for(const[e,r]of[...t.entries()].sort((e,t)=>e[0]-t[0])){const t=n[n.length-1];t&&t.hours===r&&t.days[t.days.length-1]===e-1?t.days.push(e):n.push({days:[e],hours:r})}return n.map(e=>{var t,n,r,s,a;const o=null!==(t=e.days[0])&&void 0!==t?t:0,i=null!==(n=e.days[e.days.length-1])&&void 0!==n?n:o;return`${1===e.days.length?null!==(r=h[o])&&void 0!==r?r:`Day ${o}`:`${null!==(s=h[o])&&void 0!==s?s:`Day ${o}`} to ${null!==(a=h[i])&&void 0!==a?a:`Day ${i}`}`}: ${e.hours}`}).join("\n")}function y({locations:e,schedules:t,users:n}){const r=[],s=e[0];if(null==s?void 0:s.address){const e=s.address,t=e.formatted_address||[e.address_number,e.street,e.unit,e.city,e.state,e.postal_code].filter(Boolean).join(", ");t&&r.push({question:"What is your address?",answer:`We are located at ${t}.`})}const a=t[0];a&&r.push({question:"What are your business hours?",answer:f(a)});const o=n.map(e=>e.name).filter(e=>!!e);return o.length>0&&r.push({question:"Who are the members of your team?",answer:`Our team includes: ${o.join(", ")}.`}),r}function g({isCreate:e,prefillCount:t,faqDirty:n}){return e&&t>0&&!n}export{u as AIAgent,y as buildAIAgentPrefillFaq,g as shouldApplyPrefillFaq};
|
|
2
|
+
//# sourceMappingURL=ai-agent.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-agent.mjs","sources":["../src/react/useCreateComponent.tsx","../src/react/AIAgent.tsx","../src/ai-agent/prefill-faq.ts"],"sourcesContent":[null,null,null],"names":["useCreateComponent","dialstack","tagName","componentRef","useRef","componentInstance","setComponentInstance","useState","containerRef","useCallback","container","current","parentNode","removeChild","component","create","element","setInstance","Error","assertUpgraded","err","removeAppearanceTarget","setAttribute","_NPM_PACKAGE_VERSION_","e","console","log","appendChild","EMPTY_HIDE_FIELDS","useIsomorphicLayoutEffect","window","useEffect","useLayoutEffect","useLayoutUpdateWithSetter","value","onUpdated","undefined","error","AIAgent","agentId","mode","initialValues","secret","hideFields","onSaved","onCreateRequested","onSaveRequested","onCheckExtensionAvailability","onRotateSecretRequested","onCreated","onError","locale","className","style","useDialstackComponents","submitMode","comp","val","setMode","setSubmitMode","setInitialValues","setSecret","setOnCreateRequested","setOnSaveRequested","setOnCheckExtensionAvailability","setOnRotateSecretRequested","setAgentId","setHideFields","setLocale","el","handleSaved","detail","id","handleCreated","handleError","addEventListener","removeEventListener","React","createElement","ref","DAY_NAMES","formatScheduleAnswer","schedule","ranges","length","byDay","Map","r","set","day","start","end","groups","hours","entries","sort","a","b","last","days","push","map","g","firstDay","_a","lastDay","_b","_c","_d","_e","join","buildAIAgentPrefillFaq","locations","schedules","users","items","firstLocation","address","addr","formatted","formatted_address","address_number","street","unit","city","state","postal_code","filter","Boolean","question","answer","firstSchedule","names","u","name","shouldApplyPrefillFaq","isCreate","prefillCount","faqDirty"],"mappings":"mKAqEM,SAAUA,EACdC,EACAC,GAEA,MAAMC,EAAeC,EAAmC,OAEjDC,EAAmBC,GAAwBC,EAAqC,MA0CvF,MAAO,CACLC,aAxCmBC,EAClBC,IAQC,GANIP,EAAaQ,SAAWR,EAAaQ,QAAQC,aAC/CT,EAAaQ,QAAQC,WAAWC,YAAYV,EAA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,EAAKI,OAAQJ,EAAKK,KAAML,EAAKM,KAAMN,EAAKO,MAAOP,EAAKQ,aACvEC,OAAOC,SACPlB,KAAK,MACNS,GACFJ,EAAMf,KAAK,CACT6B,SAAU,wBACVC,OAAQ,qBAAqBX,MAGnC,CAEA,MAAMY,EAAgBlB,EAAU,GAC5BkB,GACFhB,EAAMf,KAAK,CACT6B,SAAU,gCACVC,OAAQjD,EAAqBkD,KAIjC,MAAMC,EAAQlB,EAAMb,IAAKgC,GAAMA,EAAEC,MAAMP,OAAQO,KAA2BA,GAQ1E,OAPIF,EAAMhD,OAAS,GACjB+B,EAAMf,KAAK,CACT6B,SAAU,oCACVC,OAAQ,sBAAsBE,EAAMtB,KAAK,WAItCK,CACT,CAEM,SAAUoB,GAAsBC,SACpCA,EAAQC,aACRA,EAAYC,SACZA,IAMA,OAAOF,GAAYC,EAAe,IAAMC,CAC1C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var t=require("react"),e=require("@dialstack/sdk-react");function r(e,r){const n=t.useRef(null),[s,a]=t.useState(null);return{containerRef:t.useCallback(t=>{if(n.current&&n.current.parentNode&&(n.current.parentNode.removeChild(n.current),n.current=null,a(null)),!t)return;const s=e.create(r);try{!function(t,e){if(!t||"function"!=typeof t.setInstance)throw new Error(`<dialstack-${e}> was created but is not a registered custom element, so it would render nothing. Install @dialstack/sdk-js alongside @dialstack/sdk-react and import it once at your entry point — importing it is what registers the elements. On @dialstack/sdk-js/pure nothing registers on import: await registerComponents() before rendering. If it is installed, check that your bundler is not dropping its side effects.`)}(s,r)}catch(t){throw e.removeAppearanceTarget(s),t}try{s.setAttribute("data-dialstack-sdk-version",_NPM_PACKAGE_VERSION_)}catch(t){console.log("Error setting SDK version attribute:",t)}t.appendChild(s),n.current=s,a(s)},[e,r]),componentInstance:s}}function n(e,r,n){t.useEffect(()=>{if(e&&void 0!==r)try{n(e,r)}catch(t){console.error("DialStack: Error calling setter:",t)}},[e,r,n])}exports.CallHistory=({phoneNumber:s,limit:a,className:o,style:i,locale:c,formatting:l,icons:u,layoutVariant:d,classes:p,displayOptions:m,onLoaderStart:f,onLoadError:g})=>{const{dialstack:h}=e.useDialstackComponents(),{containerRef:k,componentInstance:y}=r(h,"call-history");return n(y,s,(t,e)=>t.setPhoneNumber(e)),n(y,a,(t,e)=>t.setLimit(e)),n(y,c,(t,e)=>t.setLocale(e)),n(y,l,(t,e)=>t.setFormatting(e)),n(y,u,(t,e)=>t.setIcons(e)),n(y,d,(t,e)=>t.setLayoutVariant(e)),n(y,p,(t,e)=>t.setClasses(e)),n(y,m,(t,e)=>t.setDisplayOptions(e)),n(y,f,(t,e)=>t.setOnLoaderStart(e)),n(y,g,(t,e)=>t.setOnLoadError(e)),t.createElement("div",{ref:k,className:o,style:i})};
|
|
2
|
+
//# sourceMappingURL=call-history.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-history.cjs","sources":["../src/react/useCreateComponent.tsx","../src/react/useUpdateWithSetter.ts","../src/react/CallHistory.tsx"],"sourcesContent":[null,null,null],"names":["useCreateComponent","dialstack","tagName","componentRef","useRef","componentInstance","setComponentInstance","useState","containerRef","useCallback","container","current","parentNode","removeChild","component","create","element","setInstance","Error","assertUpgraded","err","removeAppearanceTarget","setAttribute","_NPM_PACKAGE_VERSION_","e","console","log","appendChild","useUpdateWithSetter","value","onUpdated","useEffect","undefined","error","CallHistory","phoneNumber","limit","className","style","locale","formatting","icons","layoutVariant","classes","displayOptions","onLoaderStart","onLoadError","useDialstackComponents","comp","val","setPhoneNumber","setLimit","setLocale","setFormatting","setIcons","setLayoutVariant","setClasses","setDisplayOptions","setOnLoaderStart","setOnLoadError","React","createElement","ref"],"mappings":"sEAqEM,SAAUA,EACdC,EACAC,GAEA,MAAMC,EAAeC,EAAAA,OAAmC,OAEjDC,EAAmBC,GAAwBC,EAAAA,SAAqC,MA0CvF,MAAO,CACLC,aAxCmBC,EAAAA,YAClBC,IAQC,GANIP,EAAaQ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oC,EAAO,CAACO,EAAMC,IAAQD,EAAKM,SAASL,IAC3ErB,EAAoBvB,EAAmBqC,EAAe,CAACM,EAAMC,IAAQD,EAAKO,iBAAiBN,IAC3FrB,EAAoBvB,EAAmBsC,EAAS,CAACK,EAAMC,IAAQD,EAAKQ,WAAWP,IAC/ErB,EAAoBvB,EAAmBuC,EAAgB,CAACI,EAAMC,IAC5DD,EAAKS,kBAAkBR,IAIzBrB,EAAoBvB,EAAmBwC,EAAe,CAACG,EAAMC,IAAQD,EAAKU,iBAAiBT,IAC3FrB,EAAoBvB,EAAmByC,EAAa,CAACE,EAAMC,IAAQD,EAAKW,eAAeV,IAEhFW,EAAAC,cAAA,MAAA,CAAKC,IAAKtD,EAAc6B,UAAWA,EAAWC,MAAOA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Locale, FormattingOptions, ComponentIcons, LayoutVariant, CallHistoryClasses, CallHistoryDisplayOptions, LoaderStart, LoadError } from '@dialstack/sdk-js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* React wrapper for CallHistory Web Component
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
interface CallHistoryProps {
|
|
9
|
+
/**
|
|
10
|
+
* Phone number to fetch call history for (E.164 format, required)
|
|
11
|
+
*/
|
|
12
|
+
phoneNumber: string;
|
|
13
|
+
/**
|
|
14
|
+
* Maximum number of calls to display
|
|
15
|
+
* @default 5
|
|
16
|
+
*/
|
|
17
|
+
limit?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Optional CSS class name
|
|
20
|
+
*/
|
|
21
|
+
className?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Optional inline styles
|
|
24
|
+
*/
|
|
25
|
+
style?: React.CSSProperties;
|
|
26
|
+
/**
|
|
27
|
+
* Locale for UI strings
|
|
28
|
+
*/
|
|
29
|
+
locale?: Locale;
|
|
30
|
+
/**
|
|
31
|
+
* Formatting options for dates
|
|
32
|
+
*/
|
|
33
|
+
formatting?: FormattingOptions;
|
|
34
|
+
/**
|
|
35
|
+
* Custom icons (partial override of defaults)
|
|
36
|
+
*/
|
|
37
|
+
icons?: ComponentIcons;
|
|
38
|
+
/**
|
|
39
|
+
* Layout variant (compact, comfortable, default)
|
|
40
|
+
*/
|
|
41
|
+
layoutVariant?: LayoutVariant;
|
|
42
|
+
/**
|
|
43
|
+
* Custom CSS classes for styling integration
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <CallHistory
|
|
48
|
+
* classes={{
|
|
49
|
+
* base: 'rounded-lg',
|
|
50
|
+
* item: 'hover:bg-gray-50',
|
|
51
|
+
* itemMissed: 'bg-red-50'
|
|
52
|
+
* }}
|
|
53
|
+
* />
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
classes?: CallHistoryClasses;
|
|
57
|
+
/**
|
|
58
|
+
* Display options for controlling field visibility
|
|
59
|
+
*/
|
|
60
|
+
displayOptions?: CallHistoryDisplayOptions;
|
|
61
|
+
/**
|
|
62
|
+
* Callback when component starts loading
|
|
63
|
+
*/
|
|
64
|
+
onLoaderStart?: (event: LoaderStart) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Callback when there's an error loading call history
|
|
67
|
+
*/
|
|
68
|
+
onLoadError?: (event: LoadError) => void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* CallHistory component displays recent calls for a specific phone number
|
|
72
|
+
*
|
|
73
|
+
* Must be used within a DialstackComponentsProvider.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* <DialstackComponentsProvider dialstack={dialstack}>
|
|
78
|
+
* <CallHistory
|
|
79
|
+
* phoneNumber="+14155551234"
|
|
80
|
+
* limit={5}
|
|
81
|
+
* />
|
|
82
|
+
* </DialstackComponentsProvider>
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
declare const CallHistory: React.FC<CallHistoryProps>;
|
|
86
|
+
|
|
87
|
+
export { CallHistory };
|
|
88
|
+
export type { CallHistoryProps };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Locale, FormattingOptions, ComponentIcons, LayoutVariant, CallHistoryClasses, CallHistoryDisplayOptions, LoaderStart, LoadError } from '@dialstack/sdk-js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* React wrapper for CallHistory Web Component
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
interface CallHistoryProps {
|
|
9
|
+
/**
|
|
10
|
+
* Phone number to fetch call history for (E.164 format, required)
|
|
11
|
+
*/
|
|
12
|
+
phoneNumber: string;
|
|
13
|
+
/**
|
|
14
|
+
* Maximum number of calls to display
|
|
15
|
+
* @default 5
|
|
16
|
+
*/
|
|
17
|
+
limit?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Optional CSS class name
|
|
20
|
+
*/
|
|
21
|
+
className?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Optional inline styles
|
|
24
|
+
*/
|
|
25
|
+
style?: React.CSSProperties;
|
|
26
|
+
/**
|
|
27
|
+
* Locale for UI strings
|
|
28
|
+
*/
|
|
29
|
+
locale?: Locale;
|
|
30
|
+
/**
|
|
31
|
+
* Formatting options for dates
|
|
32
|
+
*/
|
|
33
|
+
formatting?: FormattingOptions;
|
|
34
|
+
/**
|
|
35
|
+
* Custom icons (partial override of defaults)
|
|
36
|
+
*/
|
|
37
|
+
icons?: ComponentIcons;
|
|
38
|
+
/**
|
|
39
|
+
* Layout variant (compact, comfortable, default)
|
|
40
|
+
*/
|
|
41
|
+
layoutVariant?: LayoutVariant;
|
|
42
|
+
/**
|
|
43
|
+
* Custom CSS classes for styling integration
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <CallHistory
|
|
48
|
+
* classes={{
|
|
49
|
+
* base: 'rounded-lg',
|
|
50
|
+
* item: 'hover:bg-gray-50',
|
|
51
|
+
* itemMissed: 'bg-red-50'
|
|
52
|
+
* }}
|
|
53
|
+
* />
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
classes?: CallHistoryClasses;
|
|
57
|
+
/**
|
|
58
|
+
* Display options for controlling field visibility
|
|
59
|
+
*/
|
|
60
|
+
displayOptions?: CallHistoryDisplayOptions;
|
|
61
|
+
/**
|
|
62
|
+
* Callback when component starts loading
|
|
63
|
+
*/
|
|
64
|
+
onLoaderStart?: (event: LoaderStart) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Callback when there's an error loading call history
|
|
67
|
+
*/
|
|
68
|
+
onLoadError?: (event: LoadError) => void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* CallHistory component displays recent calls for a specific phone number
|
|
72
|
+
*
|
|
73
|
+
* Must be used within a DialstackComponentsProvider.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* <DialstackComponentsProvider dialstack={dialstack}>
|
|
78
|
+
* <CallHistory
|
|
79
|
+
* phoneNumber="+14155551234"
|
|
80
|
+
* limit={5}
|
|
81
|
+
* />
|
|
82
|
+
* </DialstackComponentsProvider>
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
declare const CallHistory: React.FC<CallHistoryProps>;
|
|
86
|
+
|
|
87
|
+
export { CallHistory };
|
|
88
|
+
export type { CallHistoryProps };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import t,{useRef as e,useState as r,useCallback as n,useEffect as o}from"react";import{useDialstackComponents as s}from"@dialstack/sdk-react";function a(t,o){const s=e(null),[a,i]=r(null);return{containerRef:n(e=>{if(s.current&&s.current.parentNode&&(s.current.parentNode.removeChild(s.current),s.current=null,i(null)),!e)return;const r=t.create(o);try{!function(t,e){if(!t||"function"!=typeof t.setInstance)throw new Error(`<dialstack-${e}> was created but is not a registered custom element, so it would render nothing. Install @dialstack/sdk-js alongside @dialstack/sdk-react and import it once at your entry point — importing it is what registers the elements. On @dialstack/sdk-js/pure nothing registers on import: await registerComponents() before rendering. If it is installed, check that your bundler is not dropping its side effects.`)}(r,o)}catch(e){throw t.removeAppearanceTarget(r),e}try{r.setAttribute("data-dialstack-sdk-version",_NPM_PACKAGE_VERSION_)}catch(t){console.log("Error setting SDK version attribute:",t)}e.appendChild(r),s.current=r,i(r)},[t,o]),componentInstance:a}}function i(t,e,r){o(()=>{if(t&&void 0!==e)try{r(t,e)}catch(t){console.error("DialStack: Error calling setter:",t)}},[t,e,r])}const c=({phoneNumber:e,limit:r,className:n,style:o,locale:c,formatting:l,icons:d,layoutVariant:u,classes:p,displayOptions:m,onLoaderStart:f,onLoadError:g})=>{const{dialstack:h}=s(),{containerRef:k,componentInstance:y}=a(h,"call-history");return i(y,e,(t,e)=>t.setPhoneNumber(e)),i(y,r,(t,e)=>t.setLimit(e)),i(y,c,(t,e)=>t.setLocale(e)),i(y,l,(t,e)=>t.setFormatting(e)),i(y,d,(t,e)=>t.setIcons(e)),i(y,u,(t,e)=>t.setLayoutVariant(e)),i(y,p,(t,e)=>t.setClasses(e)),i(y,m,(t,e)=>t.setDisplayOptions(e)),i(y,f,(t,e)=>t.setOnLoaderStart(e)),i(y,g,(t,e)=>t.setOnLoadError(e)),t.createElement("div",{ref:k,className:n,style:o})};export{c as CallHistory};
|
|
2
|
+
//# sourceMappingURL=call-history.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-history.mjs","sources":["../src/react/useCreateComponent.tsx","../src/react/useUpdateWithSetter.ts","../src/react/CallHistory.tsx"],"sourcesContent":[null,null,null],"names":["useCreateComponent","dialstack","tagName","componentRef","useRef","componentInstance","setComponentInstance","useState","containerRef","useCallback","container","current","parentNode","removeChild","component","create","element","setInstance","Error","assertUpgraded","err","removeAppearanceTarget","setAttribute","_NPM_PACKAGE_VERSION_","e","console","log","appendChild","useUpdateWithSetter","value","onUpdated","useEffect","undefined","error","CallHistory","phoneNumber","limit","className","style","locale","formatting","icons","layoutVariant","classes","displayOptions","onLoaderStart","onLoadError","useDialstackComponents","comp","val","setPhoneNumber","setLimit","setLocale","setFormatting","setIcons","setLayoutVariant","setClasses","setDisplayOptions","setOnLoaderStart","setOnLoadError","React","createElement","ref"],"mappings":"8IAqEM,SAAUA,EACdC,EACAC,GAEA,MAAMC,EAAeC,EAAmC,OAEjDC,EAAmBC,GAAwBC,EAAqC,MA0CvF,MAAO,CACLC,aAxCmBC,EAClBC,IAQC,GANIP,EAAaQ,SAAWR,EAAaQ,QAAQC,aAC/CT,EAAaQ,QAAQC,WAAWC,YAAYV,EAAaQ,SACzDR,EAAaQ,QAAU,KACvBL,EAAqB,QAGlBI,EAAW,OAGhB,MAAMI,EAAYb,EAAUc,OAAOb,GACnC,KAvDN,SAAwBc,EAAkBd,GACxC,IAAIc,GAAyE,mBAAtDA,EAAsCC,YAG7D,MAAM,IAAIC,MACR,cAAchB,sZAOlB,CA4CQiB,CAAeL,EAAWZ,EAC5B,CAAE,MAAOkB,GAMP,MADAnB,EAAUoB,uBAAuBP,GAC3BM,CACR,CAGA,IACEN,EAAUQ,aAAa,6BAA8BC,sBACvD,CAAE,MAAOC,GACPC,QAAQC,IAAI,uCAAwCF,EACtD,CAGAd,EAAUiB,YAAYb,GACtBX,EAAaQ,QAAUG,EACvBR,EAAqBQ,IAEvB,CAACb,EAAWC,IAKZG,oBAEJ,UCpFgBuB,EACdd,EACAe,EACAC,GAEAC,EAAU,KACR,GAAKjB,QAAuBkB,IAAVH,EAElB,IACEC,EAAUhB,EAAWe,EACvB,CAAE,MAAOI,GACPR,QAAQQ,MAAM,mCAAoCA,EACpD,GACC,CAACnB,EAAWe,EAAOC,GACxB,CCyDO,MAAMI,EAA0CA,EACrDC,cACAC,QACAC,YACAC,QACAC,SACAC,aACAC,QACAC,gBACAC,UACAC,iBACAC,gBACAC,kBAEA,MAAM7C,UAAEA,GAAc8C,KAChBvC,aAAEA,EAAYH,kBAAEA,GAAsBL,EAAmBC,EAAW,gBAoB1E,OAjBA2B,EAAoBvB,EAAmB8B,EAAa,CAACa,EAAMC,IAAQD,EAAKE,eAAeD,IACvFrB,EAAoBvB,EAAmB+B,EAAO,CAACY,EAAMC,IAAQD,EAAKG,SAASF,IAG3ErB,EAAoBvB,EAAmBkC,EAAQ,CAACS,EAAMC,IAAQD,EAAKI,UAAUH,IAC7ErB,EAAoBvB,EAAmBmC,EAAY,CAACQ,EAAMC,IAAQD,EAAKK,cAAcJ,IACrFrB,EAAoBvB,EAAmBoC,EAAO,CAACO,EAAMC,IAAQD,EAAKM,SAASL,IAC3ErB,EAAoBvB,EAAmBqC,EAAe,CAACM,EAAMC,IAAQD,EAAKO,iBAAiBN,IAC3FrB,EAAoBvB,EAAmBsC,EAAS,CAACK,EAAMC,IAAQD,EAAKQ,WAAWP,IAC/ErB,EAAoBvB,EAAmBuC,EAAgB,CAACI,EAAMC,IAC5DD,EAAKS,kBAAkBR,IAIzBrB,EAAoBvB,EAAmBwC,EAAe,CAACG,EAAMC,IAAQD,EAAKU,iBAAiBT,IAC3FrB,EAAoBvB,EAAmByC,EAAa,CAACE,EAAMC,IAAQD,EAAKW,eAAeV,IAEhFW,EAAAC,cAAA,MAAA,CAAKC,IAAKtD,EAAc6B,UAAWA,EAAWC,MAAOA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var t=require("react"),e=require("@dialstack/sdk-react");function r(e,r){const n=t.useRef(null),[s,a]=t.useState(null);return{containerRef:t.useCallback(t=>{if(n.current&&n.current.parentNode&&(n.current.parentNode.removeChild(n.current),n.current=null,a(null)),!t)return;const s=e.create(r);try{!function(t,e){if(!t||"function"!=typeof t.setInstance)throw new Error(`<dialstack-${e}> was created but is not a registered custom element, so it would render nothing. Install @dialstack/sdk-js alongside @dialstack/sdk-react and import it once at your entry point — importing it is what registers the elements. On @dialstack/sdk-js/pure nothing registers on import: await registerComponents() before rendering. If it is installed, check that your bundler is not dropping its side effects.`)}(s,r)}catch(t){throw e.removeAppearanceTarget(s),t}try{s.setAttribute("data-dialstack-sdk-version",_NPM_PACKAGE_VERSION_)}catch(t){console.log("Error setting SDK version attribute:",t)}t.appendChild(s),n.current=s,a(s)},[e,r]),componentInstance:s}}function n(e,r,n){t.useEffect(()=>{if(e&&void 0!==r)try{n(e,r)}catch(t){console.error("DialStack: Error calling setter:",t)}},[e,r,n])}exports.CallLogs=({className:s,style:a,dateRange:o,limit:i,locale:c,formatting:l,icons:d,layoutVariant:u,classes:p,displayOptions:m,customRowRenderer:g,onLoaderStart:f,onLoadError:k,onRowClick:h})=>{const{dialstack:y}=e.useDialstackComponents(),{containerRef:R,componentInstance:w}=r(y,"call-logs");return n(w,o,(t,e)=>t.setDateRange(e)),n(w,i,(t,e)=>t.setLimit(e)),n(w,c,(t,e)=>t.setLocale(e)),n(w,l,(t,e)=>t.setFormatting(e)),n(w,d,(t,e)=>t.setIcons(e)),n(w,u,(t,e)=>t.setLayoutVariant(e)),n(w,p,(t,e)=>t.setClasses(e)),n(w,m,(t,e)=>t.setDisplayOptions(e)),n(w,g,(t,e)=>t.setCustomRowRenderer(e)),n(w,f,(t,e)=>t.setOnLoaderStart(e)),n(w,k,(t,e)=>t.setOnLoadError(e)),n(w,h,(t,e)=>t.setOnRowClick(e)),t.createElement("div",{ref:R,className:s,style:a})};
|
|
2
|
+
//# sourceMappingURL=call-logs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-logs.cjs","sources":["../src/react/useCreateComponent.tsx","../src/react/useUpdateWithSetter.ts","../src/react/CallLogs.tsx"],"sourcesContent":[null,null,null],"names":["useCreateComponent","dialstack","tagName","componentRef","useRef","componentInstance","setComponentInstance","useState","containerRef","useCallback","container","current","parentNode","removeChild","component","create","element","setInstance","Error","assertUpgraded","err","removeAppearanceTarget","setAttribute","_NPM_PACKAGE_VERSION_","e","console","log","appendChild","useUpdateWithSetter","value","onUpdated","useEffect","undefined","error","CallLogs","className","style","dateRange","limit","locale","formatting","icons","layoutVariant","classes","displayOptions","customRowRenderer","onLoaderStart","onLoadError","onRowClick","useDialstackComponents","comp","val","setDateRange","setLimit","setLocale","setFormatting","setIcons","setLayoutVariant","setClasses","setDisplayOptions","setCustomRowRenderer","setOnLoaderStart","setOnLoadError","setOnRowClick","React","createElement","ref"],"mappings":"sEAqEM,SAAUA,EACdC,EACAC,GAEA,MAAMC,EAAeC,EAAAA,OAAmC,OAEjDC,EAAmBC,GAAwBC,EAAAA,SAAqC,MA0CvF,MAAO,CACLC,aAxCmBC,EAAAA,YAClBC,IAQC,GANIP,EAAaQ,SAAWR,EAAaQ,QAAQC,aAC/CT,EAAaQ,QAAQC,WAAWC,YAAYV,EAAaQ,SACzDR,EAAaQ,QAAU,KACvBL,EAAqB,QAGlBI,EAAW,OAGhB,MAAMI,EAAYb,EAAUc,OAAOb,GACnC,KAvDN,SAAwBc,EAAkBd,GACxC,IAAIc,GAAyE,mBAAtDA,EAAsCC,YAG7D,MAAM,IAAIC,MACR,cAAchB,sZAOlB,CA4CQiB,CAAeL,EAAWZ,EAC5B,CAAE,MAAOkB,GAMP,MADAnB,EAAUoB,uBAAuBP,GAC3BM,CACR,CAGA,IACEN,EAAUQ,aAAa,6BAA8BC,sBACvD,CAAE,MAAOC,GACPC,QAAQC,IAAI,uCAAwCF,EACtD,CAGAd,EAAUiB,YAAYb,GACtBX,EAAaQ,QAAUG,EACvBR,EAAqBQ,IAEvB,CAACb,EAAWC,IAKZG,oBAEJ,UCpFgBuB,EACdd,EACAe,EACAC,GAEAC,EAAAA,UAAU,KACR,GAAKjB,QAAuBkB,IAAVH,EAElB,IACEC,EAAUhB,EAAWe,EACvB,CAAE,MAAOI,GACPR,QAAQQ,MAAM,mCAAoCA,EACpD,GACC,CAACnB,EAAWe,EAAOC,GACxB,kBC2EiDI,EAC/CC,YACAC,QACAC,YACAC,QACAC,SACAC,aACAC,QACAC,gBACAC,UACAC,iBACAC,oBACAC,gBACAC,cACAC,iBAEA,MAAM/C,UAAEA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