@mahatisystems/mahati-ui-components 6.0.1 → 6.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/dist/index.d.mts CHANGED
@@ -906,14 +906,20 @@ type Props = {
906
906
  title?: string;
907
907
  ratingType?: "emoji" | "star";
908
908
  optionalRating?: boolean;
909
+ sessionData?: {
910
+ label: string;
911
+ value: string | number | null;
912
+ }[];
909
913
  };
910
- declare function AdvancedFeedbackModal({ isOpen, onClose, onSubmit, maxChars, title, ratingType, optionalRating, }: Props): react_jsx_runtime.JSX.Element;
914
+ declare function AdvancedFeedbackModal({ isOpen, onClose, onSubmit, maxChars, title, ratingType, optionalRating, sessionData, }: Props): react_jsx_runtime.JSX.Element;
911
915
 
912
916
  interface MahatiChatbotProps {
913
917
  isOpen: boolean;
914
918
  onClose: () => void;
919
+ onSend?: (msg: any) => void;
920
+ showForm?: boolean;
915
921
  title?: string;
916
922
  }
917
- declare function Chatbot({ isOpen, onClose, title }: MahatiChatbotProps): React__default.ReactPortal | null;
923
+ declare function Chatbot({ isOpen, onClose, showForm, title, onSend, }: MahatiChatbotProps): React__default.ReactPortal | null;
918
924
 
919
925
  export { Accordion, type AccordionProps, type AvatarOption, type CalendarDate, type CalendarDateRange, type CalendarProps, type CalendarTime, CardOverlayLoader, CardWithLoading, CircularSpinner, DEFAULT_ACTIVITY_OPTIONS, DEFAULT_STATUS_OPTIONS, type FieldSize, Filter$1 as Filter, type FilterValues, LoadingDots, LoadingDotsLinear, MahatiActivity, type MahatiActivityProps, Chatbot as MahatiAdvancedChatbotModal, AdvancedFeedbackModal as MahatiAdvancedFeedbackModal, AsyncDropdown as MahatiAsyncDropdown, AvatarDropdown as MahatiAvatarDropdown, AvatarMultiSelectDropdown as MahatiAvatarMultiSelectDropdown, Button as MahatiButton, Calendar as MahatiCalendar, MahatiCameraAccessModal, Card as MahatiCard, CascadingDropdown as MahatiCascadingDropdown, MahatiChartAnalyticsWidget, ConfettiExplosion as MahatiConfettiExplosion, Dropdown as MahatiDropdown, FormContainer as MahatiFormContainer, GroupedDropdown as MahatiGroupedDropdown, Input as MahatiInput, MahatiLocationAccessModal, MahatiMicrophoneAccessModal, Modal as MahatiModal, MultiSelectDropdown as MahatiMultiSelectDropdown, MahatiNotificationCard, MahatiPromotionModal as MahatiPromotionModal_V1, MahatiPromotionModalV2Modal as MahatiPromotionModal_V2, MahatiPromotionModalV3Modal as MahatiPromotionModal_V3, RealisticConfetti as MahatiRealisticConfetti, MahatiSearch, type MahatiSearchProps, SearchableDropdown as MahatiSearchableDropdown, MahatiStatus, type MahatiStatusProps, TabbedInterface as MahatiTabbedInterface, Table as MahatiTable, TableWithTab as MahatiTableWithTab, TexttoAudio as MahatiTexttoAudio, ToastMessage as MahatiToastMessage, Tooltip as MahatiTooltip, type SelectOption, Spinner };
package/dist/index.d.ts CHANGED
@@ -906,14 +906,20 @@ type Props = {
906
906
  title?: string;
907
907
  ratingType?: "emoji" | "star";
908
908
  optionalRating?: boolean;
909
+ sessionData?: {
910
+ label: string;
911
+ value: string | number | null;
912
+ }[];
909
913
  };
