vdb-ai-chat 1.0.7 → 1.0.9

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 (65) hide show
  1. package/dist/chat-widget.js +1 -1
  2. package/lib/commonjs/api.js +19 -1
  3. package/lib/commonjs/api.js.map +1 -1
  4. package/lib/commonjs/components/BetaNotice.js +13 -12
  5. package/lib/commonjs/components/BetaNotice.js.map +1 -1
  6. package/lib/commonjs/components/ChatInput.js +59 -49
  7. package/lib/commonjs/components/ChatInput.js.map +1 -1
  8. package/lib/commonjs/components/ChatWidget.js +95 -63
  9. package/lib/commonjs/components/ChatWidget.js.map +1 -1
  10. package/lib/commonjs/components/MessageBubble.js +67 -52
  11. package/lib/commonjs/components/MessageBubble.js.map +1 -1
  12. package/lib/commonjs/components/MessageMetaRow.js +50 -31
  13. package/lib/commonjs/components/MessageMetaRow.js.map +1 -1
  14. package/lib/commonjs/components/ProductsListView.js +232 -153
  15. package/lib/commonjs/components/ProductsListView.js.map +1 -1
  16. package/lib/commonjs/components/SuggestionsRow.js +27 -24
  17. package/lib/commonjs/components/SuggestionsRow.js.map +1 -1
  18. package/lib/commonjs/contexts/ThemeProvider.js +80 -0
  19. package/lib/commonjs/contexts/ThemeProvider.js.map +1 -0
  20. package/lib/commonjs/contexts/utils.js +142 -0
  21. package/lib/commonjs/contexts/utils.js.map +1 -0
  22. package/lib/module/api.js +19 -1
  23. package/lib/module/api.js.map +1 -1
  24. package/lib/module/components/BetaNotice.js +14 -13
  25. package/lib/module/components/BetaNotice.js.map +1 -1
  26. package/lib/module/components/ChatInput.js +61 -50
  27. package/lib/module/components/ChatInput.js.map +1 -1
  28. package/lib/module/components/ChatWidget.js +99 -65
  29. package/lib/module/components/ChatWidget.js.map +1 -1
  30. package/lib/module/components/MessageBubble.js +69 -52
  31. package/lib/module/components/MessageBubble.js.map +1 -1
  32. package/lib/module/components/MessageMetaRow.js +52 -32
  33. package/lib/module/components/MessageMetaRow.js.map +1 -1
  34. package/lib/module/components/ProductsListView.js +234 -154
  35. package/lib/module/components/ProductsListView.js.map +1 -1
  36. package/lib/module/components/SuggestionsRow.js +29 -25
  37. package/lib/module/components/SuggestionsRow.js.map +1 -1
  38. package/lib/module/contexts/ThemeProvider.js +75 -0
  39. package/lib/module/contexts/ThemeProvider.js.map +1 -0
  40. package/lib/module/contexts/utils.js +136 -0
  41. package/lib/module/contexts/utils.js.map +1 -0
  42. package/lib/typescript/api.d.ts.map +1 -1
  43. package/lib/typescript/components/BetaNotice.d.ts.map +1 -1
  44. package/lib/typescript/components/ChatInput.d.ts.map +1 -1
  45. package/lib/typescript/components/ChatWidget.d.ts.map +1 -1
  46. package/lib/typescript/components/MessageBubble.d.ts +1 -1
  47. package/lib/typescript/components/MessageBubble.d.ts.map +1 -1
  48. package/lib/typescript/components/MessageMetaRow.d.ts.map +1 -1
  49. package/lib/typescript/components/ProductsListView.d.ts.map +1 -1
  50. package/lib/typescript/components/SuggestionsRow.d.ts.map +1 -1
  51. package/lib/typescript/contexts/ThemeProvider.d.ts +7 -0
  52. package/lib/typescript/contexts/ThemeProvider.d.ts.map +1 -0
  53. package/lib/typescript/contexts/utils.d.ts +136 -0
  54. package/lib/typescript/contexts/utils.d.ts.map +1 -0
  55. package/package.json +6 -2
  56. package/src/api.ts +24 -0
  57. package/src/components/BetaNotice.tsx +15 -13
  58. package/src/components/ChatInput.tsx +63 -62
  59. package/src/components/ChatWidget.tsx +264 -216
  60. package/src/components/MessageBubble.tsx +113 -74
  61. package/src/components/MessageMetaRow.tsx +80 -50
  62. package/src/components/ProductsListView.tsx +242 -183
  63. package/src/components/SuggestionsRow.tsx +40 -25
  64. package/src/contexts/ThemeProvider.tsx +87 -0
  65. package/src/contexts/utils.ts +135 -0
