vdb-ai-chat 1.0.20 → 1.0.22

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 +24 -2
  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 +79 -3
  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 +10 -2
  17. package/lib/commonjs/components/ProductsList.js.map +1 -1
  18. package/lib/commonjs/components/ProductsListView.js +116 -311
  19. package/lib/commonjs/components/ProductsListView.js.map +1 -1
  20. package/lib/commonjs/components/utils.js +152 -4
  21. package/lib/commonjs/components/utils.js.map +1 -1
  22. package/lib/commonjs/types.js +4 -0
  23. package/lib/module/api.js +24 -3
  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 +81 -5
  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 +10 -2
  38. package/lib/module/components/ProductsList.js.map +1 -1
  39. package/lib/module/components/ProductsListView.js +116 -312
  40. package/lib/module/components/ProductsListView.js.map +1 -1
  41. package/lib/module/components/utils.js +147 -2
  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 +4 -0
  55. package/lib/typescript/components/ProductsList.d.ts.map +1 -1
  56. package/lib/typescript/components/ProductsListView.d.ts +4 -0
  57. package/lib/typescript/components/ProductsListView.d.ts.map +1 -1
  58. package/lib/typescript/components/utils.d.ts +24 -1
  59. package/lib/typescript/components/utils.d.ts.map +1 -1
  60. package/lib/typescript/types.d.ts +27 -0
  61. package/lib/typescript/types.d.ts.map +1 -1
  62. package/package.json +1 -1
  63. package/src/api.ts +31 -3
  64. package/src/components/BetaNotice.tsx +0 -1
  65. package/src/components/Button.tsx +85 -0
  66. package/src/components/ChatWidget.tsx +88 -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 +12 -0
  71. package/src/components/ProductsListView.tsx +227 -302
  72. package/src/components/utils.ts +164 -2
  73. package/src/types.ts +30 -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
 