910
- declare function AdvancedFeedbackModal({ isOpen, onClose, onSubmit, maxChars, title, ratingType, optionalRating, }: Props): react_jsx_runtime.JSX.Element;
914
+ declare function AdvancedFeedbackModal({ isOpen, onClose, onSubmit, maxChars, title, ratingType, optionalRating, sessionData, }: Props): react_jsx_runtime.JSX.Element;
911
915
 
912
916
  interface MahatiChatbotProps {
913
917
  isOpen: boolean;
914
918
  onClose: () => void;
919
+ onSend?: (msg: any) => void;
920
+ showForm?: boolean;
915
921
  title?: string;
916
922
  }
917
- declare function Chatbot({ isOpen, onClose, title }: MahatiChatbotProps): React__default.ReactPortal | null;
923
+ declare function Chatbot({ isOpen, onClose, showForm, title, onSend, }: MahatiChatbotProps): React__default.ReactPortal | null;
918
924
 
919
925
  export { Accordion, type AccordionProps, type AvatarOption, type CalendarDate, type CalendarDateRange, type CalendarProps, type CalendarTime, CardOverlayLoader, CardWithLoading, CircularSpinner, DEFAULT_ACTIVITY_OPTIONS, DEFAULT_STATUS_OPTIONS, type FieldSize, Filter$1 as Filter, type FilterValues, LoadingDots, LoadingDotsLinear, MahatiActivity, type MahatiActivityProps, Chatbot as MahatiAdvancedChatbotModal, AdvancedFeedbackModal as MahatiAdvancedFeedbackModal, AsyncDropdown as MahatiAsyncDropdown, AvatarDropdown as MahatiAvatarDropdown, AvatarMultiSelectDropdown as MahatiAvatarMultiSelectDropdown, Button as MahatiButton, Calendar as MahatiCalendar, MahatiCameraAccessModal, Card as MahatiCard, CascadingDropdown as MahatiCascadingDropdown, MahatiChartAnalyticsWidget, ConfettiExplosion as MahatiConfettiExplosion, Dropdown as MahatiDropdown, FormContainer as MahatiFormContainer, GroupedDropdown as MahatiGroupedDropdown, Input as MahatiInput, MahatiLocationAccessModal, MahatiMicrophoneAccessModal, Modal as MahatiModal, MultiSelectDropdown as MahatiMultiSelectDropdown, MahatiNotificationCard, MahatiPromotionModal as MahatiPromotionModal_V1, MahatiPromotionModalV2Modal as MahatiPromotionModal_V2, MahatiPromotionModalV3Modal as MahatiPromotionModal_V3, RealisticConfetti as MahatiRealisticConfetti, MahatiSearch, type MahatiSearchProps, SearchableDropdown as MahatiSearchableDropdown, MahatiStatus, type MahatiStatusProps, TabbedInterface as MahatiTabbedInterface, Table as MahatiTable, TableWithTab as MahatiTableWithTab, TexttoAudio as MahatiTexttoAudio, ToastMessage as MahatiToastMessage, Tooltip as MahatiTooltip, type SelectOption, Spinner };
package/dist/index.js CHANGED
@@ -13360,7 +13360,7 @@ var ratings = [
13360
13360
  }
13361
13361
  ];
