@inploi/plugin-chatbot 3.12.5 → 3.12.7

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.
@@ -1,4 +1,4 @@
1
- import { _, g as getHeadOrThrow, i as invariant, A as AbortedError, N, a as getFlowSubmissionsPayload, h as hasProp, k as kbToReadableSize, o as o$1, c as clsx, b as a$2, d as _$1, y, F, s as store, p, e as parse, f as picklist, j as h, l as k, m as isSubmissionOfType, C as Cn, n as parseAsync, V as ValiError, q as object, t as transform, r as maxLength, u as minLength, v as record, w as boolean, x as string, z as email, B as url, D as regex, T, E as m, G as AnimatePresence, H as ERROR_MESSAGES } from "./index-b4781911.js";
1
+ import { _, g as getHeadOrThrow, i as invariant, A as AbortedError, N, a as getFlowSubmissionsPayload, h as hasProp, k as kbToReadableSize, o as o$1, c as clsx, b as _$1, y, F, s as store, d as a$2, p, e as parse, f as picklist, j as h, l as k, m as isSubmissionOfType, C as Cn, n as parseAsync, V as ValiError, q as object, t as transform, r as maxLength, u as minLength, v as record, w as boolean, x as string, z as email, B as url, D as regex, T, E as cva, G as ERROR_MESSAGES } from "./index-da27a1bf.js";
2
2
  import "@inploi/sdk";
