vdb-ai-chat 1.0.21 → 1.0.23

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.
Files changed (73) hide show
  1. package/dist/chat-widget.js +1 -1
  2. package/lib/commonjs/api.js +20 -1
  3. package/lib/commonjs/api.js.map +1 -1
  4. package/lib/commonjs/components/BetaNotice.js +0 -1
  5. package/lib/commonjs/components/BetaNotice.js.map +1 -1
  6. package/lib/commonjs/components/Button.js +95 -0
  7. package/lib/commonjs/components/Button.js.map +1 -0
  8. package/lib/commonjs/components/ChatWidget.js +82 -4
  9. package/lib/commonjs/components/ChatWidget.js.map +1 -1
  10. package/lib/commonjs/components/LabelContainer.js +50 -0
  11. package/lib/commonjs/components/LabelContainer.js.map +1 -0
  12. package/lib/commonjs/components/MessageBubble.js +50 -11
  13. package/lib/commonjs/components/MessageBubble.js.map +1 -1
  14. package/lib/commonjs/components/MessageMetaRow.js +22 -6
  15. package/lib/commonjs/components/MessageMetaRow.js.map +1 -1
  16. package/lib/commonjs/components/ProductsList.js +12 -2
  17. package/lib/commonjs/components/ProductsList.js.map +1 -1
  18. package/lib/commonjs/components/ProductsListView.js +123 -317
  19. package/lib/commonjs/components/ProductsListView.js.map +1 -1
  20. package/lib/commonjs/components/utils.js +189 -6
  21. package/lib/commonjs/components/utils.js.map +1 -1
  22. package/lib/commonjs/types.js +4 -0
  23. package/lib/module/api.js +20 -2
  24. package/lib/module/api.js.map +1 -1
  25. package/lib/module/components/BetaNotice.js +0 -1
  26. package/lib/module/components/BetaNotice.js.map +1 -1
  27. package/lib/module/components/Button.js +88 -0
  28. package/lib/module/components/Button.js.map +1 -0
  29. package/lib/module/components/ChatWidget.js +84 -6
  30. package/lib/module/components/ChatWidget.js.map +1 -1
  31. package/lib/module/components/LabelContainer.js +43 -0
  32. package/lib/module/components/LabelContainer.js.map +1 -0
  33. package/lib/module/components/MessageBubble.js +51 -12
  34. package/lib/module/components/MessageBubble.js.map +1 -1
  35. package/lib/module/components/MessageMetaRow.js +22 -6
  36. package/lib/module/components/MessageMetaRow.js.map +1 -1
  37. package/lib/module/components/ProductsList.js +12 -2
  38. package/lib/module/components/ProductsList.js.map +1 -1
  39. package/lib/module/components/ProductsListView.js +123 -318
  40. package/lib/module/components/ProductsListView.js.map +1 -1
  41. package/lib/module/components/utils.js +182 -4
  42. package/lib/module/components/utils.js.map +1 -1
  43. package/lib/module/types.js +1 -1
  44. package/lib/typescript/api.d.ts +1 -0
  45. package/lib/typescript/api.d.ts.map +1 -1
  46. package/lib/typescript/components/BetaNotice.d.ts.map +1 -1
  47. package/lib/typescript/components/Button.d.ts +5 -0
  48. package/lib/typescript/components/Button.d.ts.map +1 -0
  49. package/lib/typescript/components/ChatWidget.d.ts.map +1 -1
  50. package/lib/typescript/components/LabelContainer.d.ts +10 -0
  51. package/lib/typescript/components/LabelContainer.d.ts.map +1 -0
  52. package/lib/typescript/components/MessageBubble.d.ts.map +1 -1
  53. package/lib/typescript/components/MessageMetaRow.d.ts.map +1 -1
  54. package/lib/typescript/components/ProductsList.d.ts +5 -0
  55. package/lib/typescript/components/ProductsList.d.ts.map +1 -1
  56. package/lib/typescript/components/ProductsListView.d.ts +5 -0
  57. package/lib/typescript/components/ProductsListView.d.ts.map +1 -1
  58. package/lib/typescript/components/utils.d.ts +37 -4
  59. package/lib/typescript/components/utils.d.ts.map +1 -1
  60. package/lib/typescript/types.d.ts +28 -0
  61. package/lib/typescript/types.d.ts.map +1 -1
  62. package/package.json +1 -1
  63. package/src/api.ts +30 -2
  64. package/src/components/BetaNotice.tsx +0 -1
  65. package/src/components/Button.tsx +85 -0
  66. package/src/components/ChatWidget.tsx +90 -2
  67. package/src/components/LabelContainer.tsx +50 -0
  68. package/src/components/MessageBubble.tsx +50 -36
  69. package/src/components/MessageMetaRow.tsx +26 -9
  70. package/src/components/ProductsList.tsx +15 -0
  71. package/src/components/ProductsListView.tsx +238 -307
  72. package/src/components/utils.ts +242 -5
  73. package/src/types.ts +31 -0
