@adatechnology/conversations-ui 0.20.0 → 0.21.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/dist/index.d.ts
CHANGED
|
@@ -881,6 +881,11 @@ interface ConversationContextEntry {
|
|
|
881
881
|
value?: string | undefined;
|
|
882
882
|
icon?: string;
|
|
883
883
|
status?: ConversationContextStatus;
|
|
884
|
+
/**
|
|
885
|
+
* Opt-in: com valor preenchido, o valor vira um botão (foco, clique, toque). Serve ao host para
|
|
886
|
+
* abrir o texto inteiro quando o card trunca — o toque não mostra dica de hover.
|
|
887
|
+
*/
|
|
888
|
+
onSelect?: () => void;
|
|
884
889
|
}
|
|
885
890
|
interface ConversationContextPanelLabels {
|
|
886
891
|
title: string;
|
package/dist/index.js
CHANGED
|
@@ -2085,7 +2085,15 @@ function ConversationContextPanel({
|
|
|
2085
2085
|
entry.value ? "text-gray-900 dark:text-gray-100" : "italic font-normal text-gray-400 dark:text-gray-500"
|
|
2086
2086
|
),
|
|
2087
2087
|
"data-cv-tooltip": entry.value ?? labels.notCollected,
|
|
2088
|
-
children: entry.value
|
|
2088
|
+
children: entry.value && entry.onSelect ? /* @__PURE__ */ jsx14(
|
|
2089
|
+
"button",
|
|
2090
|
+
{
|
|
2091
|
+
type: "button",
|
|
2092
|
+
onClick: entry.onSelect,
|
|
2093
|
+
className: "w-full cursor-pointer truncate rounded text-center font-semibold hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-blue-500",
|
|
2094
|
+
children: entry.value
|
|
2095
|
+
}
|
|
2096
|
+
) : entry.value ?? labels.notCollected
|
|
2089
2097
|
}
|
|
2090
2098
|
)
|
|
2091
2099
|
]
|
package/package.json
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test'
|
|
2
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
3
|
+
|
|
4
|
+
import { ConversationContextPanel } from './ConversationContextPanel'
|
|
5
|
+
|
|
6
|
+
const noop = () => {}
|
|
7
|
+
|
|
8
|
+
describe('ConversationContextPanel onSelect', () => {
|
|
9
|
+
it('vira botão só no card preenchido que declara onSelect', () => {
|
|
10
|
+
const markup = renderToStaticMarkup(
|
|
11
|
+
<ConversationContextPanel
|
|
12
|
+
defaultOpen
|
|
13
|
+
entries={[
|
|
14
|
+
{ key: 'items', label: 'Itens', value: '2x Pudim, 1x Café', onSelect: noop },
|
|
15
|
+
{ key: 'code', label: 'Código', value: 'PED-1' },
|
|
16
|
+
{ key: 'time', label: 'Horário', onSelect: noop },
|
|
17
|
+
]}
|
|
18
|
+
/>,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
expect(markup.match(/<button type="button" class="w-full/g)?.length).toBe(1)
|
|
22
|
+
expect(markup).toContain('data-cv-tooltip="2x Pudim, 1x Café"')
|
|
23
|
+
})
|
|
24
|
+
})
|
|
@@ -29,6 +29,11 @@ export interface ConversationContextEntry {
|
|
|
29
29
|
value?: string | undefined
|
|
30
30
|
icon?: string
|
|
31
31
|
status?: ConversationContextStatus
|
|
32
|
+
/**
|
|
33
|
+
* Opt-in: com valor preenchido, o valor vira um botão (foco, clique, toque). Serve ao host para
|
|
34
|
+
* abrir o texto inteiro quando o card trunca — o toque não mostra dica de hover.
|
|
35
|
+
*/
|
|
36
|
+
onSelect?: () => void
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
export interface ConversationContextPanelLabels {
|
|
@@ -265,7 +270,17 @@ export function ConversationContextPanel({
|
|
|
265
270
|
)}
|
|
266
271
|
data-cv-tooltip={entry.value ?? labels.notCollected}
|
|
267
272
|
>
|
|
268
|
-
{entry.value
|
|
273
|
+
{entry.value && entry.onSelect ? (
|
|
274
|
+
<button
|
|
275
|
+
type="button"
|
|
276
|
+
onClick={entry.onSelect}
|
|
277
|
+
className="w-full cursor-pointer truncate rounded text-center font-semibold hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-blue-500"
|
|
278
|
+
>
|
|
279
|
+
{entry.value}
|
|
280
|
+
</button>
|
|
281
|
+
) : (
|
|
282
|
+
(entry.value ?? labels.notCollected)
|
|
283
|
+
)}
|
|
269
284
|
</dd>
|
|
270
285
|
</div>
|
|
271
286
|
)
|