@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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-395856be.cjs");
3
+ const index = require("./index-0fac2e23.cjs");
4
4
  require("@inploi/sdk");
5
5
  const followNodes = ({
6
6
  node,
@@ -2803,13 +2803,13 @@ const ChatInputSubmit = ({
2803
2803
  return index.o("div", {
2804
2804
  class: "flex flex-col items-center py-3",
2805
2805
  children: index.o("button", {
2806
- 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",
2806
+ 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",
2807
2807
  name: input.key,
2808
2808
  onClick: () => {
2809
2809
  onSubmitSuccess(null);
2810
2810
  },
2811
2811
  children: index.o("span", {
2812
- class: "relative bottom-[2px] top-[-2px] flex items-center gap-1.5 transition-all duration-300 group-active:bottom-0 group-active:top-0",
2812
+ class: "flex items-center gap-1.5",
2813
2813
  children: [index.o("span", {
2814
2814
  class: "inline-flex items-center text-sm font-medium",
2815
2815
  children: input.config.label
@@ -2946,34 +2946,40 @@ const ChatInput = () => {
2946
2946
  var _a;
2947
2947
  const input = (_a = index.store.current$.value.flow) == null ? void 0 : _a.data.currentInput;
2948
2948
  const inputWrapperRef = index._$1(null);
2949
+ const inputContentRef = index._$1(null);
2949
2950
  const updateHeight = index.T(() => {
2950
- if (inputWrapperRef.current) {
2951
- index.store.inputHeight$.value = inputWrapperRef.current.getBoundingClientRect().height;
2951
+ if (inputContentRef.current) {
2952
+ index.store.inputHeight$.value = inputContentRef.current.getBoundingClientRect().height;
2952
2953
  }
2953
2954
  }, []);
2954
2955
  index.p(() => {
2955
2956
  updateHeight();
2956
2957
  }, [input == null ? void 0 : input.type, updateHeight]);
2958
+ index.p(() => {
2959
+ const wrapper = inputWrapperRef.current;
2960
+ if (!wrapper)
2961
+ return;
2962
+ wrapper.addEventListener("transitionstart", chatStore.scrollToEnd.smooth);
2963
+ wrapper.addEventListener("transitioncancel", chatStore.scrollToEnd.smooth);
2964
+ wrapper.addEventListener("transitionend", chatStore.scrollToEnd.smooth);
2965
+ return () => {
2966
+ wrapper.removeEventListener("transitionstart", chatStore.scrollToEnd.smooth);
2967
+ wrapper.removeEventListener("transitioncancel", chatStore.scrollToEnd.smooth);
2968
+ wrapper.removeEventListener("transitionend", chatStore.scrollToEnd.smooth);
2969
+ };
2970
+ }, []);
2957
2971
  const handleSubmitSuccess = (type) => (value) => chatStore.onSubmitSuccessFn$.value({
2958
2972
  type,
2959
2973
  value
2960
2974
  });
2961
- return index.o(index.m.div, {
2962
- initial: {
2963
- height: 0
2964
- },
2965
- animate: {
2975
+ return index.o("div", {
2976
+ ref: inputWrapperRef,
2977
+ style: {
2966
2978
  height: index.store.inputHeight$.value
2967
2979
  },
2968
- exit: {
2969
- height: 0,
2970
- opacity: 0
2971
- },
2972
- onAnimationStart: chatStore.scrollToEnd.smooth,
2973
- onAnimationComplete: chatStore.scrollToEnd.smooth,
2974
- class: "bg-statusbar absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-md backdrop-saturate-150",
2980
+ 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",
2975
2981
  children: index.o("div", {
2976
- ref: inputWrapperRef,
2982
+ ref: inputContentRef,
2977
2983
  class: "border-divider border-t",
2978
2984
  children: index.N({
2979
2985
  input,
@@ -3031,101 +3037,36 @@ const ChatInput = () => {
3031
3037
  })
3032
3038
  });
3033
3039
  };
3034
- const falsyToString = (value) => typeof value === "boolean" ? "".concat(value) : value === 0 ? "0" : value;
3035
- const cx = index.clsx;
3036
- const cva = (base, config) => {
3037
- return (props) => {
3038
- var ref;
3039
- if ((config === null || config === void 0 ? void 0 : config.variants) == null)
3040
- return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
3041
- const { variants, defaultVariants } = config;
3042
- const getVariantClassNames = Object.keys(variants).map((variant) => {
3043
- const variantProp = props === null || props === void 0 ? void 0 : props[variant];
3044
- const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
3045
- if (variantProp === null)
3046
- return null;
3047
- const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
3048
- return variants[variant][variantKey];
3049
- });
3050
- const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param) => {
3051
- let [key, value] = param;
3052
- if (value === void 0) {
3053
- return acc;
3054
- }
3055
- acc[key] = value;
3056
- return acc;
3057
- }, {});
3058
- const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (ref = config.compoundVariants) === null || ref === void 0 ? void 0 : ref.reduce((acc, param1) => {
3059
- let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param1;
3060
- return Object.entries(compoundVariantOptions).every((param) => {
3061
- let [key, value] = param;
3062
- return Array.isArray(value) ? value.includes({
3063
- ...defaultVariants,
3064
- ...propsWithoutUndefined
3065
- }[key]) : {
3066
- ...defaultVariants,
3067
- ...propsWithoutUndefined
3068
- }[key] === value;
3069
- }) ? [
3070
- ...acc,
3071
- cvClass,
3072
- cvClassName
3073
- ] : acc;
3074
- }, []);
3075
- return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
3076
- };
3077
- };
3078
- 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", {
3040
+ const chatBubbleVariants = index.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", {
3079
3041
  variants: {
3080
3042
  side: {
3081
3043
  left: "bg-bubble-weak-bg text-neutral-12 shadow-surface-sm outline outline-1 outline-bubble-weak rounded-bl-md",
3082
3044
  right: "ml-auto bg-accent-9 text-white rounded-br-md shadow-surface-sm shadow-bubble-strong-shadow"
3083
3045
  },
3084
- transitionState: {
3085
- entering: "opacity-0 translate-y-8",
3086
- entered: "opacity-100 translate-y-0",
3087
- exiting: "opacity-0 scale-0",
3088
- exited: ""
3046
+ animate: {
3047
+ true: "animate-bubble-in",
3048
+ false: ""
3089
3049
  }
3090
3050
  },
3091
3051
  defaultVariants: {
3092
3052
  side: "left"
3093
3053
  }
3094
3054
  });
3095
- const motionVariants = {
3096
- hidden: {
3097
- y: "100%",
3098
- scale: 0.75
3099
- },
3100
- shown: {
3101
- y: 0,
3102
- scale: 1
3103
- }
3104
- };
3105
3055
  const ChatBubble = ({
3106
3056
  children,
3107
3057
  className,
3108
- transitionState,
3058
+ animate,
3109
3059
  side,
3110
3060
  ...props
3111
3061
  }) => {
3112
- return index.o(index.m.p, {
3113
- variants: motionVariants,
3114
- initial: "hidden",
3115
- animate: "shown",
3116
- transition: {
3117
- type: "spring",
3118
- damping: 25,
3119
- stiffness: 500
3120
- },
3121
- "data-transition": transitionState,
3062
+ return index.o("p", {
3122
3063
  style: {
3123
3064
  transformOrigin: side === "left" ? "0% 50%" : "100% 50%"
3124
3065
  },
3125
3066
  class: chatBubbleVariants({
3126
3067
  className,
3127
3068
  side,
3128
- transitionState
3069
+ animate
3129
3070
  }),
3130
3071
  ...props,
3131
3072
  children
@@ -3159,7 +3100,7 @@ const authorToSide = {
3159
3100
  bot: "left",
3160
3101
  user: "right"
3161
3102
  };
3162
- const systemMessageStyle = cva("w-full select-none py-2 text-wrap-balance text-center text-[10px] uppercase tracking-widest drop-shadow-[0_1.5px_var(--i-color-n-1)]", {
3103
+ const systemMessageStyle = index.cva("w-full select-none py-2 text-wrap-balance text-center text-[10px] uppercase tracking-widest drop-shadow-[0_1.5px_var(--i-color-n-1)]", {
3163
3104
  variants: {
3164
3105
  variant: {
3165
3106
  info: "text-neutral-8",
@@ -3180,75 +3121,74 @@ const Conversation = ({
3180
3121
  return index.o("ol", {
3181
3122
  "aria-label": "Chat messages",
3182
3123
  class: "flex flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",
3183
- children: [index.o(index.AnimatePresence, {
3184
- initial: false,
3185
- children: messages.map((message, i2) => {
3186
- return index.o(index.k, {
3187
- children: index.o("li", {
3188
- class: "flex",
3189
- children: index.N(message).with({
3190
- type: "system"
3191
- }, (message2) => index.o("p", {
3192
- class: systemMessageStyle({
3193
- variant: message2.variant
3194
- }),
3195
- children: message2.text
3196
- })).with({
3197
- type: "text",
3198
- author: index._.union("bot", "user")
3199
- }, (message2) => {
3200
- const isLastSentMessage = message2.author === "user" && !messages.slice(i2 + 1).some((m) => m.type === "text" && m.author === "user");
3201
- return index.o(ChatBubble, {
3202
- side: authorToSide[message2.author],
3203
- children: [message2.text, isLastSentMessage ? lastSentMessageFooter : null]
3204
- }, i2);
3205
- }).with({
3206
- type: "link"
3207
- }, (message2) => {
3208
- return index.o("div", {
3209
- class: "bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",
3210
- children: index.o("a", {
3211
- 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",
3212
- target: "_blank",
3213
- href: message2.href,
3214
- children: [message2.text, index.o("svg", {
3215
- class: "flex-none",
3216
- width: "15",
3217
- height: "15",
3218
- viewBox: "0 0 15 15",
3219
- fill: "none",
3220
- xmlns: "http://www.w3.org/2000/svg",
3221
- children: index.o("path", {
3222
- 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",
3223
- fill: "currentColor",
3224
- "fill-rule": "evenodd",
3225
- "clip-rule": "evenodd"
3226
- })
3227
- })]
3228
- })
3229
- });
3230
- }).with({
3231
- type: "image"
3232
- }, (image) => index.o("img", {
3233
- class: "shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",
3234
- src: image.url,
3235
- style: {
3236
- aspectRatio: image.width / image.height
3124
+ children: [messages.map((message, i2) => {
3125
+ return index.o(index.k, {
3126
+ children: index.o("li", {
3127
+ class: "flex",
3128
+ children: index.N(message).with({
3129
+ type: "system"
3130
+ }, (message2) => index.o("p", {
3131
+ class: systemMessageStyle({
3132
+ variant: message2.variant
3133
+ }),
3134
+ children: message2.text
3135
+ })).with({
3136
+ type: "text",
3137
+ author: index._.union("bot", "user")
3138
+ }, (message2) => {
3139
+ const isLastSentMessage = message2.author === "user" && !messages.slice(i2 + 1).some((m) => m.type === "text" && m.author === "user");
3140
+ const isLastMessage = i2 === messages.length - 1;
3141
+ return index.o(ChatBubble, {
3142
+ animate: isLastMessage,
3143
+ side: authorToSide[message2.author],
3144
+ children: [message2.text, isLastSentMessage ? lastSentMessageFooter : null]
3145
+ }, i2);
3146
+ }).with({
3147
+ type: "link"
3148
+ }, (message2) => {
3149
+ return index.o("div", {
3150
+ class: "bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",
3151
+ children: index.o("a", {
3152
+ 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",
3153
+ target: "_blank",
3154
+ href: message2.href,
3155
+ children: [message2.text, index.o("svg", {
3156
+ class: "flex-none",
3157
+ width: "15",
3158
+ height: "15",
3159
+ viewBox: "0 0 15 15",
3160
+ fill: "none",
3161
+ xmlns: "http://www.w3.org/2000/svg",
3162
+ children: index.o("path", {
3163
+ 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",
3164
+ fill: "currentColor",
3165
+ "fill-rule": "evenodd",
3166
+ "clip-rule": "evenodd"
3167
+ })
3168
+ })]
3169
+ })
3170
+ });
3171
+ }).with({
3172
+ type: "image"
3173
+ }, (image) => index.o("img", {
3174
+ class: "shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",
3175
+ src: image.url,
3176
+ style: {
3177
+ aspectRatio: image.width / image.height
3178
+ }
3179
+ })).with({
3180
+ type: "file"
3181
+ }, (file) => {
3182
+ return index.o(FileThumbnail, {
3183
+ class: file.author === "bot" ? "" : "ml-auto",
3184
+ file: {
3185
+ name: file.fileName,
3186
+ sizeKb: file.fileSizeKb
3237
3187
  }
3238
- })).with({
3239
- type: "file"
3240
- }, (file) => {
3241
- return index.o(FileThumbnail, {
3242
- class: file.author === "bot" ? "" : "ml-auto",
3243
- file: {
3244
- name: file.fileName,
3245
- sizeKb: file.fileSizeKb
3246
- }
3247
- });
3248
- }).exhaustive()
3249
- })
3250
- }, i2);
3251
- })
3188
+ });
3189
+ }).exhaustive()
3190
+ })
3191
+ }, i2);
3252
3192
  }), index.o(TypingIndicator, {}, "typing")]
3253
3193
  });
3254
3194
  };
@@ -3292,7 +3232,8 @@ const ChatbotBody = ({
3292
3232
  flow_id: flow.id,
3293
3233
  flow_version: flow.version,
3294
3234
  flow_session_id: currentApplication.data.flowSessionId
3295
- }
3235
+ },
3236
+ customProperties: flow.context
3296
3237
  });
3297
3238
  } else {
3298
3239
  index.store.removeMessagesSentByNodeIds([fromNodeId]);