3
3
  const followNodes = ({
4
4
  node,
@@ -2801,13 +2801,13 @@ const ChatInputSubmit = ({
2801
2801
  return o$1("div", {
2802
2802
  class: "flex flex-col items-center py-3",
2803
2803
  children: o$1("button", {
2804
- class: "bg-accent-9 hover:bg-accent-10 active:bg-submit-bg-active hover:border-accent-10 active:border-submit-bg-active border-accent-9 ring-accent-6 focus-visible:outline-accent-8 ring-offset-neutral-1 group flex cursor-pointer rounded-full border border-solid px-5 py-3 pr-4 text-white shadow-[inset_0px_-6px_2px_-1px_oklch(100_0_0/.45),inset_0px_1px_1px_oklch(100_0_0/.3)] outline-none ring-1 ring-offset-[1.5px] transition-all duration-300 focus-visible:outline-2 active:shadow-[inset_0px_0px_2px_-1px_oklch(100_0_0/.45),inset_0px_3px_1px_.5px_oklch(0_0_0/.08)] active:ring-2 active:ring-offset-2",
2804
+ class: "bg-accent-9 hover:bg-accent-10 active:bg-submit-bg-active hover:border-accent-10 active:border-submit-bg-active border-accent-9 ring-accent-6 focus-visible:outline-accent-8 ring-offset-neutral-1 flex cursor-pointer rounded-full border border-solid px-5 py-3 pr-4 text-white outline-none ring-1 ring-offset-[1.5px] transition-all duration-300 focus-visible:outline-2 active:ring-2 active:ring-offset-2",
2805
2805
  name: input.key,
2806
2806
  onClick: () => {
2807
2807
  onSubmitSuccess(null);
2808
2808
  },
2809
2809
  children: o$1("span", {
2810
- class: "relative bottom-[2px] top-[-2px] flex items-center gap-1.5 transition-all duration-300 group-active:bottom-0 group-active:top-0",
2810
+ class: "flex items-center gap-1.5",
2811
2811
  children: [o$1("span", {
2812
2812
  class: "inline-flex items-center text-sm font-medium",
2813
2813
  children: input.config.label
@@ -2944,34 +2944,40 @@ const ChatInput = () => {
2944
2944
  var _a;
2945
2945
  const input = (_a = store.current$.value.flow) == null ? void 0 : _a.data.currentInput;
2946
2946
  const inputWrapperRef = _$1(null);
2947
+ const inputContentRef = _$1(null);
2947
2948
  const updateHeight = T(() => {
2948
- if (inputWrapperRef.current) {
2949
- store.inputHeight$.value = inputWrapperRef.current.getBoundingClientRect().height;
2949
+ if (inputContentRef.current) {
2950
+ store.inputHeight$.value = inputContentRef.current.getBoundingClientRect().height;
2950
2951
  }
2951
2952
  }, []);
2952
2953
  p(() => {
2953
2954
  updateHeight();
2954
2955
  }, [input == null ? void 0 : input.type, updateHeight]);
2956
+ p(() => {
2957
+ const wrapper = inputWrapperRef.current;
2958
+ if (!wrapper)
2959
+ return;
2960
+ wrapper.addEventListener("transitionstart", chatStore.scrollToEnd.smooth);
2961
+ wrapper.addEventListener("transitioncancel", chatStore.scrollToEnd.smooth);
2962
+ wrapper.addEventListener("transitionend", chatStore.scrollToEnd.smooth);
2963
+ return () => {
2964
+ wrapper.removeEventListener("transitionstart", chatStore.scrollToEnd.smooth);
2965
+ wrapper.removeEventListener("transitioncancel", chatStore.scrollToEnd.smooth);
2966
+ wrapper.removeEventListener("transitionend", chatStore.scrollToEnd.smooth);
2967
+ };
2968
+ }, []);
2955
2969
  const handleSubmitSuccess = (type) => (value) => chatStore.onSubmitSuccessFn$.value({
2956
2970
  type,
2957
2971
  value
2958
2972
  });
2959
- return o$1(m.div, {
2960
- initial: {
2961
- height: 0
2962
- },
2963
- animate: {
2973
+ return o$1("div", {
2974
+ ref: inputWrapperRef,
2975
+ style: {
2964
2976
  height: store.inputHeight$.value
2965
2977
  },
2966
- exit: {
2967
- height: 0,
2968
- opacity: 0
2969
- },
2970
- onAnimationStart: chatStore.scrollToEnd.smooth,
2971
- onAnimationComplete: chatStore.scrollToEnd.smooth,
2972
- class: "bg-statusbar absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-md backdrop-saturate-150",
2978
+ class: "bg-statusbar ease-expo-out absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-md backdrop-saturate-150 transition-all duration-700",
2973
2979
  children: o$1("div", {
2974
- ref: inputWrapperRef,
2980
+ ref: inputContentRef,
2975
2981
  class: "border-divider border-t",
2976
2982
  children: N({
2977
2983
  input,
@@ -3029,101 +3035,36 @@ const ChatInput = () => {
3029
3035
  })
3030
3036
  });
3031
3037
  };
3032
- const falsyToString = (value) => typeof value === "boolean" ? "".concat(value) : value === 0 ? "0" : value;
3033
- const cx = clsx;
3034
- const cva = (base, config) => {
3035
- return (props) => {
3036
- var ref;
3037
- if ((config === null || config === void 0 ? void 0 : config.variants) == null)
3038
- return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
3039
- const { variants, defaultVariants } = config;
3040
- const getVariantClassNames = Object.keys(variants).map((variant) => {
3041
- const variantProp = props === null || props === void 0 ? void 0 : props[variant];
3042
- const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
3043
- if (variantProp === null)
3044
- return null;
3045
- const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
3046
- return variants[variant][variantKey];
3047
- });
3048
- const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param) => {
3049
- let [key, value] = param;
3050
- if (value === void 0) {
3051
- return acc;
3052
- }
3053
- acc[key] = value;
3054
- return acc;
3055
- }, {});
3056
- const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (ref = config.compoundVariants) === null || ref === void 0 ? void 0 : ref.reduce((acc, param1) => {
3057
- let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param1;
3058
- return Object.entries(compoundVariantOptions).every((param) => {
3059
- let [key, value] = param;
3060
- return Array.isArray(value) ? value.includes({
3061
- ...defaultVariants,
3062
- ...propsWithoutUndefined
3063
- }[key]) : {
3064
- ...defaultVariants,
3065
- ...propsWithoutUndefined
3066
- }[key] === value;
3067
- }) ? [
3068
- ...acc,
3069
- cvClass,
3070
- cvClassName
3071
- ] : acc;
3072
- }, []);
3073
- return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
3074
- };
3075
- };
3076
3038
  const chatBubbleVariants = cva("max-w-[min(100%,24rem)] [text-wrap:pretty] leading-snug flex-shrink min-w-[2rem] py-2 px-3 rounded-[18px] min-h-[36px] break-words relative", {
3077
3039
  variants: {
3078
3040
  side: {
3079
3041
  left: "bg-bubble-weak-bg text-neutral-12 shadow-surface-sm outline outline-1 outline-bubble-weak rounded-bl-md",
3080
3042
  right: "ml-auto bg-accent-9 text-white rounded-br-md shadow-surface-sm shadow-bubble-strong-shadow"
3081
3043
  },
3082
- transitionState: {
3083
- entering: "opacity-0 translate-y-8",
3084
- entered: "opacity-100 translate-y-0",
3085
- exiting: "opacity-0 scale-0",
3086
- exited: ""
3044
+ animate: {
3045
+ true: "animate-bubble-in",
3046
+ false: ""
3087
3047
  }
3088
3048
  },
3089
3049
  defaultVariants: {
3090
3050
  side: "left"
3091
3051
  }
3092
3052
  });
3093
- const motionVariants = {
3094
- hidden: {
3095
- y: "100%",
3096
- scale: 0.75
3097
- },
3098
- shown: {
3099
- y: 0,
3100
- scale: 1
3101
- }
3102
- };
3103
3053
  const ChatBubble = ({
3104
3054
  children,
3105
3055
  className,
3106
- transitionState,
3056
+ animate,
3107
3057
  side,
3108
3058
  ...props
3109
3059
  }) => {
3110
- return o$1(m.p, {
3111
- variants: motionVariants,
3112
- initial: "hidden",
3113
- animate: "shown",
3114
- transition: {
3115
- type: "spring",
3116
- damping: 25,
3117
- stiffness: 500
3118
- },
3119
- "data-transition": transitionState,
3060
+ return o$1("p", {
3120
3061
  style: {
3121
3062
  transformOrigin: side === "left" ? "0% 50%" : "100% 50%"
3122
3063
  },
3123
3064
  class: chatBubbleVariants({
3124
3065
  className,
3125
3066
  side,
3126
- transitionState
3067
+ animate
3127
3068
  }),
3128
3069
  ...props,
3129
3070
  children
@@ -3178,75 +3119,74 @@ const Conversation = ({
3178
3119
  return o$1("ol", {
3179
3120
  "aria-label": "Chat messages",
3180
3121
  class: "flex flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",
3181
- children: [o$1(AnimatePresence, {
3182
- initial: false,
3183
- children: messages.map((message, i2) => {
3184
- return o$1(k, {
3185
- children: o$1("li", {
3186
- class: "flex",
3187
- children: N(message).with({
3188
- type: "system"
3189
- }, (message2) => o$1("p", {
3190
- class: systemMessageStyle({
3191
- variant: message2.variant
3192
- }),
3193
- children: message2.text
3194
- })).with({
3195
- type: "text",
3196
- author: _.union("bot", "user")
3197
- }, (message2) => {
3198
- const isLastSentMessage = message2.author === "user" && !messages.slice(i2 + 1).some((m2) => m2.type === "text" && m2.author === "user");
3199
- return o$1(ChatBubble, {
3200
- side: authorToSide[message2.author],
3201
- children: [message2.text, isLastSentMessage ? lastSentMessageFooter : null]
3202
- }, i2);
3203
- }).with({
3204
- type: "link"
3205
- }, (message2) => {
3206
- return o$1("div", {
3207
- class: "bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",
3208
- children: o$1("a", {
3209
- class: "bg-lowest shadow-surface-sm ring-accent-6 hover:ring-accent-8 active:bg-accent-2 active:text-accent-10 text-accent-9 focus-visible:ring-accent-7/50 text-wrap-balance flex items-center gap-1.5 rounded-full py-2 pl-4 pr-2.5 text-center no-underline ring-1 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2",
3210
- target: "_blank",
3211
- href: message2.href,
3212
- children: [message2.text, o$1("svg", {
3213
- class: "flex-none",
3214
- width: "15",
3215
- height: "15",
3216
- viewBox: "0 0 15 15",
3217
- fill: "none",
3218
- xmlns: "http://www.w3.org/2000/svg",
3219
- children: o$1("path", {
3220
- d: "M3.64645 11.3536C3.45118 11.1583 3.45118 10.8417 3.64645 10.6465L10.2929 4L6 4C5.72386 4 5.5 3.77614 5.5 3.5C5.5 3.22386 5.72386 3 6 3L11.5 3C11.6326 3 11.7598 3.05268 11.8536 3.14645C11.9473 3.24022 12 3.36739 12 3.5L12 9.00001C12 9.27615 11.7761 9.50001 11.5 9.50001C11.2239 9.50001 11 9.27615 11 9.00001V4.70711L4.35355 11.3536C4.15829 11.5488 3.84171 11.5488 3.64645 11.3536Z",
3221
- fill: "currentColor",
3222
- "fill-rule": "evenodd",
3223
- "clip-rule": "evenodd"
3224
- })
3225
- })]
3226
- })
3227
- });
3228
- }).with({
3229
- type: "image"
3230
- }, (image) => o$1("img", {
3231
- class: "shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",
3232
- src: image.url,
3233
- style: {
3234
- aspectRatio: image.width / image.height
3122
+ children: [messages.map((message, i2) => {
3123
+ return o$1(k, {
3124
+ children: o$1("li", {
3125
+ class: "flex",
3126
+ children: N(message).with({
3127
+ type: "system"
3128
+ }, (message2) => o$1("p", {
3129
+ class: systemMessageStyle({
3130
+ variant: message2.variant
3131
+ }),
3132
+ children: message2.text
3133
+ })).with({
3134
+ type: "text",
3135
+ author: _.union("bot", "user")
3136
+ }, (message2) => {
3137
+ const isLastSentMessage = message2.author === "user" && !messages.slice(i2 + 1).some((m) => m.type === "text" && m.author === "user");
3138
+ const isLastMessage = i2 === messages.length - 1;
3139
+ return o$1(ChatBubble, {
3140
+ animate: isLastMessage,
3141
+ side: authorToSide[message2.author],
3142
+ children: [message2.text, isLastSentMessage ? lastSentMessageFooter : null]
3143
+ }, i2);
3144
+ }).with({
3145
+ type: "link"
3146
+ }, (message2) => {
3147
+ return o$1("div", {
3148
+ class: "bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",
3149
+ children: o$1("a", {
3150
+ class: "bg-lowest shadow-surface-sm ring-accent-6 hover:ring-accent-8 active:bg-accent-2 active:text-accent-10 text-accent-9 focus-visible:ring-accent-7/50 text-wrap-balance flex items-center gap-1.5 rounded-full py-2 pl-4 pr-2.5 text-center no-underline ring-1 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2",
3151
+ target: "_blank",
3152
+ href: message2.href,
3153
+ children: [message2.text, o$1("svg", {
3154
+ class: "flex-none",
3155
+ width: "15",
3156
+ height: "15",
3157
+ viewBox: "0 0 15 15",
3158
+ fill: "none",
3159
+ xmlns: "http://www.w3.org/2000/svg",
3160
+ children: o$1("path", {
3161
+ d: "M3.64645 11.3536C3.45118 11.1583 3.45118 10.8417 3.64645 10.6465L10.2929 4L6 4C5.72386 4 5.5 3.77614 5.5 3.5C5.5 3.22386 5.72386 3 6 3L11.5 3C11.6326 3 11.7598 3.05268 11.8536 3.14645C11.9473 3.24022 12 3.36739 12 3.5L12 9.00001C12 9.27615 11.7761 9.50001 11.5 9.50001C11.2239 9.50001 11 9.27615 11 9.00001V4.70711L4.35355 11.3536C4.15829 11.5488 3.84171 11.5488 3.64645 11.3536Z",
3162
+ fill: "currentColor",
3163
+ "fill-rule": "evenodd",
3164
+ "clip-rule": "evenodd"
3165
+ })
3166
+ })]
3167
+ })
3168
+ });
3169
+ }).with({
3170
+ type: "image"
3171
+ }, (image) => o$1("img", {
3172
+ class: "shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",
3173
+ src: image.url,
3174
+ style: {
3175
+ aspectRatio: image.width / image.height
3176
+ }
3177
+ })).with({
3178
+ type: "file"
3179
+ }, (file) => {
3180
+ return o$1(FileThumbnail, {
3181
+ class: file.author === "bot" ? "" : "ml-auto",
3182
+ file: {
3183
+ name: file.fileName,
3184
+ sizeKb: file.fileSizeKb
3235
3185
  }
3236
- })).with({
3237
- type: "file"
3238
- }, (file) => {
3239
- return o$1(FileThumbnail, {
3240
- class: file.author === "bot" ? "" : "ml-auto",
3241
- file: {
3242
- name: file.fileName,
3243
- sizeKb: file.fileSizeKb
3244
- }
3245
- });
3246
- }).exhaustive()
3247
- })
3248
- }, i2);
3249
- })
3186
+ });
3187
+ }).exhaustive()
3188
+ })
3189
+ }, i2);
3250
3190
  }), o$1(TypingIndicator, {}, "typing")]
3251
3191
  });
3252
3192
  };
@@ -3290,7 +3230,8 @@ const ChatbotBody = ({
3290
3230
  flow_id: flow.id,
3291
3231
  flow_version: flow.version,
3292
3232
  flow_session_id: currentApplication.data.flowSessionId
3293
- }
3233
+ },
3234
+ customProperties: flow.context
3294
3235
  });
3295
3236
  } else {
3296
3237
  store.removeMessagesSentByNodeIds([fromNodeId]);