pixelon 0.3.29 → 0.3.31
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/components/molecules/chat/StructuredContent/components/ActionMenu/ActionMenu.d.ts +3 -0
- package/dist/components/molecules/chat/StructuredContent/components/index.d.ts +1 -0
- package/dist/components/molecules/chat/StructuredContent/helpers/types.d.ts +1 -0
- package/dist/index.esm.js +59 -15
- package/dist/index.js +59 -15
- package/package.json +1 -1
|
@@ -9,3 +9,4 @@ export { BadgeDisplay } from './BadgeDisplay/BadgeDisplay';
|
|
|
9
9
|
export { TimeInputWithConfirm } from './TimeInputWithConfirm/TimeInputWithConfirm';
|
|
10
10
|
export { ReactiveForm } from './ReactiveForm/ReactiveForm';
|
|
11
11
|
export { CarouselDisplay } from './CarouselDisplay/CarouselDisplay';
|
|
12
|
+
export { ActionMenu } from './ActionMenu/ActionMenu';
|
|
@@ -27,5 +27,6 @@ export interface ChatComponentProps {
|
|
|
27
27
|
assistantMessageId?: string;
|
|
28
28
|
}
|
|
29
29
|
export type OnConfirm = (value: unknown, label: string) => void;
|
|
30
|
+
export declare function getSubmitActionId(component: UIComponentData): string | undefined;
|
|
30
31
|
export declare const TERMINAL_STATUS: Set<string>;
|
|
31
32
|
export declare const DISPLAY_COMPONENTS: Set<string>;
|
package/dist/index.esm.js
CHANGED
|
@@ -1618,6 +1618,11 @@ function parseContent(content) {
|
|
|
1618
1618
|
return null;
|
|
1619
1619
|
}
|
|
1620
1620
|
|
|
1621
|
+
function getSubmitActionId(component) {
|
|
1622
|
+
const actions = component.actions;
|
|
1623
|
+
if (!actions || actions.length === 0) return void 0;
|
|
1624
|
+
return (actions.find((a) => a.kind === "submit") ?? actions[0]).id;
|
|
1625
|
+
}
|
|
1621
1626
|
const TERMINAL_STATUS = /* @__PURE__ */ new Set(["answered", "cancelled", "expired"]);
|
|
1622
1627
|
const DISPLAY_COMPONENTS = /* @__PURE__ */ new Set(["card", "badge", "reactive_form", "carousel"]);
|
|
1623
1628
|
|
|
@@ -1999,7 +2004,7 @@ const SelectWithConfirm = ({
|
|
|
1999
2004
|
});
|
|
2000
2005
|
const handleConfirm = () => {
|
|
2001
2006
|
if (selected) {
|
|
2002
|
-
emitInteraction(selected.value, selected.label);
|
|
2007
|
+
emitInteraction(selected.value, selected.label, getSubmitActionId(component));
|
|
2003
2008
|
setIsDrawerOpen(false);
|
|
2004
2009
|
}
|
|
2005
2010
|
};
|
|
@@ -2202,7 +2207,8 @@ const SelectMultipleWithConfirm = ({
|
|
|
2202
2207
|
if (selectedOptions.length > 0) {
|
|
2203
2208
|
emitInteraction(
|
|
2204
2209
|
selectedOptions.map((o) => o.value),
|
|
2205
|
-
selectedOptions.map((o) => o.label).join(", ")
|
|
2210
|
+
selectedOptions.map((o) => o.label).join(", "),
|
|
2211
|
+
getSubmitActionId(component)
|
|
2206
2212
|
);
|
|
2207
2213
|
setIsDrawerOpen(false);
|
|
2208
2214
|
}
|
|
@@ -2405,7 +2411,7 @@ const InputWithConfirm = ({
|
|
|
2405
2411
|
variant: "primary",
|
|
2406
2412
|
size: "small",
|
|
2407
2413
|
disabled: !inputValue,
|
|
2408
|
-
onClick: () => emitInteraction(inputValue, inputValue),
|
|
2414
|
+
onClick: () => emitInteraction(inputValue, inputValue, getSubmitActionId(component)),
|
|
2409
2415
|
children: "Confirmar"
|
|
2410
2416
|
}
|
|
2411
2417
|
)
|
|
@@ -2548,9 +2554,9 @@ const DateInputWithConfirm = ({
|
|
|
2548
2554
|
if (!selectedDate) return;
|
|
2549
2555
|
const isoValue = formatDateToISO$1(selectedDate);
|
|
2550
2556
|
const displayValue2 = formatDateDisplay$1(selectedDate, locale, timezone);
|
|
2551
|
-
emitInteraction(isoValue, displayValue2);
|
|
2557
|
+
emitInteraction(isoValue, displayValue2, getSubmitActionId(component));
|
|
2552
2558
|
setIsOpen(false);
|
|
2553
|
-
}, [selectedDate, emitInteraction, locale, timezone]);
|
|
2559
|
+
}, [selectedDate, emitInteraction, locale, timezone, component]);
|
|
2554
2560
|
const displayValue = formatDateDisplay$1(selectedDate, locale, timezone);
|
|
2555
2561
|
const placeholder = component.props.placeholder || "Selecciona una fecha";
|
|
2556
2562
|
const label = component.props.label || "Selecciona una fecha";
|
|
@@ -2976,16 +2982,16 @@ const TimeInputWithConfirm = ({
|
|
|
2976
2982
|
const value24h = componentsTo24h(nowComp);
|
|
2977
2983
|
const display = formatTimeDisplay(value24h, locale, timezone);
|
|
2978
2984
|
setConfirmedTime(value24h);
|
|
2979
|
-
emitInteraction(value24h, display);
|
|
2985
|
+
emitInteraction(value24h, display, getSubmitActionId(component));
|
|
2980
2986
|
setIsOpen(false);
|
|
2981
|
-
}, [locale, timezone, emitInteraction]);
|
|
2987
|
+
}, [locale, timezone, emitInteraction, component]);
|
|
2982
2988
|
const handleConfirm = useCallback(() => {
|
|
2983
2989
|
const value24h = componentsTo24h(tempComponents);
|
|
2984
2990
|
const display = formatTimeDisplay(value24h, locale, timezone);
|
|
2985
2991
|
setConfirmedTime(value24h);
|
|
2986
|
-
emitInteraction(value24h, display);
|
|
2992
|
+
emitInteraction(value24h, display, getSubmitActionId(component));
|
|
2987
2993
|
setIsOpen(false);
|
|
2988
|
-
}, [tempComponents, locale, timezone, emitInteraction]);
|
|
2994
|
+
}, [tempComponents, locale, timezone, emitInteraction, component]);
|
|
2989
2995
|
const displayValue = confirmedTime ? formatTimeDisplay(confirmedTime, locale, timezone) : "";
|
|
2990
2996
|
const placeholder = component.props.placeholder || "Selecciona una hora";
|
|
2991
2997
|
const label = component.props.label || "Selecciona una hora";
|
|
@@ -5054,7 +5060,8 @@ const CarouselDisplay = ({
|
|
|
5054
5060
|
actions.selection.toggle(item.id);
|
|
5055
5061
|
emitInteraction(
|
|
5056
5062
|
[{ value: item.id, label: item.title || item.id }],
|
|
5057
|
-
item.title || item.id
|
|
5063
|
+
item.title || item.id,
|
|
5064
|
+
getSubmitActionId(component)
|
|
5058
5065
|
);
|
|
5059
5066
|
return;
|
|
5060
5067
|
}
|
|
@@ -5062,7 +5069,7 @@ const CarouselDisplay = ({
|
|
|
5062
5069
|
actions.selection.toggle(item.id);
|
|
5063
5070
|
}
|
|
5064
5071
|
},
|
|
5065
|
-
[selectionMode, disabled, isConfirmed, actions, emitInteraction]
|
|
5072
|
+
[selectionMode, disabled, isConfirmed, actions, emitInteraction, component]
|
|
5066
5073
|
);
|
|
5067
5074
|
const handleRemove = useCallback(
|
|
5068
5075
|
(item) => {
|
|
@@ -5077,14 +5084,14 @@ const CarouselDisplay = ({
|
|
|
5077
5084
|
const selected = items.filter((i) => selectedIds.includes(i.id));
|
|
5078
5085
|
const value = selected.map((i) => ({ value: i.id, label: i.title || i.id }));
|
|
5079
5086
|
const label = selected.map((i) => i.title || i.id).join(", ");
|
|
5080
|
-
emitInteraction(value, label);
|
|
5087
|
+
emitInteraction(value, label, getSubmitActionId(component));
|
|
5081
5088
|
}
|
|
5082
5089
|
if (selectionMode === "removable") {
|
|
5083
5090
|
const value = items.map((i) => ({ value: i.id, label: i.title || i.id }));
|
|
5084
5091
|
const label = items.map((i) => i.title || i.id).join(", ");
|
|
5085
|
-
emitInteraction(value, label);
|
|
5092
|
+
emitInteraction(value, label, getSubmitActionId(component));
|
|
5086
5093
|
}
|
|
5087
|
-
}, [selectionMode, disabled, isConfirmed, items, selectedIds, emitInteraction]);
|
|
5094
|
+
}, [selectionMode, disabled, isConfirmed, items, selectedIds, emitInteraction, component]);
|
|
5088
5095
|
const confirmDisabled = useMemo(() => {
|
|
5089
5096
|
if (selectionMode === "multiple") return selectedIds.length === 0;
|
|
5090
5097
|
if (selectionMode === "removable") {
|
|
@@ -5140,6 +5147,42 @@ const CarouselDisplay = ({
|
|
|
5140
5147
|
] });
|
|
5141
5148
|
};
|
|
5142
5149
|
|
|
5150
|
+
const ActionMenu = ({
|
|
5151
|
+
component,
|
|
5152
|
+
eventBus,
|
|
5153
|
+
assistantMessageId = ""
|
|
5154
|
+
}) => {
|
|
5155
|
+
const { emitInteraction, isConfirmed } = useComponentInteraction({
|
|
5156
|
+
eventBus,
|
|
5157
|
+
fieldName: component.props.field_name || "action_menu",
|
|
5158
|
+
componentType: component.type,
|
|
5159
|
+
assistantMessageId
|
|
5160
|
+
});
|
|
5161
|
+
if (isConfirmed) return null;
|
|
5162
|
+
const label = component.props.label;
|
|
5163
|
+
const actions = component.actions ?? [];
|
|
5164
|
+
if (actions.length === 0) return null;
|
|
5165
|
+
return /* @__PURE__ */ jsxs(
|
|
5166
|
+
"div",
|
|
5167
|
+
{
|
|
5168
|
+
className: "px-chat-action-menu",
|
|
5169
|
+
style: { display: "flex", flexDirection: "column", gap: "8px" },
|
|
5170
|
+
children: [
|
|
5171
|
+
label && /* @__PURE__ */ jsx("div", { style: { fontWeight: 500 }, children: label }),
|
|
5172
|
+
/* @__PURE__ */ jsx("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" }, children: actions.map((a) => /* @__PURE__ */ jsx(
|
|
5173
|
+
Button$1,
|
|
5174
|
+
{
|
|
5175
|
+
variant: a.intent === "primary" ? "primary" : "secondary",
|
|
5176
|
+
onClick: () => emitInteraction(a.value ?? a.id, a.label, a.id),
|
|
5177
|
+
children: a.label
|
|
5178
|
+
},
|
|
5179
|
+
a.id
|
|
5180
|
+
)) })
|
|
5181
|
+
]
|
|
5182
|
+
}
|
|
5183
|
+
);
|
|
5184
|
+
};
|
|
5185
|
+
|
|
5143
5186
|
const COMPONENT_MAP = {
|
|
5144
5187
|
select: SelectWithConfirm,
|
|
5145
5188
|
select_multiple: SelectMultipleWithConfirm,
|
|
@@ -5150,7 +5193,8 @@ const COMPONENT_MAP = {
|
|
|
5150
5193
|
card: CardDisplay,
|
|
5151
5194
|
badge: BadgeDisplay,
|
|
5152
5195
|
reactive_form: ReactiveForm,
|
|
5153
|
-
carousel: CarouselDisplay
|
|
5196
|
+
carousel: CarouselDisplay,
|
|
5197
|
+
action_menu: ActionMenu
|
|
5154
5198
|
};
|
|
5155
5199
|
function renderComponent(props) {
|
|
5156
5200
|
const { component } = props;
|
package/dist/index.js
CHANGED
|
@@ -1639,6 +1639,11 @@ function parseContent(content) {
|
|
|
1639
1639
|
return null;
|
|
1640
1640
|
}
|
|
1641
1641
|
|
|
1642
|
+
function getSubmitActionId(component) {
|
|
1643
|
+
const actions = component.actions;
|
|
1644
|
+
if (!actions || actions.length === 0) return void 0;
|
|
1645
|
+
return (actions.find((a) => a.kind === "submit") ?? actions[0]).id;
|
|
1646
|
+
}
|
|
1642
1647
|
const TERMINAL_STATUS = /* @__PURE__ */ new Set(["answered", "cancelled", "expired"]);
|
|
1643
1648
|
const DISPLAY_COMPONENTS = /* @__PURE__ */ new Set(["card", "badge", "reactive_form", "carousel"]);
|
|
1644
1649
|
|
|
@@ -2020,7 +2025,7 @@ const SelectWithConfirm = ({
|
|
|
2020
2025
|
});
|
|
2021
2026
|
const handleConfirm = () => {
|
|
2022
2027
|
if (selected) {
|
|
2023
|
-
emitInteraction(selected.value, selected.label);
|
|
2028
|
+
emitInteraction(selected.value, selected.label, getSubmitActionId(component));
|
|
2024
2029
|
setIsDrawerOpen(false);
|
|
2025
2030
|
}
|
|
2026
2031
|
};
|
|
@@ -2223,7 +2228,8 @@ const SelectMultipleWithConfirm = ({
|
|
|
2223
2228
|
if (selectedOptions.length > 0) {
|
|
2224
2229
|
emitInteraction(
|
|
2225
2230
|
selectedOptions.map((o) => o.value),
|
|
2226
|
-
selectedOptions.map((o) => o.label).join(", ")
|
|
2231
|
+
selectedOptions.map((o) => o.label).join(", "),
|
|
2232
|
+
getSubmitActionId(component)
|
|
2227
2233
|
);
|
|
2228
2234
|
setIsDrawerOpen(false);
|
|
2229
2235
|
}
|
|
@@ -2426,7 +2432,7 @@ const InputWithConfirm = ({
|
|
|
2426
2432
|
variant: "primary",
|
|
2427
2433
|
size: "small",
|
|
2428
2434
|
disabled: !inputValue,
|
|
2429
|
-
onClick: () => emitInteraction(inputValue, inputValue),
|
|
2435
|
+
onClick: () => emitInteraction(inputValue, inputValue, getSubmitActionId(component)),
|
|
2430
2436
|
children: "Confirmar"
|
|
2431
2437
|
}
|
|
2432
2438
|
)
|
|
@@ -2569,9 +2575,9 @@ const DateInputWithConfirm = ({
|
|
|
2569
2575
|
if (!selectedDate) return;
|
|
2570
2576
|
const isoValue = formatDateToISO$1(selectedDate);
|
|
2571
2577
|
const displayValue2 = formatDateDisplay$1(selectedDate, locale, timezone);
|
|
2572
|
-
emitInteraction(isoValue, displayValue2);
|
|
2578
|
+
emitInteraction(isoValue, displayValue2, getSubmitActionId(component));
|
|
2573
2579
|
setIsOpen(false);
|
|
2574
|
-
}, [selectedDate, emitInteraction, locale, timezone]);
|
|
2580
|
+
}, [selectedDate, emitInteraction, locale, timezone, component]);
|
|
2575
2581
|
const displayValue = formatDateDisplay$1(selectedDate, locale, timezone);
|
|
2576
2582
|
const placeholder = component.props.placeholder || "Selecciona una fecha";
|
|
2577
2583
|
const label = component.props.label || "Selecciona una fecha";
|
|
@@ -2997,16 +3003,16 @@ const TimeInputWithConfirm = ({
|
|
|
2997
3003
|
const value24h = componentsTo24h(nowComp);
|
|
2998
3004
|
const display = formatTimeDisplay(value24h, locale, timezone);
|
|
2999
3005
|
setConfirmedTime(value24h);
|
|
3000
|
-
emitInteraction(value24h, display);
|
|
3006
|
+
emitInteraction(value24h, display, getSubmitActionId(component));
|
|
3001
3007
|
setIsOpen(false);
|
|
3002
|
-
}, [locale, timezone, emitInteraction]);
|
|
3008
|
+
}, [locale, timezone, emitInteraction, component]);
|
|
3003
3009
|
const handleConfirm = React.useCallback(() => {
|
|
3004
3010
|
const value24h = componentsTo24h(tempComponents);
|
|
3005
3011
|
const display = formatTimeDisplay(value24h, locale, timezone);
|
|
3006
3012
|
setConfirmedTime(value24h);
|
|
3007
|
-
emitInteraction(value24h, display);
|
|
3013
|
+
emitInteraction(value24h, display, getSubmitActionId(component));
|
|
3008
3014
|
setIsOpen(false);
|
|
3009
|
-
}, [tempComponents, locale, timezone, emitInteraction]);
|
|
3015
|
+
}, [tempComponents, locale, timezone, emitInteraction, component]);
|
|
3010
3016
|
const displayValue = confirmedTime ? formatTimeDisplay(confirmedTime, locale, timezone) : "";
|
|
3011
3017
|
const placeholder = component.props.placeholder || "Selecciona una hora";
|
|
3012
3018
|
const label = component.props.label || "Selecciona una hora";
|
|
@@ -5075,7 +5081,8 @@ const CarouselDisplay = ({
|
|
|
5075
5081
|
actions.selection.toggle(item.id);
|
|
5076
5082
|
emitInteraction(
|
|
5077
5083
|
[{ value: item.id, label: item.title || item.id }],
|
|
5078
|
-
item.title || item.id
|
|
5084
|
+
item.title || item.id,
|
|
5085
|
+
getSubmitActionId(component)
|
|
5079
5086
|
);
|
|
5080
5087
|
return;
|
|
5081
5088
|
}
|
|
@@ -5083,7 +5090,7 @@ const CarouselDisplay = ({
|
|
|
5083
5090
|
actions.selection.toggle(item.id);
|
|
5084
5091
|
}
|
|
5085
5092
|
},
|
|
5086
|
-
[selectionMode, disabled, isConfirmed, actions, emitInteraction]
|
|
5093
|
+
[selectionMode, disabled, isConfirmed, actions, emitInteraction, component]
|
|
5087
5094
|
);
|
|
5088
5095
|
const handleRemove = React.useCallback(
|
|
5089
5096
|
(item) => {
|
|
@@ -5098,14 +5105,14 @@ const CarouselDisplay = ({
|
|
|
5098
5105
|
const selected = items.filter((i) => selectedIds.includes(i.id));
|
|
5099
5106
|
const value = selected.map((i) => ({ value: i.id, label: i.title || i.id }));
|
|
5100
5107
|
const label = selected.map((i) => i.title || i.id).join(", ");
|
|
5101
|
-
emitInteraction(value, label);
|
|
5108
|
+
emitInteraction(value, label, getSubmitActionId(component));
|
|
5102
5109
|
}
|
|
5103
5110
|
if (selectionMode === "removable") {
|
|
5104
5111
|
const value = items.map((i) => ({ value: i.id, label: i.title || i.id }));
|
|
5105
5112
|
const label = items.map((i) => i.title || i.id).join(", ");
|
|
5106
|
-
emitInteraction(value, label);
|
|
5113
|
+
emitInteraction(value, label, getSubmitActionId(component));
|
|
5107
5114
|
}
|
|
5108
|
-
}, [selectionMode, disabled, isConfirmed, items, selectedIds, emitInteraction]);
|
|
5115
|
+
}, [selectionMode, disabled, isConfirmed, items, selectedIds, emitInteraction, component]);
|
|
5109
5116
|
const confirmDisabled = React.useMemo(() => {
|
|
5110
5117
|
if (selectionMode === "multiple") return selectedIds.length === 0;
|
|
5111
5118
|
if (selectionMode === "removable") {
|
|
@@ -5161,6 +5168,42 @@ const CarouselDisplay = ({
|
|
|
5161
5168
|
] });
|
|
5162
5169
|
};
|
|
5163
5170
|
|
|
5171
|
+
const ActionMenu = ({
|
|
5172
|
+
component,
|
|
5173
|
+
eventBus,
|
|
5174
|
+
assistantMessageId = ""
|
|
5175
|
+
}) => {
|
|
5176
|
+
const { emitInteraction, isConfirmed } = useComponentInteraction({
|
|
5177
|
+
eventBus,
|
|
5178
|
+
fieldName: component.props.field_name || "action_menu",
|
|
5179
|
+
componentType: component.type,
|
|
5180
|
+
assistantMessageId
|
|
5181
|
+
});
|
|
5182
|
+
if (isConfirmed) return null;
|
|
5183
|
+
const label = component.props.label;
|
|
5184
|
+
const actions = component.actions ?? [];
|
|
5185
|
+
if (actions.length === 0) return null;
|
|
5186
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5187
|
+
"div",
|
|
5188
|
+
{
|
|
5189
|
+
className: "px-chat-action-menu",
|
|
5190
|
+
style: { display: "flex", flexDirection: "column", gap: "8px" },
|
|
5191
|
+
children: [
|
|
5192
|
+
label && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontWeight: 500 }, children: label }),
|
|
5193
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" }, children: actions.map((a) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5194
|
+
Button$1,
|
|
5195
|
+
{
|
|
5196
|
+
variant: a.intent === "primary" ? "primary" : "secondary",
|
|
5197
|
+
onClick: () => emitInteraction(a.value ?? a.id, a.label, a.id),
|
|
5198
|
+
children: a.label
|
|
5199
|
+
},
|
|
5200
|
+
a.id
|
|
5201
|
+
)) })
|
|
5202
|
+
]
|
|
5203
|
+
}
|
|
5204
|
+
);
|
|
5205
|
+
};
|
|
5206
|
+
|
|
5164
5207
|
const COMPONENT_MAP = {
|
|
5165
5208
|
select: SelectWithConfirm,
|
|
5166
5209
|
select_multiple: SelectMultipleWithConfirm,
|
|
@@ -5171,7 +5214,8 @@ const COMPONENT_MAP = {
|
|
|
5171
5214
|
card: CardDisplay,
|
|
5172
5215
|
badge: BadgeDisplay,
|
|
5173
5216
|
reactive_form: ReactiveForm,
|
|
5174
|
-
carousel: CarouselDisplay
|
|
5217
|
+
carousel: CarouselDisplay,
|
|
5218
|
+
action_menu: ActionMenu
|
|
5175
5219
|
};
|
|
5176
5220
|
function renderComponent(props) {
|
|
5177
5221
|
const { component } = props;
|