13362
13362
  function AdvancedFeedbackModal(param) {
13363
- var isOpen = param.isOpen, onClose = param.onClose, onSubmit = param.onSubmit, _param_maxChars = param.maxChars, maxChars = _param_maxChars === void 0 ? 200 : _param_maxChars, _param_title = param.title, title = _param_title === void 0 ? "Share Your Feedback" : _param_title, _param_ratingType = param.ratingType, ratingType = _param_ratingType === void 0 ? "emoji" : _param_ratingType, _param_optionalRating = param.optionalRating, optionalRating = _param_optionalRating === void 0 ? false : _param_optionalRating;
13363
+ var isOpen = param.isOpen, onClose = param.onClose, onSubmit = param.onSubmit, _param_maxChars = param.maxChars, maxChars = _param_maxChars === void 0 ? 200 : _param_maxChars, _param_title = param.title, title = _param_title === void 0 ? "Share Your Feedback" : _param_title, _param_ratingType = param.ratingType, ratingType = _param_ratingType === void 0 ? "emoji" : _param_ratingType, _param_optionalRating = param.optionalRating, optionalRating = _param_optionalRating === void 0 ? false : _param_optionalRating, sessionData = param.sessionData;
13364
13364
  var _ref = _sliced_to_array((0, import_react25.useState)("rating"), 2), step = _ref[0], setStep = _ref[1];
13365
13365
  var _ref1 = _sliced_to_array((0, import_react25.useState)(null), 2), rating = _ref1[0], setRating = _ref1[1];
13366
13366
  var _ref2 = _sliced_to_array((0, import_react25.useState)(""), 2), message = _ref2[0], setMessage = _ref2[1];
@@ -13368,11 +13368,12 @@ function AdvancedFeedbackModal(param) {
13368
13368
  var _ref4 = _sliced_to_array((0, import_react25.useState)(false), 2), showForm = _ref4[0], setShowForm = _ref4[1];
13369
13369
  var _ref5 = _sliced_to_array((0, import_react25.useState)(null), 2), emojiRating = _ref5[0], setEmojiRating = _ref5[1];
13370
13370
  var remaining = maxChars - message.length;
13371
- var isValid = optionalRating ? message.trim().length > 0 : rating !== null && message.trim().length > 0;
13371
+ var isValid = optionalRating ? message.trim().length > 0 : (rating !== null || emojiRating !== null) && message.trim().length > 0;
13372
13372
  var handleSubmit = function handleSubmit() {
13373
- if (!optionalRating && !rating) return;
13373
+ var _ref;
13374
+ if (!optionalRating && !(rating || emojiRating)) return;
13374
13375
  onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit({
13375
- rating: rating !== null && rating !== void 0 ? rating : 0,
13376
+ rating: (_ref = rating !== null && rating !== void 0 ? rating : emojiRating) !== null && _ref !== void 0 ? _ref : 0,
13376
13377
  feedback: message
13377
13378
  });
13378
13379
  setStep("success");
@@ -13380,6 +13381,9 @@ function AdvancedFeedbackModal(param) {
13380
13381
  var resetAndClose = function resetAndClose() {
13381
13382
  setStep("rating");
13382
13383
  setRating(null);
13384
+ setEmojiRating(null);
13385
+ setShowConfirm(false);
13386
+ setShowForm(false);
13383
13387
  setMessage("");
13384
13388
  onClose();
13385
13389
  };
@@ -13428,6 +13432,25 @@ function AdvancedFeedbackModal(param) {
13428
13432
  className: "absolute top-4 right-4 text-gray-500 hover:text-black z-10",
13429
13433
  children: "\u2715"
13430
13434
  }),
13435
+ step !== "rating" && step !== "success" && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("button", {
13436
+ onClick: function onClick() {
13437
+ if (step === "form") {
13438
+ setStep("confirm");
13439
+ setShowForm(false);
13440
+ } else if (step === "confirm") {
13441
+ setStep("emoji");
13442
+ setShowConfirm(false);
13443
+ } else if (step === "emoji") {
13444
+ setStep("rating");
13445
+ setEmojiRating(null);
13446
+ setRating(null);
13447
+ }
13448
+ },
13449
+ className: "absolute top-4 left-4 text-gray-500 hover:text-black z-10",
13450
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_lucide_react7.ArrowLeft, {
13451
+ size: 20
13452
+ })
13453
+ }),
13431
13454
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", {
13432
13455
  className: "absolute -top-20 -left-20 w-60 h-60 bg-[#1761a3]/20 rounded-full blur-3xl"
13433
13456
  }),