@@ -1,6 +1,7 @@
1
1
  import { Dimensions } from "react-native";
2
2
  import { Storage } from "../storage";
3
3
  import { useMediaQuery } from "react-responsive";
4
+ import { ButtonCategoryStyle } from "src/types";
4
5
 
5
6
  export const DEVICE_SIZE = Dimensions.get("window");
6
7
 
@@ -165,9 +166,19 @@ export const getDeviceType = (platform?: string) => {
165
166
  export enum AnalyticsEventNames {
166
167
  WIDGET_OPENED = "ai_chat_widget_opened",
167
168
  WIDGET_CLOSED = "ai_chat_widget_closed",
168
- CHAT_CLEARED = "ai_chat_cleared",
169
- PRODUCT_PREVIEW_CLICKED = "ai_product_preview_clicked",
170
- SHOW_ALL_RESULTS_CLICKED = "ai_show_all_results_clicked",
169
+ CHAT_CLEARED = "ai_chat_cleared"
170
+ }
171
+
172
+ export enum AIEventNames {
173
+ AI_CHAT_WIDGET = "ai_chat_widget",
174
+ }
175
+
176
+ export enum AIEventTypes {
177
+ WIDGET_OPENED = "widget_opened",
178
+ WIDGET_CLOSED = "widget_closed",
179
+ CHAT_CLEARED = "chat_cleared",
180
+ PRODUCT_PREVIEW_CLICKED = "product_preview_clicked",
181
+ SHOW_ALL_RESULTS_CLICKED = "show_all_results_clicked",
171
182
  }
172
183
 
173
184
  export const isIpad = () => {
@@ -308,7 +319,7 @@ export const renderSearchParams = ({searchPayload, priceMode, vdbSetting, search
308
319
  return searchPayload;
309
320
  }
310
321
 
311
- export const generateSavedSearchName = (search_params: any) => {
322
+ export const generateSavedSearchName = (search_params: any, shortenShapeValues: boolean = false) => {
312
323
  let options: { [k: string]: any } = {};
313
324
  let title_parts = [];
314
325
 
@@ -321,7 +332,16 @@ export const generateSavedSearchName = (search_params: any) => {
321
332
  //Shape
322
333
  if (search_params?.shapes && search_params?.shapes?.length) {
323
334
  options.shapes = search_params?.shapes || [];
324
- title_parts.push(options.shapes.join(", "));
335
+
336
+ // Shorten shape values if there are more than 3 shapes
337
+ if (shortenShapeValues && options.shapes.length > 3) {
338
+ const firstThree = options.shapes.slice(0, 3);
339
+ const remainingCount = options.shapes.length - 3;
340
+ const shapeText = `${firstThree.join(", ")} + ${remainingCount} more`;
341
+ title_parts.push(shapeText);
342
+ } else {
343
+ title_parts.push(options.shapes.join(", "));
344
+ }
325
345
  }
326
346
 
327
347
  //Carat Weight
@@ -844,3 +864,220 @@ export const generateSavedSearchName = (search_params: any) => {
844
864
 
845
865
  return { title: title_parts.filter(Boolean).join(" | "), options: options };
846
866
  };
867
+
868
+ export enum ButtonCategory {
869
+ diam = "diam",
870
+ gem = "gem",
871
+ jewelry = "jewelry",
872
+ lab = "lab",
873
+ default = "default",
874
+ }
875
+
876
+ export enum ButtonType {
877
+ primary,
878
+ secondary,
879
+ tertiary,
880
+ }
881
+
882
+ export enum ProductCategory {
883
+ DIAMOND = "diamond",
884
+ LAB_GROWN_DIAMOND = "lab_grown_diamond",
885
+ GEMSTONE = "gemstone",
886
+ JEWELRY = "jewelry",
887
+ LABGROWN_JEWELRY = "lab_grown_jewelry",
888
+ }
889
+
890
+ export const getProductColor = (
891
+ productType: string | undefined
892
+ ): any => {
893
+ switch (productType) {
894
+ case ProductCategory.DIAMOND:
895
+ return "diam-06";
896
+ case ProductCategory.GEMSTONE:
897
+ return "gem-06";
898
+ case ProductCategory.JEWELRY:
899
+ return "jewelry-06";
900
+ case ProductCategory.LAB_GROWN_DIAMOND:
901
+ return "lab-06";
902
+ case ProductCategory.LABGROWN_JEWELRY:
903
+ return "lab-06";
904
+ default:
905
+ return "diam-06";
906
+ }
907
+ };
908
+
909
+ export const getProductAlphaColor = (productType: string | undefined) => {
910
+ switch (productType) {
911
+ case ProductCategory.DIAMOND:
912
+ return "diam-03";
913
+ case ProductCategory.GEMSTONE:
914
+ return "gem-03";
915
+ case ProductCategory.JEWELRY:
916
+ return "jewelry-03";
917
+ case ProductCategory.LAB_GROWN_DIAMOND:
918
+ return "lab-03";
919
+ case ProductCategory.LABGROWN_JEWELRY:
920
+ return "lab-03";
921
+ default:
922
+ return "diam-03";
923
+ }
924
+ };
925
+
926
+ export const getStyleForCategory = (
927
+ category: ButtonCategory,
928
+ type: ButtonType,
929
+ disabled: boolean
930
+ ): ButtonCategoryStyle => {
931
+ if (disabled) {
932
+ if (type === ButtonType.primary) {
933
+ return {
934
+ textColor: "primary-cont-disabled",
935
+ background: "primary-bg-disabled",
936
+ borderColor: `transparent`,
937
+ hover: "transparent",
938
+ };
939
+ }
940
+ if (type === ButtonType.secondary) {
941
+ return {
942
+ textColor: "secondary-cont-disabled",
943
+ background: "transparent",
944
+ borderColor: `secondary-bor-disabled`,
945
+ hover: "transparent",
946
+ };
947
+ }
948
+ if (type === ButtonType.tertiary) {
949
+ return {
950
+ textColor: "tertiary-cont-disabled",
951
+ background: "tertiary-bg-disabled",
952
+ borderColor: `transparent`,
953
+ hover: "transparent",
954
+ };
955
+ }
956
+ }
957
+
958
+ if (type === ButtonType.primary) {
959
+ if (category === ButtonCategory.default) {
960
+ return {
961
+ textColor: "primary-cont",
962
+ background: "primary-bg-static",
963
+ borderColor: `transparent`,
964
+ hover: "primary-bg-hover",
965
+ };
966
+ }
967
+
968
+ return {
969
+ textColor: `${category}-05`,
970
+ background: `${category}-01`,
971
+ borderColor: `transparent`,
972
+ hover: `${category}-02`,
973
+ };
974
+ }
975
+
976
+ if (type === ButtonType.secondary) {
977
+ if (category === ButtonCategory.default) {
978
+ return {
979
+ textColor: "secondary-cont",
980
+ background: "transparent",
981
+ borderColor: `secondary-bor-static`,
982
+ hover: "secondary-bg-hover",
983
+ };
984
+ }
985
+
986
+ return {
987
+ textColor: `${category}-06`,
988
+ background: `transparent`,
989
+ borderColor: `${category}-01`,
990
+ hover: `${category}-03`,
991
+ };
992
+ }
993
+
994
+ if (type === ButtonType.tertiary) {
995
+ if (category === ButtonCategory.default) {
996
+ return {
997
+ textColor: "tertiary-cont",
998
+ background: "tertiary-bg-static",
999
+ borderColor: `transparent`,
1000
+ hover: "transparent",
1001
+ };
1002
+ }
1003
+
1004
+ return {
1005
+ textColor: `${category}-06`,
1006
+ background: `${category}-03`,
1007
+ borderColor: `transparent`,
1008
+ hover: "transparent",
1009
+ };
1010
+ }
1011
+
1012
+ return {
1013
+ textColor: "primary-cont",
1014
+ background: "primary-bg-static",
1015
+ borderColor: `transparent`,
1016
+ hover: "primary-bg-hover",
1017
+ };
1018
+ };
1019
+
1020
+ export const isInvalidFancyColorOvertone = (
1021
+ fancyColorOvertoneLong?: string
1022
+ ) => {
1023
+ const invalidFancyColorOvertoneArray = ["Champagne", "Cognac", "Chameleon"];
1024
+ if (fancyColorOvertoneLong) {
1025
+ return invalidFancyColorOvertoneArray.includes(fancyColorOvertoneLong);
1026
+ }
1027
+ };
1028
+
1029
+
1030
+ export const colorStringForShort = (isShort: boolean, itemDetail?: any) => {
1031
+ let colorString = null;
1032
+
1033
+ if (isShort) {
1034
+ if (isInvalidFancyColorOvertone(itemDetail?.fancy_color_overtone_long)) {
1035
+ colorString = itemDetail?.is_fancy
1036
+ ? `${
1037
+ itemDetail?.fancy_color_intensity_short || itemDetail?.color || ""
1038
+ } ${itemDetail?.fancy_color_short || ""}(${
1039
+ itemDetail?.fancy_color_overtone_long || ""
1040
+ })`
1041
+ : `${itemDetail?.fancy_color_long || itemDetail?.color || ""}`;
1042
+ } else {
1043
+ colorString = itemDetail?.is_fancy
1044
+ ? `${
1045
+ itemDetail?.fancy_color_intensity_short ||
1046
+ itemDetail?.fancy_color_intensity ||
1047
+ ""
1048
+ } ${itemDetail?.fancy_color_overtone_short || ""}${
1049
+ itemDetail?.fancy_color_short || ""
1050
+ }`
1051
+ : `${itemDetail?.fancy_color_long || itemDetail?.color || ""}`;
1052
+ }
1053
+ } else {
1054
+ if (isInvalidFancyColorOvertone(itemDetail?.fancy_color_overtone_long)) {
1055
+ colorString = itemDetail?.is_fancy
1056
+ ? [
1057
+ itemDetail?.fancy_color_intensity_long ||
1058
+ itemDetail?.fancy_color_intensity,
1059
+ itemDetail?.fancy_color_long,
1060
+ itemDetail?.fancy_color_overtone_long
1061
+ ? `(${itemDetail.fancy_color_overtone_long})`
1062
+ : null,
1063
+ ]
1064
+ .filter(Boolean)
1065
+ .join(" ")
1066
+ : itemDetail?.fancy_color_long || itemDetail?.color || "";
1067
+ } else {
1068
+ colorString = itemDetail?.is_fancy
1069
+ ? [
1070
+ itemDetail?.fancy_color_intensity_long ||
1071
+ itemDetail?.fancy_color_intensity,
1072
+ itemDetail?.fancy_color_overtone_long,
1073
+ itemDetail?.fancy_color_long,
1074
+ ]
1075
+ .filter(Boolean)
1076
+ .join(" ")
1077
+ : itemDetail?.fancy_color_long || itemDetail?.color || "";
1078
+ }
1079
+ }
1080
+
1081
+ return colorString === "" ? "-" : colorString;
1082
+ };
1083
+
package/src/types.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import { DefaultThemeValueType } from "styled";
2
+ import { ButtonCategory, ButtonType } from "./components/utils";
3
+
1
4
  export type Role = "user" | "assistant";
2
5
 
3
6
  export interface ChatMessage {
@@ -47,6 +50,7 @@ export interface ChatWidgetProps {
47
50
  /** When true, shows beta labels and disclaimer. */
48
51
  isBetaMode?: boolean;
49
52
  activeProductType?: string;
53
+ trackAnalyticsEvent?: (eventName: string, eventData: Record<string, any>) => void;
50
54
  }
51
55
 
52
56
  export interface ChatWidgetRef {
@@ -57,3 +61,30 @@ export interface ChatWidgetHandlers {
57
61
  onViewAllPress?: (deepLinkUrl: string, payload: any) => void;
58
62
  onItemPress?: (deepLinkUrl: string, item: any) => void;
59
63
  }
64
+
65
+ export type ButtonCategoryStyle = {
66
+ textColor: DefaultThemeValueType;
67
+ background: DefaultThemeValueType;
68
+ borderColor: DefaultThemeValueType;
69
+ hover: DefaultThemeValueType;
70
+ };
71
+
72
+ export type ButtonProps = {
73
+ category: ButtonCategory;
74
+ type?: ButtonType;
75
+ disabled?: boolean;
76
+ loading?: boolean;
77
+ onPress?: () => void;
78
+ height?: number;
79
+ width?: number;
80
+ borderRadius?: number;
81
+ paddingLeftText?: number;
82
+ textTypographyStyle?: string;
83
+ hideText?: boolean;
84
+ showLeftText?: boolean;
85
+ manualColor?: string;
86
+ isDisableInteraction?: boolean;
87
+ maxWidth?: number;
88
+ style?: any;
89
+ children?: React.ReactNode;
90
+ };