@@ -1,6 +1,9 @@
1
1
  import React from "react";
2
- import { View, Text, StyleSheet, Image, Platform, Pressable } from "react-native";
2
+ import { View, StyleSheet, Image, Platform } from "react-native";
3
3
  import { FeedbackAction, fetchConversationId, formatToTime } from "./utils";
4
+ import { useTheme } from "styled-components/native";
5
+ import styled from "styled-components/native";
6
+ import { css } from "styled-components/native";
4
7
  let ImageComponent = Image;
5
8
  if (Platform.OS !== "web") {
6
9
  try {
@@ -11,11 +14,9 @@ if (Platform.OS !== "web") {
11
14
  export const MessageMetaRow = ({
12
15
  message,
13
16
  priceMode,
14
- handleFeedbackAction,
15
- onReloadResults,
16
- reloading,
17
- hasResults
17
+ handleFeedbackAction
18
18
  }) => {
19
+ const theme = useTheme();
19
20
  const isUser = message.role === "user";
20
21
  const [conversationId, setConversationId] = React.useState(null);
21
22
  React.useEffect(() => {
@@ -31,12 +32,14 @@ export const MessageMetaRow = ({
31
32
  style: [styles.rowContainer, isUser ? styles.alignRight : styles.alignLeft]
32
33
  }, /*#__PURE__*/React.createElement(View, {
33
34
  style: styles.timeContainer
34
- }, /*#__PURE__*/React.createElement(Text, {
35
- style: styles.timeText
35
+ }, /*#__PURE__*/React.createElement(TimeText, {
36
+ theme: theme
36
37
  }, formatToTime(message.createdAt))), canFeedback ? /*#__PURE__*/React.createElement(View, {
37
38
  style: styles.likeDislikeContainer
38
- }, /*#__PURE__*/React.createElement(Pressable, {
39
- style: state => [styles.borderButton, state?.hovered && styles.borderButtonHover, message.reaction === FeedbackAction.LIKE && styles.borderButtonLike],
39
+ }, /*#__PURE__*/React.createElement(LikeButton, {
40
+ type: "like",
41
+ style: state => [state?.hovered && styles.borderButtonHover],
42
+ reaction: message.reaction,
40
43
  onPress: () => handleFeedbackAction(FeedbackAction.LIKE, String(conversationId), message.id),
41
44
  disabled: !canFeedback
42
45
  }, /*#__PURE__*/React.createElement(ImageComponent, {
@@ -47,10 +50,12 @@ export const MessageMetaRow = ({
47
50
  style: {
48
51
  width: 20,
49
52
  height: 20,
50
- tintColor: message.reaction === FeedbackAction.LIKE ? "#00B140" : "#020001"
53
+ tintColor: message.reaction === FeedbackAction.LIKE ? theme["success-01"] || "#00B140" : theme["core-05"] || "#020001"
51
54
  }
52
- })), /*#__PURE__*/React.createElement(Pressable, {
53
- style: state => [styles.borderButton, state?.hovered && styles.borderButtonHover, message.reaction === FeedbackAction.DISLIKE && styles.borderButtonDislike],
55
+ })), /*#__PURE__*/React.createElement(LikeButton, {
56
+ type: "dislike",
57
+ style: state => [state?.hovered && styles.borderButtonHover],
58
+ reaction: message.reaction,
54
59
  onPress: () => handleFeedbackAction(FeedbackAction.DISLIKE, String(conversationId), message.id),
55
60
  disabled: !canFeedback
56
61
  }, /*#__PURE__*/React.createElement(ImageComponent, {
@@ -61,10 +66,44 @@ export const MessageMetaRow = ({
61
66
  style: {
62
67
  width: 20,
63
68
  height: 20,
64
- tintColor: message.reaction === FeedbackAction.DISLIKE ? "#D0021B" : "#020001"
69
+ tintColor: message.reaction === FeedbackAction.DISLIKE ? theme["error-01"] || "#D0021B" : theme["core-05"] || "#020001"
65
70
  }
66
71
  }))) : null);
67
72
  };
73
+ const LikeButton = styled.Pressable`
74
+ border-width: 1;
75
+ border-radius: 8px;
76
+ padding-horizontal: 4px;
77
+ padding-vertical: 4px;
78
+ ${({
79
+ reaction,
80
+ type
81
+ }) => reaction === FeedbackAction.LIKE && type === "like" ? css`
82
+ background-color: ${({
83
+ theme
84
+ }) => theme["success-02"] || "#DBFFE4"};
85
+ border-color: ${({
86
+ theme
87
+ }) => theme["success-01"] || "#00B140"};
88
+ ` : reaction === FeedbackAction.DISLIKE && type === "dislike" ? css`
89
+ background-color: ${({
90
+ theme
91
+ }) => theme["error-02"] || "#FFE2E0"};
92
+ border-color: ${({
93
+ theme
94
+ }) => theme["error-01"] || "#D0021B"};
95
+ ` : css`
96
+ border-color: ${({
97
+ theme
98
+ }) => theme["core-03"] || "#D5D5DC"};
99
+ `}
100
+ `;
101
+ const TimeText = styled.Text`
102
+ font-size: 12px;
103
+ color: ${({
104
+ theme
105
+ }) => theme["core-06"] || "#666"};
106
+ `;
68
107
  const styles = StyleSheet.create({
69
108
  rowContainer: {
70
109
  flexDirection: "row",
@@ -88,27 +127,8 @@ const styles = StyleSheet.create({
88
127
  timeContainer: {
89
128
  margin: 0
90
129
  },
91
- borderButton: {
92
- borderWidth: 1,
93
- borderColor: "#D5D5DC",
94
- borderRadius: 8,
95
- paddingHorizontal: 4,
96
- paddingVertical: 4
97
- },
98
130
  borderButtonHover: {
99
131
  backgroundColor: "#EDEDF2"
100
- },
101
- borderButtonLike: {
102
- backgroundColor: "#DBFFE4",
103
- borderColor: "#00B140"
104
- },
105
- borderButtonDislike: {
106
- backgroundColor: "#FFE2E0",
107
- borderColor: "#D0021B"
108
- },
109
- timeText: {
110
- fontSize: 12,
111
- color: "#666"
112
132
  }
113
133
  });
114
134
  export default MessageMetaRow;
@@ -1 +1 @@
1
- {"version":3,"names":["React","View","Text","StyleSheet","Image","Platform","Pressable","FeedbackAction","fetchConversationId","formatToTime","ImageComponent","OS","ExpoImage","require","MessageMetaRow","message","priceMode","handleFeedbackAction","onReloadResults","reloading","hasResults","isUser","role","conversationId","setConversationId","useState","useEffect","fetchId","id","isValidMessageId","length","startsWith","canFeedback","isLoading","createElement","style","styles","rowContainer","alignRight","alignLeft","timeContainer","timeText","createdAt","likeDislikeContainer","state","borderButton","hovered","borderButtonHover","reaction","LIKE","borderButtonLike","onPress","String","disabled","source","uri","resizeMode","width","height","tintColor","DISLIKE","borderButtonDislike","create","flexDirection","justifyContent","alignItems","gap","marginHorizontal","marginTop","marginBottom","alignSelf","margin","borderWidth","borderColor","borderRadius","paddingHorizontal","paddingVertical","backgroundColor","fontSize","color"],"sourceRoot":"../../../src","sources":["components/MessageMetaRow.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SACEC,IAAI,EACJC,IAAI,EACJC,UAAU,EACVC,KAAK,EACLC,QAAQ,EAERC,SAAS,QACJ,cAAc;AAErB,SAASC,cAAc,EAAEC,mBAAmB,EAAEC,YAAY,QAAQ,SAAS;AAE3E,IAAIC,cAA4B,GAAGN,KAAK;AACxC,IAAIC,QAAQ,CAACM,EAAE,KA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,EAAE;IAChB2B,eAAe,EAAE,SAAS;IAC1BJ,WAAW,EAAE;EACf,CAAC;EACDZ,mBAAmB,EAAE;IACnBgB,eAAe,EAAE,SAAS;IAC1BJ,WAAW,EAAE;EACf,CAAC;EACDhC,QAAQ,EAAE;IACRqC,QAAQ,EAAE,EAAE;IACZC,KAAK,EAAE;EACT;AACF,CAAC,CAAC;AAEF,eAAejE,cAAc","ignoreList":[]}
1
+ {"version":3,"names":["React","View","StyleSheet","Image","Platform","FeedbackAction","fetchConversationId","formatToTime","useTheme","styled","css","ImageComponent","OS","ExpoImage","require","MessageMetaRow","message","priceMode","handleFeedbackAction","theme","isUser","role","conversationId","setConversationId","useState","useEffect","fetchId","id","isValidMessageId","length","startsWith","canFeedback","isLoading","createElement","style","styles","rowContainer","alignRight","alignLeft","timeContainer","TimeText","createdAt","likeDislikeContainer","LikeButton","type","state","hovered","borderButtonHover","reaction","onPress","LIKE","String","disabled","source","uri","resizeMode","width","height","tintColor","DISLIKE","Pressable","Text","create","flexDirection","justifyContent","alignItems","gap","marginHorizontal","marginTop","marginBottom","alignSelf","margin","backgroundColor"],"sourceRoot":"../../../src","sources":["components/MessageMetaRow.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,EAAEC,UAAU,EAAEC,KAAK,EAAEC,QAAQ,QAAQ,cAAc;AAEhE,SAASC,cAAc,EAAEC,mBAAmB,EAAEC,YAAY,QAAQ,SAAS;AAC3E,SAASC,QAAQ,QAAQ,0BAA0B;AACnD,OAAOC,MAAM,MAAM,0BAA0B;AAE7C,SAASC,GAAG,QAAQ,0BAA0B;AAE9C,IAAIC,cAA4B,GAAGR,KAAK;AACxC,IAAIC,QAAQ,CAACQ,EAAE,KAAK,KAAK,EAAE;EACzB,IAAI;IACF,MAAMC,SAAS,GAAGC,OAAO,CAAC,YAAY,CAAC,CAACX,KAAK;IAC7C,IAAIU,SAAS,EAAEF,cAAc,GAAGE,SAAS;EAC3C,CAAC,C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,CAAC,SAAS,CAAC,IAAI,MAAM;AAC7E,CAAC;AAED,MAAMgB,MAAM,GAAGjC,UAAU,CAAC4D,MAAM,CAAC;EAC/B1B,YAAY,EAAE;IACZ2B,aAAa,EAAE,KAAK;IACpBC,cAAc,EAAE,eAAe;IAC/BC,UAAU,EAAE,QAAQ;IACpBC,GAAG,EAAE,CAAC;IACNC,gBAAgB,EAAE,CAAC;IACnBC,SAAS,EAAE,CAAC;IACZC,YAAY,EAAE;EAChB,CAAC;EACDhC,UAAU,EAAE;IACViC,SAAS,EAAE;EACb,CAAC;EACDhC,SAAS,EAAE;IACTgC,SAAS,EAAE;EACb,CAAC;EACD5B,oBAAoB,EAAE;IACpBqB,aAAa,EAAE,KAAK;IACpBG,GAAG,EAAE;EACP,CAAC;EACD3B,aAAa,EAAE;IACbgC,MAAM,EAAE;EACV,CAAC;EACDxB,iBAAiB,EAAE;IACjByB,eAAe,EAAE;EACnB;AACF,CAAC,CAAC;AAEF,eAAezD,cAAc","ignoreList":[]}
@@ -1,6 +1,8 @@
1
1
  import React, { memo, useEffect, useState } from "react";
2
- import { View, StyleSheet, Text, TouchableOpacity, ScrollView, Platform, Image, Pressable } from "react-native";
2
+ import { View, StyleSheet, ScrollView, Platform, Image, Pressable } from "react-native";
3
3
  import { getUserCurrencySymbol } from "./utils";
4
+ import { useTheme } from "styled-components/native";
5
+ import styled from "styled-components/native";
4
6
  let ImageComponent = Image;
5
7
  if (Platform.OS !== "web") {
6
8
  try {
@@ -10,6 +12,171 @@ if (Platform.OS !== "web") {
10
12
  // expo-image not installed, use React Native Image
11
13
  }
12
14
  }
15
+
16
+ // Token configuration for diamond details display
17
+
18
+ const DIAMOND_TOKENS = [
19
+ // Row 1: Basic specs
20
+ {
21
+ type: "field",
22
+ field: "shape_long",
23
+ style: "primary"
24
+ }, {
25
+ type: "fieldWithSuffix",
26
+ field: "size",
27
+ style: "secondary",
28
+ suffix: "ct",
29
+ showCurrencyIf: "price_per_carat"
30
+ }, {
31
+ type: "field",
32
+ field: "color",
33
+ style: "primary"
34
+ }, {
35
+ type: "field",
36
+ field: "clarity_short",
37
+ style: "primary"
38
+ }, {
39
+ type: "separator"
40
+ }, {
41
+ type: "group",
42
+ items: [{
43
+ type: "field",
44
+ field: "cut_short",
45
+ style: "primary"
46
+ }, {
47
+ type: "field",
48
+ field: "polish_short",
49
+ style: "primary",
50
+ prefix: "/"
51
+ }, {
52
+ type: "field",
53
+ field: "symmetry_short",
54
+ style: "primary",
55
+ prefix: "/"
56
+ }]
57
+ }, {
58
+ type: "separator"
59
+ }, {
60
+ type: "field",
61
+ field: "fluorescence_intensity_short",
62
+ style: "primary"
63
+ }, {
64
+ type: "separator"
65
+ }, {
66
+ type: "field",
67
+ field: "lab_short",
68
+ style: "primary"
69
+ }, {
70
+ type: "separator"
71
+ }, {
72
+ type: "field",
73
+ field: "discount_percent",
74
+ style: "secondary",
75
+ format: "percent"
76
+ },
77
+ // Row 2: Measurements & Pricing
78
+ {
79
+ type: "lineBreak"
80
+ }, {
81
+ type: "field",
82
+ field: "depth_percent",
83
+ style: "secondary",
84
+ prefix: "D",
85
+ format: "percent"
86
+ }, {
87
+ type: "separator"
88
+ }, {
89
+ type: "field",
90
+ field: "table_percent",
91
+ style: "secondary",
92
+ prefix: "T",
93
+ format: "percent"
94
+ }, {
95
+ type: "separator"
96
+ }, {
97
+ type: "field",
98
+ field: "measurement",
99
+ style: "secondary"
100
+ }, {
101
+ type: "separator"
102
+ }, {
103
+ type: "priceField",
104
+ field: "price_per_carat",
105
+ style: "secondary",
106
+ suffix: "PC"
107
+ }, {
108
+ type: "priceField",
109
+ field: "total_sales_price",
110
+ style: "secondary",
111
+ prefix: " ="
112
+ }];
113
+ const renderToken = (token, item, userCurrency, index) => {
114
+ const TextView = token.style === "secondary" ? TextStyleTwo : TextStyleOne;
115
+ const currency = userCurrency || "$";
116
+ const theme = useTheme();
117
+ switch (token.type) {
118
+ case "separator":
119
+ return /*#__PURE__*/React.createElement(TextView, {
120
+ key: index,
121
+ theme: theme
122
+ }, "·");
123
+ case "lineBreak":
124
+ return /*#__PURE__*/React.createElement(View, {
125
+ key: index,
126
+ style: styles.lineBreak
127
+ });
128
+ case "field":
129
+ {
130
+ let value = item[token.field] ?? "-";
131
+ if (token.format === "percent" && value !== "-") {
132
+ value = `${value}%`;
133
+ }
134
+ return /*#__PURE__*/React.createElement(React.Fragment, {
135
+ key: index
136
+ }, token.prefix && /*#__PURE__*/React.createElement(TextView, {
137
+ theme: theme
138
+ }, token.prefix), /*#__PURE__*/React.createElement(TextView, {
139
+ theme: theme
140
+ }, value));
141
+ }
142
+ case "fieldWithSuffix":
143
+ {
144
+ const value = item[token.field] ?? "-";
145
+ const showSuffix = token.showCurrencyIf ? item[token.showCurrencyIf] : true;
146
+ return /*#__PURE__*/React.createElement(View, {
147
+ key: index,
148
+ style: styles.rowCenter
149
+ }, /*#__PURE__*/React.createElement(TextView, {
150
+ theme: theme
151
+ }, value), showSuffix && token.suffix && /*#__PURE__*/React.createElement(TextView, {
152
+ theme: theme
153
+ }, token.suffix));
154
+ }
155
+ case "priceField":
156
+ {
157
+ const value = item[token.field];
158
+ return /*#__PURE__*/React.createElement(View, {
159
+ key: index,
160
+ style: styles.rowCenter
161
+ }, token.prefix && /*#__PURE__*/React.createElement(TextView, {
162
+ theme: theme
163
+ }, token.prefix), value && /*#__PURE__*/React.createElement(TextView, {
164
+ theme: theme
165
+ }, currency), /*#__PURE__*/React.createElement(TextView, {
166
+ theme: theme
167
+ }, value ?? "-"), token.suffix && /*#__PURE__*/React.createElement(TextView, {
168
+ theme: theme
169
+ }, token.suffix));
170
+ }
171
+ case "group":
172
+ return /*#__PURE__*/React.createElement(View, {
173
+ key: index,
174
+ style: styles.rowCenter
175
+ }, token.items?.map((subToken, subIndex) => renderToken(subToken, item, userCurrency, subIndex)));
176
+ default:
177
+ return null;
178
+ }
179
+ };
13
180
  const ProductsListViewComponent = ({
14
181
  data,
15
182
  totalResults,
@@ -18,6 +185,7 @@ const ProductsListViewComponent = ({
18
185
  item
19
186
  }) => {
20
187
  if (!data || !data.length) return null;
188
+ const theme = useTheme();
21
189
  const [userCurrency, setUserCurrency] = useState(null);
22
190
  useEffect(() => {
23
191
  const fetchCurrency = async () => {
@@ -26,118 +194,29 @@ const ProductsListViewComponent = ({
26
194
  };
27
195
  fetchCurrency();
28
196
  }, []);
29
- return /*#__PURE__*/React.createElement(View, {
30
- style: styles.wrapper
197
+ return /*#__PURE__*/React.createElement(Wrapper, {
198
+ theme: theme
31
199
  }, /*#__PURE__*/React.createElement(ScrollView, {
32
200
  showsVerticalScrollIndicator: false,
33
201
  contentContainerStyle: styles.listContent
34
- }, data.map((item, index) => /*#__PURE__*/React.createElement(Pressable, {
35
- key: item.id,
36
- onPress: () => onItemPress?.(item)
202
+ }, data.map((dataItem, index) => /*#__PURE__*/React.createElement(Pressable, {
203
+ key: dataItem.id,
204
+ onPress: () => onItemPress?.(dataItem)
37
205
  // @ts-ignore - hovered is available on web
38
206
  ,
39
207
  style: ({
40
208
  hovered
41
209
  }) => [styles.itemContainer, hovered && styles.itemHover]
42
- }, /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(View, {
210
+ }, /*#__PURE__*/React.createElement(View, {
43
211
  style: styles.left
44
212
  }, /*#__PURE__*/React.createElement(View, {
45
213
  style: styles.serialContainer
46
- }, /*#__PURE__*/React.createElement(Text, {
47
- style: styles.serial
48
- }, index + 1, ".")), /*#__PURE__*/React.createElement(View, {
214
+ }, /*#__PURE__*/React.createElement(Serial, null, index + 1, ".")), /*#__PURE__*/React.createElement(View, {
49
215
  style: styles.tokens
50
- }, /*#__PURE__*/React.createElement(Text, {
51
- style: styles.textStyleOne
52
- }, item.shape_long ?? "-"), /*#__PURE__*/React.createElement(View, {
53
- style: {
54
- flexDirection: "row",
55
- alignItems: "center"
56
- }
57
- }, /*#__PURE__*/React.createElement(Text, {
58
- style: styles.textStyleTwo
59
- }, item.size ?? "-"), item.price_per_carat ? /*#__PURE__*/React.createElement(Text, {
60
- style: styles.textStyleOne
61
- }, "ct") : /*#__PURE__*/React.createElement(React.Fragment, null)), /*#__PURE__*/React.createElement(Text, {
62
- style: styles.textStyleOne
63
- }, item.color ?? "-"), /*#__PURE__*/React.createElement(Text, {
64
- style: styles.textStyleOne
65
- }, item.clarity_short ?? "-"), /*#__PURE__*/React.createElement(Text, {
66
- style: styles.textStyleOne
67
- }, "·"), /*#__PURE__*/React.createElement(View, {
68
- style: {
69
- flexDirection: "row",
70
- alignItems: "center"
71
- }
72
- }, /*#__PURE__*/React.createElement(Text, {
73
- style: styles.textStyleOne
74
- }, item.cut_short ?? "-"), /*#__PURE__*/React.createElement(Text, {
75
- style: styles.textStyleOne
76
- }, "/"), /*#__PURE__*/React.createElement(Text, {
77
- style: styles.textStyleOne
78
- }, item.polish_short ?? "-"), /*#__PURE__*/React.createElement(Text, {
79
- style: styles.textStyleOne
80
- }, "/"), /*#__PURE__*/React.createElement(Text, {
81
- style: styles.textStyleOne
82
- }, item.symmetry_short ?? "-")), /*#__PURE__*/React.createElement(Text, {
83
- style: styles.textStyleOne
84
- }, "·"), /*#__PURE__*/React.createElement(Text, {
85
- style: styles.textStyleOne
86
- }, item.fluorescence_intensity_short ?? "-"), /*#__PURE__*/React.createElement(Text, {
87
- style: styles.textStyleOne
88
- }, "·"), /*#__PURE__*/React.createElement(Text, {
89
- style: styles.textStyleOne
90
- }, item.lab_short ?? "-"), /*#__PURE__*/React.createElement(Text, {
91
- style: styles.textStyleOne
92
- }, "·"), /*#__PURE__*/React.createElement(Text, {
93
- style: styles.textStyleTwo
94
- }, item.discount_percent ? item.discount_percent + "%" : "-"), /*#__PURE__*/React.createElement(View, {
95
- style: styles.lineBreak
96
- }), /*#__PURE__*/React.createElement(Text, {
97
- style: styles.textStyleOne
98
- }, "D"), /*#__PURE__*/React.createElement(Text, {
99
- style: styles.textStyleTwo
100
- }, item.depth_percent ? item.depth_percent + "%" : "-"), /*#__PURE__*/React.createElement(Text, {
101
- style: styles.textStyleOne
102
- }, "·"), /*#__PURE__*/React.createElement(Text, {
103
- style: styles.textStyleOne
104
- }, "T"), /*#__PURE__*/React.createElement(Text, {
105
- style: styles.textStyleTwo
106
- }, item.table_percent ? item.table_percent + "%" : "-"), /*#__PURE__*/React.createElement(Text, {
107
- style: styles.textStyleOne
108
- }, "·"), /*#__PURE__*/React.createElement(Text, {
109
- style: styles.textStyleTwo
110
- }, item.measurement ?? "-"), /*#__PURE__*/React.createElement(Text, {
111
- style: styles.textStyleOne
112
- }, "·"), /*#__PURE__*/React.createElement(View, {
113
- style: {
114
- flexDirection: "row",
115
- alignItems: "center"
116
- }
117
- }, item.price_per_carat ? /*#__PURE__*/React.createElement(Text, {
118
- style: styles.textStyleTwo
119
- }, userCurrency ? userCurrency : "$") : /*#__PURE__*/React.createElement(React.Fragment, null), /*#__PURE__*/React.createElement(Text, {
120
- style: styles.textStyleTwo
121
- }, item.price_per_carat ?? "-"), /*#__PURE__*/React.createElement(Text, {
122
- style: styles.textStyleOne
123
- }, "PC")), /*#__PURE__*/React.createElement(View, {
124
- style: {
125
- flexDirection: "row",
126
- alignItems: "center"
127
- }
128
- }, /*#__PURE__*/React.createElement(Text, {
129
- style: styles.textStyleOne
130
- }, " ="), item.total_sales_price ? /*#__PURE__*/React.createElement(Text, {
131
- style: styles.textStyleTwo
132
- }, userCurrency ? userCurrency : "$") : /*#__PURE__*/React.createElement(React.Fragment, null), /*#__PURE__*/React.createElement(Text, {
133
- style: styles.textStyleTwo
134
- }, item.total_sales_price ?? "-")))))))), /*#__PURE__*/React.createElement(TouchableOpacity, {
135
- style: styles.button,
216
+ }, DIAMOND_TOKENS.map((token, tokenIndex) => renderToken(token, dataItem, userCurrency, tokenIndex))))))), /*#__PURE__*/React.createElement(ButtonView, {
136
217
  activeOpacity: 0.8,
137
218
  onPress: () => onViewAll(item)
138
- }, /*#__PURE__*/React.createElement(Text, {
139
- style: styles.buttonText
140
- }, `View All ${totalResults} Results`), /*#__PURE__*/React.createElement(ImageComponent, {
219
+ }, /*#__PURE__*/React.createElement(ButtonText, null, `View All ${totalResults} Results`), /*#__PURE__*/React.createElement(ImageComponent, {
141
220
  source: {
142
221
  uri: "https://cdn.vdbapp.com/ai/chat-widget/assets/img/right.svg"
143
222
  },
@@ -145,24 +224,66 @@ const ProductsListViewComponent = ({
145
224
  style: {
146
225
  width: 20,
147
226
  height: 20,
148
- tintColor: "#fff"
227
+ tintColor: theme["primary-cont"] || "#ffffff"
149
228
  }
150
229
  })));
151
230
  };
231
+ const Wrapper = styled.View`
232
+ padding-horizontal: 8px;
233
+ `;
234
+ const Serial = styled.Text`
235
+ font-size: 13px;
236
+ color: ${({
237
+ theme
238
+ }) => theme["core-05"] || "#020001"};
239
+ font-weight: 500;
240
+ `;
241
+ const TextStyleOne = styled.Text`
242
+ font-size: 13px;
243
+ color: ${({
244
+ theme
245
+ }) => theme["core-06"] || "#4F4E57"};
246
+ font-weight: 400;
247
+ font-family: "Roboto";
248
+ font-style: normal;
249
+ `;
250
+ const TextStyleTwo = styled.Text`
251
+ font-size: 13px;
252
+ color: ${({
253
+ theme
254
+ }) => theme["core-05"] || "#020001"};
255
+ font-weight: 500;
256
+ font-family: "Roboto";
257
+ font-style: normal;
258
+ `;
259
+ const ButtonView = styled.TouchableOpacity`
260
+ margin-top: 12px;
261
+ margin-horizontal: 12px;
262
+ align-self: center;
263
+ padding-horizontal: 16px;
264
+ padding-vertical: 6px;
265
+ background-color: ${({
266
+ theme
267
+ }) => theme["primary-bg-static"] || "#292735"};
268
+ border-radius: 8px;
269
+ align-items: center;
270
+ gap: 16px;
271
+ width: 100%;
272
+ flex-direction: row;
273
+ justify-content: center;
274
+ align-content: center;
275
+ `;
276
+ const ButtonText = styled.Text`
277
+ color: ${({
278
+ theme
279
+ }) => theme["primary-cont"] || "#ffffff"};
280
+ font-size: 14px;
281
+ font-weight: 600;
282
+ `;
152
283
  const styles = StyleSheet.create({
153
- wrapper: {
154
- paddingHorizontal: 8
155
- },
156
284
  listContent: {
157
285
  gap: 8
158
286
  },
159
- row: {
160
- flexDirection: "row",
161
- justifyContent: "space-between",
162
- alignItems: "center",
163
- paddingVertical: 6,
164
- backgroundColor: "#fff"
165
- },
166
287
  left: {
167
288
  flexDirection: "row",
168
289
  alignItems: "flex-start",
@@ -184,30 +305,9 @@ const styles = StyleSheet.create({
184
305
  width: "100%",
185
306
  height: 0
186
307
  },
187
- serial: {
188
- fontSize: 13,
189
- color: "#020001",
190
- fontWeight: "500"
191
- },
192
- textStyleOne: {
193
- fontFamily: "Roboto",
194
- fontSize: 13,
195
- fontStyle: "normal",
196
- fontWeight: "400",
197
- color: "#4F4E57"
198
- },
199
- textStyleTwo: {
200
- fontFamily: "Roboto",
201
- fontSize: 13,
202
- fontStyle: "normal",
203
- fontWeight: "500",
204
- color: "#020001"
205
- },
206
- price: {
207
- fontSize: 13,
208
- fontWeight: "500",
209
- color: "#020001",
210
- textAlign: "left"
308
+ rowCenter: {
309
+ flexDirection: "row",
310
+ alignItems: "center"
211
311
  },
212
312
  priceContainer: {
213
313
  alignItems: "flex-start",
@@ -218,26 +318,6 @@ const styles = StyleSheet.create({
218
318
  },
219
319
  itemHover: {
220
320
  backgroundColor: "#EDEDF2"
221
- },
222
- button: {
223
- marginTop: 12,
224
- marginHorizontal: 12,
225
- alignSelf: "center",
226
- paddingHorizontal: 16,
227
- paddingVertical: 6,
228
- backgroundColor: "#292735",
229
- borderRadius: 8,
230
- alignItems: "center",
231
- gap: 16,
232
- width: "100%",
233
- flexDirection: "row",
234
- justifyContent: "center",
235
- alignContent: "center"
236
- },
237
- buttonText: {
238
- color: "#fff",
239
- fontSize: 14,
240
- fontWeight: "600"
241
321
  }
242
322
  });
243
323
  const ProductsListView = /*#__PURE__*/memo(ProductsListViewComponent);