@@ -13435,7 +13458,7 @@ function AdvancedFeedbackModal(param) {
13435
13458
  className: "absolute -bottom-20 -right-20 w-60 h-60 bg-[#1761a3]/20 rounded-full blur-3xl"
13436
13459
  }),
13437
13460
  /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", {
13438
- className: "relative p-6 md:p-8 min-h-[350px] flex flex-col justify-start",
13461
+ className: "relative p-6 md:p-8 min-h-[350px] flex flex-col justify-center",
13439
13462
  children: [
13440
13463
  step !== "success" && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, {
13441
13464
  children: [
@@ -13468,6 +13491,7 @@ function AdvancedFeedbackModal(param) {
13468
13491
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("button", {
13469
13492
  onClick: function onClick() {
13470
13493
  setRating(star);
13494
+ setStep("emoji");
13471
13495
  },
13472
13496
  className: "transition-transform hover:scale-110",
13473
13497
  children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", {
@@ -13488,6 +13512,7 @@ function AdvancedFeedbackModal(param) {
13488
13512
  onClick: function onClick() {
13489
13513
  setEmojiRating(item.id);
13490
13514
  setShowConfirm(true);
13515
+ setStep("confirm");
13491
13516
  },
13492
13517
  className: "flex flex-col items-center gap-1 flex-1 py-3 rounded-xl transition-all duration-300\n ".concat(isActive ? "bg-gradient-to-r from-[#16a34a] to-[#1761a3] text-white scale-105 shadow-md" : "text-gray-500 hover:bg-mahati-light"),
13493
13518
  children: [
@@ -13517,7 +13542,8 @@ function AdvancedFeedbackModal(param) {
13517
13542
  children: [
13518
13543
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("button", {
13519
13544
  onClick: function onClick() {
13520
- return setShowForm(true);
13545
+ setShowForm(true);
13546
+ setStep("form");
13521
13547
  },
13522
13548
  className: "px-6 py-2 rounded-xl text-white bg-gradient-to-r from-[#16a34a] to-[#1761a3]",
13523
13549
  children: "Yes"
@@ -13535,6 +13561,27 @@ function AdvancedFeedbackModal(param) {
13535
13561
  }),
13536
13562
  showForm && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, {
13537
13563
  children: [
13564
+ sessionData && sessionData.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", {
13565
+ className: "w-full mt-3 mb-3 rounded-xl p-[1px]\r\n bg-gradient-to-r from-[#16a34a]/40 via-transparent to-[#1761a3]/40",
13566
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", {
13567
+ className: "rounded-xl bg-white/70 backdrop-blur-md\r\n border border-white/30 p-4 text-sm text-gray-800",
13568
+ children: sessionData.map(function(item, index) {
13569
+ return item.value && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("p", {
13570
+ children: [
13571
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("span", {
13572
+ className: "font-semibold text-[#0f2a44]",
13573
+ children: [
13574
+ item.label,
13575
+ ":"
13576
+ ]
13577
+ }),
13578
+ " ",
13579
+ item.value
13580
+ ]
13581
+ }, index);
13582
+ })
13583
+ })
13584
+ }),
13538
13585
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("textarea", {
13539
13586
  value: message,
13540
13587
  onChange: function onChange(e) {
@@ -13600,7 +13647,7 @@ var import_react26 = require("react");
13600
13647
  var import_react_dom4 = require("react-dom");
13601
13648
  var import_jsx_runtime35 = require("react/jsx-runtime");
13602
13649
  function Chatbot(param) {
13603
- var isOpen = param.isOpen, onClose = param.onClose, title = param.title;
13650
+ var isOpen = param.isOpen, onClose = param.onClose, showForm = param.showForm, title = param.title, onSend = param.onSend;
13604
13651
  var _ref = _sliced_to_array((0, import_react26.useState)("form"), 2), step = _ref[0], setStep = _ref[1];
13605
13652
  var _ref1 = _sliced_to_array((0, import_react26.useState)([
13606
13653
  {