@@ -308,7 +309,7 @@ export const renderSearchParams = ({searchPayload, priceMode, vdbSetting, search
308
309
  return searchPayload;
309
310
  }
310
311
 
311
- export const generateSavedSearchName = (search_params: any) => {
312
+ export const generateSavedSearchName = (search_params: any, shortenShapeValues: boolean = false) => {
312
313
  let options: { [k: string]: any } = {};
313
314
  let title_parts = [];
314
315
 
@@ -321,7 +322,16 @@ export const generateSavedSearchName = (search_params: any) => {
321
322
  //Shape
322
323
  if (search_params?.shapes && search_params?.shapes?.length) {
323
324
  options.shapes = search_params?.shapes || [];
324
- title_parts.push(options.shapes.join(", "));
325
+
326
+ // Shorten shape values if there are more than 3 shapes
327
+ if (shortenShapeValues && options.shapes.length > 3) {
328
+ const firstThree = options.shapes.slice(0, 3);
329
+ const remainingCount = options.shapes.length - 3;
330
+ const shapeText = `${firstThree.join(", ")} + ${remainingCount} more`;
331
+ title_parts.push(shapeText);
332
+ } else {
333
+ title_parts.push(options.shapes.join(", "));
334
+ }
325
335
  }
326
336
 
327
337
  //Carat Weight
@@ -844,3 +854,155 @@ export const generateSavedSearchName = (search_params: any) => {
844
854
 
845
855
  return { title: title_parts.filter(Boolean).join(" | "), options: options };
846
856
  };
857
+
858
+ export enum ButtonCategory {
859
+ diam = "diam",
860
+ gem = "gem",
861
+ jewelry = "jewelry",
862
+ lab = "lab",
863
+ default = "default",
864
+ }
865
+
866
+ export enum ButtonType {
867
+ primary,
868
+ secondary,
869
+ tertiary,
870
+ }
871
+
872
+ export enum ProductCategory {
873
+ DIAMOND = "diamond",
874
+ LAB_GROWN_DIAMOND = "lab_grown_diamond",
875
+ GEMSTONE = "gemstone",
876
+ JEWELRY = "jewelry",
877
+ LABGROWN_JEWELRY = "lab_grown_jewelry",
878
+ }
879
+
880
+ export const getProductColor = (
881
+ productType: string | undefined
882
+ ): any => {
883
+ switch (productType) {
884
+ case ProductCategory.DIAMOND:
885
+ return "diam-06";
886
+ case ProductCategory.GEMSTONE:
887
+ return "gem-06";
888
+ case ProductCategory.JEWELRY:
889
+ return "jewelry-06";
890
+ case ProductCategory.LAB_GROWN_DIAMOND:
891
+ return "lab-06";
892
+ case ProductCategory.LABGROWN_JEWELRY:
893
+ return "lab-06";
894
+ default:
895
+ return "diam-06";
896
+ }
897
+ };
898
+
899
+ export const getProductAlphaColor = (productType: string | undefined) => {
900
+ switch (productType) {
901
+ case ProductCategory.DIAMOND:
902
+ return "diam-03";
903
+ case ProductCategory.GEMSTONE:
904
+ return "gem-03";
905
+ case ProductCategory.JEWELRY:
906
+ return "jewelry-03";
907
+ case ProductCategory.LAB_GROWN_DIAMOND:
908
+ return "lab-03";
909
+ case ProductCategory.LABGROWN_JEWELRY:
910
+ return "lab-03";
911
+ default:
912
+ return "diam-03";
913
+ }
914
+ };
915
+
916
+ export const getStyleForCategory = (
917
+ category: ButtonCategory,
918
+ type: ButtonType,
919
+ disabled: boolean
920
+ ): ButtonCategoryStyle => {
921
+ if (disabled) {
922
+ if (type === ButtonType.primary) {
923
+ return {
924
+ textColor: "primary-cont-disabled",
925
+ background: "primary-bg-disabled",
926
+ borderColor: `transparent`,
927
+ hover: "transparent",
928
+ };
929
+ }
930
+ if (type === ButtonType.secondary) {
931
+ return {
932
+ textColor: "secondary-cont-disabled",
933
+ background: "transparent",
934
+ borderColor: `secondary-bor-disabled`,
935
+ hover: "transparent",
936
+ };
937
+ }
938
+ if (type === ButtonType.tertiary) {
939
+ return {
940
+ textColor: "tertiary-cont-disabled",
941
+ background: "tertiary-bg-disabled",
942
+ borderColor: `transparent`,
943
+ hover: "transparent",
944
+ };
945
+ }
946
+ }
947
+
948
+ if (type === ButtonType.primary) {
949
+ if (category === ButtonCategory.default) {
950
+ return {
951
+ textColor: "primary-cont",
952
+ background: "primary-bg-static",
953
+ borderColor: `transparent`,
954
+ hover: "primary-bg-hover",
955
+ };
956
+ }
957
+
958
+ return {
959
+ textColor: `${category}-05`,
960
+ background: `${category}-01`,
961
+ borderColor: `transparent`,
962
+ hover: `${category}-02`,
963
+ };
964
+ }
965
+
966
+ if (type === ButtonType.secondary) {
967
+ if (category === ButtonCategory.default) {
968
+ return {
969
+ textColor: "secondary-cont",
970
+ background: "transparent",
971
+ borderColor: `secondary-bor-static`,
972
+ hover: "secondary-bg-hover",
973
+ };
974
+ }
975
+
976
+ return {
977
+ textColor: `${category}-06`,
978
+ background: `transparent`,
979
+ borderColor: `${category}-01`,
980
+ hover: `${category}-03`,
981
+ };
982
+ }
983
+
984
+ if (type === ButtonType.tertiary) {
985
+ if (category === ButtonCategory.default) {
986
+ return {
987
+ textColor: "tertiary-cont",
988
+ background: "tertiary-bg-static",
989
+ borderColor: `transparent`,
990
+ hover: "transparent",
991
+ };
992
+ }
993
+
994
+ return {
995
+ textColor: `${category}-06`,
996
+ background: `${category}-03`,
997
+ borderColor: `transparent`,
998
+ hover: "transparent",
999
+ };
1000
+ }
1001
+
1002
+ return {
1003
+ textColor: "primary-cont",
1004
+ background: "primary-bg-static",
1005
+ borderColor: `transparent`,
1006
+ hover: "primary-bg-hover",
1007
+ };
1008
+ };
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 {
@@ -57,3 +60,30 @@ export interface ChatWidgetHandlers {
57
60
  onViewAllPress?: (deepLinkUrl: string, payload: any) => void;
58
61
  onItemPress?: (deepLinkUrl: string, item: any) => void;
59
62
  }
63
+
64
+ export type ButtonCategoryStyle = {
65
+ textColor: DefaultThemeValueType;
66
+ background: DefaultThemeValueType;
67
+ borderColor: DefaultThemeValueType;
68
+ hover: DefaultThemeValueType;
69
+ };
70
+
71
+ export type ButtonProps = {
72
+ category: ButtonCategory;
73
+ type?: ButtonType;
74
+ disabled?: boolean;
75
+ loading?: boolean;
76
+ onPress?: () => void;
77
+ height?: number;
78
+ width?: number;
79
+ borderRadius?: number;
80
+ paddingLeftText?: number;
81
+ textTypographyStyle?: string;
82
+ hideText?: boolean;
83
+ showLeftText?: boolean;
84
+ manualColor?: string;
85
+ isDisableInteraction?: boolean;
86
+ maxWidth?: number;
87
+ style?: any;
88
+ children?: React.ReactNode;
89
+ };