@envive-ai/react-toolkit 0.1.0 → 0.1.1

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 (151) hide show
  1. package/LICENSE +2 -0
  2. package/package.json +10 -7
  3. package/src/atoms/search/types.ts +5 -0
  4. package/src/components/common/ButtonBase/ButtonBase.tsx +70 -0
  5. package/src/components/common/ButtonBase/types.ts +27 -0
  6. package/src/components/common/Headline/Headline.tsx +81 -0
  7. package/src/components/common/ImageWithFallback/ImageWithFallback.tsx +66 -0
  8. package/src/components/common/ProductCard/ProductCard.tsx +305 -0
  9. package/src/components/common/ProductCard/ProductCardSkeleton.tsx +83 -0
  10. package/src/components/common/ProductCard/productCardVariants.ts +63 -0
  11. package/src/components/common/ProductCard/types.ts +49 -0
  12. package/src/components/common/ProductGrid/ProductGrid.tsx +73 -0
  13. package/src/components/common/ProductGrid/productGridVariants.ts +31 -0
  14. package/src/components/common/SparkleAnimation/SparkleAnimation.tsx +105 -0
  15. package/src/components/common/SparkleAnimation/types.ts +6 -0
  16. package/src/components/common/Spinner/Spinner.tsx +30 -0
  17. package/src/components/common/SuggestionButton/SuggestionButton.tsx +258 -0
  18. package/src/components/common/SuggestionButton/types.ts +14 -0
  19. package/src/components/common/Text/Text.tsx +58 -0
  20. package/src/components/common/Text/textVariantClasses.ts +106 -0
  21. package/src/components/common/Text/types.ts +23 -0
  22. package/src/components/common/TextInput/TextInput.tsx +34 -0
  23. package/src/components/models/colorsConfig.ts +28 -0
  24. package/src/components/search/FilterScrollbar/AppliedFiltersScrollbar.tsx +70 -0
  25. package/src/components/search/FilterScrollbar/DynamicFiltersScrollbar.tsx +52 -0
  26. package/src/components/search/SearchFilter/SearchFilter.tsx +84 -0
  27. package/src/components/search/SearchFilter/SearchFilterHeader.tsx +42 -0
  28. package/src/components/search/SearchFilter/SearchFilterItem.tsx +42 -0
  29. package/src/components/search/SearchFilter/types.ts +48 -0
  30. package/src/components/search/SearchInput/SearchInput.tsx +135 -0
  31. package/src/components/search/SearchInput/searchInputVariants.ts +27 -0
  32. package/src/components/search/SearchInputAutocomplete/SearchAutocomplete.tsx +62 -0
  33. package/src/components/search/SearchInputForm/SearchInputForm.tsx +66 -0
  34. package/src/components/search/SearchResultsFilterSidebar/SearchResultsFilter.tsx +82 -0
  35. package/src/components/search/SearchResultsFilterSidebar/searchFilterSidebarVariants.ts +45 -0
  36. package/{dist/packages/components/src/components/search/SearchResultsFilterSidebar/types.d.ts → src/components/search/SearchResultsFilterSidebar/types.ts} +1 -1
  37. package/src/components/search/SearchResultsStates/NoSearchResultsFound.tsx +41 -0
  38. package/src/components/search/SearchResultsStates/SearchResultsGrid.tsx +105 -0
  39. package/src/components/search/SearchResultsStates/SearchResultsLoadingGrid.tsx +50 -0
  40. package/src/components/search/types.ts +5 -0
  41. package/{dist/packages/components/src/components/test/types.d.ts → src/components/test/types.ts} +1 -1
  42. package/src/config/chatElementDisplayLocation.ts +22 -0
  43. package/{dist/packages/components/src/index.js → src/index.ts} +10 -0
  44. package/src/logging/logger.ts +21 -0
  45. package/src/types/external.ts +24 -0
  46. package/{dist/packages/components/src/util/camelCase.d.ts → src/util/camelCase.ts} +33 -11
  47. package/src/util/camelCasedPropertiesDeep.ts +81 -0
  48. package/src/util/formatPrice.ts +14 -0
  49. package/src/util/internal.ts +95 -0
  50. package/{dist/packages/components/src/util/primitive.d.ts → src/util/primitive.ts} +2 -0
  51. package/src/util/splitWords.ts +72 -0
  52. package/{dist/packages/components/src/util/trim.d.ts → src/util/trim.ts} +5 -1
  53. package/dist/packages/components/src/atoms/search/types.d.ts +0 -5
  54. package/dist/packages/components/src/atoms/search/types.js +0 -1
  55. package/dist/packages/components/src/components/common/ButtonBase/ButtonBase.d.ts +0 -2
  56. package/dist/packages/components/src/components/common/ButtonBase/ButtonBase.js +0 -41
  57. package/dist/packages/components/src/components/common/ButtonBase/types.d.ts +0 -24
  58. package/dist/packages/components/src/components/common/ButtonBase/types.js +0 -6
  59. package/dist/packages/components/src/components/common/Headline/Headline.d.ts +0 -10
  60. package/dist/packages/components/src/components/common/Headline/Headline.js +0 -34
  61. package/dist/packages/components/src/components/common/ImageWithFallback/ImageWithFallback.d.ts +0 -12
  62. package/dist/packages/components/src/components/common/ImageWithFallback/ImageWithFallback.js +0 -26
  63. package/dist/packages/components/src/components/common/ProductCard/ProductCard.d.ts +0 -39
  64. package/dist/packages/components/src/components/common/ProductCard/ProductCard.js +0 -83
  65. package/dist/packages/components/src/components/common/ProductCard/ProductCardSkeleton.d.ts +0 -9
  66. package/dist/packages/components/src/components/common/ProductCard/ProductCardSkeleton.js +0 -15
  67. package/dist/packages/components/src/components/common/ProductCard/productCardVariants.d.ts +0 -8
  68. package/dist/packages/components/src/components/common/ProductCard/productCardVariants.js +0 -50
  69. package/dist/packages/components/src/components/common/ProductCard/types.d.ts +0 -39
  70. package/dist/packages/components/src/components/common/ProductCard/types.js +0 -10
  71. package/dist/packages/components/src/components/common/ProductGrid/ProductGrid.d.ts +0 -14
  72. package/dist/packages/components/src/components/common/ProductGrid/ProductGrid.js +0 -13
  73. package/dist/packages/components/src/components/common/ProductGrid/productGridVariants.d.ts +0 -10
  74. package/dist/packages/components/src/components/common/ProductGrid/productGridVariants.js +0 -16
  75. package/dist/packages/components/src/components/common/SparkleAnimation/SparkleAnimation.d.ts +0 -7
  76. package/dist/packages/components/src/components/common/SparkleAnimation/SparkleAnimation.js +0 -40
  77. package/dist/packages/components/src/components/common/SparkleAnimation/types.d.ts +0 -6
  78. package/dist/packages/components/src/components/common/SparkleAnimation/types.js +0 -7
  79. package/dist/packages/components/src/components/common/Spinner/Spinner.d.ts +0 -5
  80. package/dist/packages/components/src/components/common/Spinner/Spinner.js +0 -16
  81. package/dist/packages/components/src/components/common/SuggestionButton/SuggestionButton.d.ts +0 -18
  82. package/dist/packages/components/src/components/common/SuggestionButton/SuggestionButton.js +0 -210
  83. package/dist/packages/components/src/components/common/SuggestionButton/types.d.ts +0 -1
  84. package/dist/packages/components/src/components/common/SuggestionButton/types.js +0 -1
  85. package/dist/packages/components/src/components/common/Text/Text.d.ts +0 -12
  86. package/dist/packages/components/src/components/common/Text/Text.js +0 -26
  87. package/dist/packages/components/src/components/common/Text/textVariantClasses.d.ts +0 -171
  88. package/dist/packages/components/src/components/common/Text/textVariantClasses.js +0 -103
  89. package/dist/packages/components/src/components/common/Text/types.d.ts +0 -16
  90. package/dist/packages/components/src/components/common/Text/types.js +0 -6
  91. package/dist/packages/components/src/components/common/TextInput/TextInput.d.ts +0 -8
  92. package/dist/packages/components/src/components/common/TextInput/TextInput.js +0 -25
  93. package/dist/packages/components/src/components/models/colorsConfig.d.ts +0 -26
  94. package/dist/packages/components/src/components/models/colorsConfig.js +0 -23
  95. package/dist/packages/components/src/components/search/FilterScrollbar/AppliedFiltersScrollbar.d.ts +0 -11
  96. package/dist/packages/components/src/components/search/FilterScrollbar/AppliedFiltersScrollbar.js +0 -18
  97. package/dist/packages/components/src/components/search/FilterScrollbar/DynamicFiltersScrollbar.d.ts +0 -15
  98. package/dist/packages/components/src/components/search/FilterScrollbar/DynamicFiltersScrollbar.js +0 -15
  99. package/dist/packages/components/src/components/search/SearchFilter/SearchFilter.d.ts +0 -2
  100. package/dist/packages/components/src/components/search/SearchFilter/SearchFilter.js +0 -24
  101. package/dist/packages/components/src/components/search/SearchFilter/SearchFilterHeader.d.ts +0 -2
  102. package/dist/packages/components/src/components/search/SearchFilter/SearchFilterHeader.js +0 -9
  103. package/dist/packages/components/src/components/search/SearchFilter/SearchFilterItem.d.ts +0 -2
  104. package/dist/packages/components/src/components/search/SearchFilter/SearchFilterItem.js +0 -13
  105. package/dist/packages/components/src/components/search/SearchFilter/types.d.ts +0 -42
  106. package/dist/packages/components/src/components/search/SearchFilter/types.js +0 -1
  107. package/dist/packages/components/src/components/search/SearchInput/SearchInput.d.ts +0 -16
  108. package/dist/packages/components/src/components/search/SearchInput/SearchInput.js +0 -38
  109. package/dist/packages/components/src/components/search/SearchInput/searchInputVariants.d.ts +0 -13
  110. package/dist/packages/components/src/components/search/SearchInput/searchInputVariants.js +0 -12
  111. package/dist/packages/components/src/components/search/SearchInputAutocomplete/SearchAutocomplete.d.ts +0 -10
  112. package/dist/packages/components/src/components/search/SearchInputAutocomplete/SearchAutocomplete.js +0 -14
  113. package/dist/packages/components/src/components/search/SearchInputForm/SearchInputForm.d.ts +0 -16
  114. package/dist/packages/components/src/components/search/SearchInputForm/SearchInputForm.js +0 -13
  115. package/dist/packages/components/src/components/search/SearchInputForm/types.js +0 -1
  116. package/dist/packages/components/src/components/search/SearchResultsFilterSidebar/SearchResultsFilter.d.ts +0 -14
  117. package/dist/packages/components/src/components/search/SearchResultsFilterSidebar/SearchResultsFilter.js +0 -15
  118. package/dist/packages/components/src/components/search/SearchResultsFilterSidebar/searchFilterSidebarVariants.d.ts +0 -16
  119. package/dist/packages/components/src/components/search/SearchResultsFilterSidebar/searchFilterSidebarVariants.js +0 -29
  120. package/dist/packages/components/src/components/search/SearchResultsFilterSidebar/types.js +0 -1
  121. package/dist/packages/components/src/components/search/SearchResultsStates/NoSearchResultsFound.d.ts +0 -8
  122. package/dist/packages/components/src/components/search/SearchResultsStates/NoSearchResultsFound.js +0 -10
  123. package/dist/packages/components/src/components/search/SearchResultsStates/SearchResultsGrid.d.ts +0 -24
  124. package/dist/packages/components/src/components/search/SearchResultsStates/SearchResultsGrid.js +0 -19
  125. package/dist/packages/components/src/components/search/SearchResultsStates/SearchResultsLoadingGrid.d.ts +0 -6
  126. package/dist/packages/components/src/components/search/SearchResultsStates/SearchResultsLoadingGrid.js +0 -10
  127. package/dist/packages/components/src/components/search/types.d.ts +0 -5
  128. package/dist/packages/components/src/components/search/types.js +0 -6
  129. package/dist/packages/components/src/components/test/types.js +0 -1
  130. package/dist/packages/components/src/config/chatElementDisplayLocation.d.ts +0 -21
  131. package/dist/packages/components/src/config/chatElementDisplayLocation.js +0 -23
  132. package/dist/packages/components/src/index.d.ts +0 -45
  133. package/dist/packages/components/src/logging/logger.d.ts +0 -7
  134. package/dist/packages/components/src/logging/logger.js +0 -16
  135. package/dist/packages/components/src/types/external.d.ts +0 -21
  136. package/dist/packages/components/src/types/external.js +0 -5
  137. package/dist/packages/components/src/util/camelCase.js +0 -2
  138. package/dist/packages/components/src/util/camelCasedPropertiesDeep.d.ts +0 -53
  139. package/dist/packages/components/src/util/camelCasedPropertiesDeep.js +0 -1
  140. package/dist/packages/components/src/util/formatPrice.d.ts +0 -1
  141. package/dist/packages/components/src/util/formatPrice.js +0 -11
  142. package/dist/packages/components/src/util/internal.d.ts +0 -27
  143. package/dist/packages/components/src/util/internal.js +0 -4
  144. package/dist/packages/components/src/util/primitive.js +0 -2
  145. package/dist/packages/components/src/util/splitWords.d.ts +0 -55
  146. package/dist/packages/components/src/util/splitWords.js +0 -2
  147. package/dist/packages/components/src/util/trim.js +0 -2
  148. package/dist/packages/components/src/util/unknownArray.js +0 -1
  149. package/dist/tsconfig.tsbuildinfo +0 -1
  150. /package/{dist/packages/components/src/components/search/SearchInputForm/types.d.ts → src/components/search/SearchInputForm/types.ts} +0 -0
  151. /package/{dist/packages/components/src/util/unknownArray.d.ts → src/util/unknownArray.ts} +0 -0
@@ -10,6 +10,7 @@ export { Spinner } from './components/common/Spinner/Spinner';
10
10
  export { SuggestionButton } from './components/common/SuggestionButton/SuggestionButton';
11
11
  export { Text } from './components/common/Text/Text';
12
12
  export { TextInput } from './components/common/TextInput/TextInput';
13
+
13
14
  // Search Components
14
15
  export { AppliedFiltersScrollbar } from './components/search/FilterScrollbar/AppliedFiltersScrollbar';
15
16
  export { DynamicFiltersScrollbar } from './components/search/FilterScrollbar/DynamicFiltersScrollbar';
@@ -23,6 +24,7 @@ export { SearchResultsFilter } from './components/search/SearchResultsFilterSide
23
24
  export { NoSearchResultsFound } from './components/search/SearchResultsStates/NoSearchResultsFound';
24
25
  export { SearchResultsGrid } from './components/search/SearchResultsStates/SearchResultsGrid';
25
26
  export { SearchResultsLoadingGrid } from './components/search/SearchResultsStates/SearchResultsLoadingGrid';
27
+
26
28
  // Utilities
27
29
  export * from './util/camelCase';
28
30
  export * from './util/camelCasedPropertiesDeep';
@@ -32,18 +34,26 @@ export * from './util/primitive';
32
34
  export * from './util/splitWords';
33
35
  export * from './util/trim';
34
36
  export * from './util/unknownArray';
37
+
35
38
  // Types
36
39
  export * from './components/common/ButtonBase/types';
37
40
  export * from './components/common/ProductCard/types';
38
41
  export * from './components/common/SparkleAnimation/types';
39
42
  export * from './components/common/SuggestionButton/types';
40
43
  export * from './components/common/Text/types';
44
+ export type { HeadlineProps, HeadlineVariant } from './components/common/Text/types'; // Explicitly re-export from types.ts
41
45
  export * from './components/search/types';
42
46
  export * from './components/search/SearchFilter/types';
43
47
  export * from './components/search/SearchInputForm/types';
48
+ export type {
49
+ SearchFilterSidebarVariant,
50
+ CloseIconVariant as CloseIconVariantType,
51
+ } from './components/search/SearchResultsFilterSidebar/types';
44
52
  export * from './atoms/search/types';
53
+
45
54
  // Config exports
46
55
  export { ChatElementDisplayLocation } from './config/chatElementDisplayLocation';
56
+
47
57
  // Variants
48
58
  export { productGridVariantClasses } from './components/common/ProductGrid/productGridVariants';
49
59
  export { searchFilterSidebarVariantClasses } from './components/search/SearchResultsFilterSidebar/searchFilterSidebarVariants';
@@ -0,0 +1,21 @@
1
+ /* eslint-disable no-console */
2
+
3
+ class Logger {
4
+ static logInfo(message: string, ...args: unknown[]): void {
5
+ console.info(`INFO: ${message}`, ...args);
6
+ }
7
+
8
+ static logDebug(message: string, ...args: unknown[]): void {
9
+ console.debug(`DEBUG: ${message}`, ...args);
10
+ }
11
+
12
+ static logError(message: string, error: unknown | undefined, ...args: unknown[]): void {
13
+ console.error(`ERROR: ${message} error=${error}`, args);
14
+ }
15
+
16
+ static logWarn(message: string, error: unknown | undefined, ...args: unknown[]): void {
17
+ console.warn(`WARN: ${message} error=${error}`, args);
18
+ }
19
+ }
20
+
21
+ export default Logger;
@@ -0,0 +1,24 @@
1
+ // Local type definitions for external dependencies that may not be available
2
+
3
+ export enum ResponseCategory {
4
+ Product = 'product',
5
+ }
6
+
7
+ export interface SearchResponseProduct {
8
+ id: string;
9
+ title: string;
10
+ description?: string;
11
+ price?: number;
12
+ currency?: string;
13
+ imageUrl?: string;
14
+ brand?: string;
15
+ category?: string;
16
+ availability?: string;
17
+ url?: string;
18
+ responseId?: string;
19
+ originalPrice?: number;
20
+ salePrice?: number;
21
+ averageRating?: number;
22
+ numberReviews?: number;
23
+ [key: string]: unknown;
24
+ }
@@ -1,21 +1,34 @@
1
+ // these types come from https://github.com/sindresorhus/type-fest/blob/main/source/camel-case.d.ts
2
+
1
3
  import type { SplitWords } from './splitWords';
4
+
2
5
  /**
3
6
  * CamelCase options.
4
7
  *
5
8
  * @see {@link CamelCase}
6
9
  */
7
10
  export type CamelCaseOptions = {
8
- /**
9
- * Whether to preserved consecutive uppercase letter.
10
- *
11
- * @default true
12
- */
13
- preserveConsecutiveUppercase?: boolean;
11
+ /**
12
+ * Whether to preserved consecutive uppercase letter.
13
+ *
14
+ * @default true
15
+ */
16
+ preserveConsecutiveUppercase?: boolean;
14
17
  };
18
+
15
19
  /**
16
20
  * Convert an array of words to camel-case.
17
21
  */
18
- type CamelCaseFromArray<Words extends string[], Options extends CamelCaseOptions, OutputString extends string = ''> = Words extends [infer FirstWord extends string, ...infer RemainingWords extends string[]] ? Options['preserveConsecutiveUppercase'] extends true ? `${Capitalize<FirstWord>}${CamelCaseFromArray<RemainingWords, Options>}` : `${Capitalize<Lowercase<FirstWord>>}${CamelCaseFromArray<RemainingWords, Options>}` : OutputString;
22
+ type CamelCaseFromArray<
23
+ Words extends string[],
24
+ Options extends CamelCaseOptions,
25
+ OutputString extends string = '',
26
+ > = Words extends [infer FirstWord extends string, ...infer RemainingWords extends string[]]
27
+ ? Options['preserveConsecutiveUppercase'] extends true
28
+ ? `${Capitalize<FirstWord>}${CamelCaseFromArray<RemainingWords, Options>}`
29
+ : `${Capitalize<Lowercase<FirstWord>>}${CamelCaseFromArray<RemainingWords, Options>}`
30
+ : OutputString;
31
+
19
32
  /**
20
33
  * Convert a string literal to camel-case.
21
34
  *
@@ -59,7 +72,16 @@ type CamelCaseFromArray<Words extends string[], Options extends CamelCaseOptions
59
72
  * @category Change case
60
73
  * @category Template literal
61
74
  */
62
- export type CamelCase<Type, Options extends CamelCaseOptions = {
63
- preserveConsecutiveUppercase: true;
64
- }> = Type extends string ? string extends Type ? Type : Uncapitalize<CamelCaseFromArray<SplitWords<Type extends Uppercase<Type> ? Lowercase<Type> : Type>, Options>> : Type;
65
- export {};
75
+ export type CamelCase<
76
+ Type,
77
+ Options extends CamelCaseOptions = { preserveConsecutiveUppercase: true },
78
+ > = Type extends string
79
+ ? string extends Type
80
+ ? Type
81
+ : Uncapitalize<
82
+ CamelCaseFromArray<
83
+ SplitWords<Type extends Uppercase<Type> ? Lowercase<Type> : Type>,
84
+ Options
85
+ >
86
+ >
87
+ : Type;
@@ -0,0 +1,81 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-function-type */
2
+ import type { CamelCase, CamelCaseOptions } from './camelCase';
3
+ import type { UnknownArray } from './unknownArray';
4
+
5
+ /**
6
+ * Convert object properties to camel case recursively.
7
+ *
8
+ * This can be useful when, for example, converting some API types from a different style.
9
+ *
10
+ * @see CamelCasedProperties
11
+ * @see CamelCase
12
+ *
13
+ * @example
14
+ * ```
15
+ * import type {CamelCasedPropertiesDeep} from 'type-fest';
16
+ *
17
+ * interface User {
18
+ * UserId: number;
19
+ * UserName: string;
20
+ * }
21
+ *
22
+ * interface UserWithFriends {
23
+ * UserInfo: User;
24
+ * UserFriends: User[];
25
+ * }
26
+ *
27
+ * const result: CamelCasedPropertiesDeep<UserWithFriends> = {
28
+ * userInfo: {
29
+ * userId: 1,
30
+ * userName: 'Tom',
31
+ * },
32
+ * userFriends: [
33
+ * {
34
+ * userId: 2,
35
+ * userName: 'Jerry',
36
+ * },
37
+ * {
38
+ * userId: 3,
39
+ * userName: 'Spike',
40
+ * },
41
+ * ],
42
+ * };
43
+ * ```
44
+ *
45
+ * @category Change case
46
+ * @category Template literal
47
+ * @category Object
48
+ */
49
+ export type CamelCasedPropertiesDeep<
50
+ Value,
51
+ Options extends CamelCaseOptions = { preserveConsecutiveUppercase: true },
52
+ > = Value extends Function
53
+ ? Value
54
+ : Value extends UnknownArray
55
+ ? CamelCasedPropertiesArrayDeep<Value>
56
+ : Value extends Set<infer U>
57
+ ? Set<CamelCasedPropertiesDeep<U, Options>>
58
+ : {
59
+ [K in keyof Value as CamelCase<K, Options>]: CamelCasedPropertiesDeep<Value[K], Options>;
60
+ };
61
+
62
+ // This is a copy of DelimiterCasedPropertiesArrayDeep (see: delimiter-cased-properties-deep.d.ts).
63
+ // These types should be kept in sync.
64
+ type CamelCasedPropertiesArrayDeep<Value extends UnknownArray> = Value extends []
65
+ ? []
66
+ : // Tailing spread array
67
+ Value extends [infer U, ...infer V]
68
+ ? [CamelCasedPropertiesDeep<U>, ...CamelCasedPropertiesDeep<V>]
69
+ : Value extends readonly [infer U, ...infer V]
70
+ ? readonly [CamelCasedPropertiesDeep<U>, ...CamelCasedPropertiesDeep<V>]
71
+ : // Leading spread array
72
+ Value extends readonly [...infer U, infer V]
73
+ ? [...CamelCasedPropertiesDeep<U>, CamelCasedPropertiesDeep<V>]
74
+ : Value extends readonly [...infer U, infer V]
75
+ ? readonly [...CamelCasedPropertiesDeep<U>, CamelCasedPropertiesDeep<V>]
76
+ : // Array
77
+ Value extends Array<infer U>
78
+ ? Array<CamelCasedPropertiesDeep<U>>
79
+ : Value extends ReadonlyArray<infer U>
80
+ ? ReadonlyArray<CamelCasedPropertiesDeep<U>>
81
+ : never;
@@ -0,0 +1,14 @@
1
+ export const formatPrice = (price?: number, currency: string = '$'): string => {
2
+ if (price == null) {
3
+ return '';
4
+ }
5
+
6
+ const options: Intl.NumberFormatOptions = {};
7
+
8
+ if (!Number.isInteger(price)) {
9
+ options.minimumFractionDigits = 2;
10
+ options.maximumFractionDigits = 2;
11
+ }
12
+
13
+ return `${currency}${price.toLocaleString('en-US', options)}`;
14
+ };
@@ -0,0 +1,95 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /* eslint-disable @typescript-eslint/no-unsafe-function-type */
3
+ // these types come from https://github.com/sindresorhus/type-fest/blob/main/source/internal.d.ts
4
+
5
+ import type { Primitive } from './primitive';
6
+ import type { Trim } from './trim';
7
+
8
+ /**
9
+ * Matches any primitive, `void`, `Date`, or `RegExp` value.
10
+ */
11
+ export type BuiltIns = Primitive | void | Date | RegExp;
12
+
13
+ /**
14
+ * Matches non-recursive types.
15
+ */
16
+ export type NonRecursiveType = BuiltIns | Function | (new (...arguments_: any[]) => unknown);
17
+
18
+ /**
19
+ * Returns a boolean for whether the string is numeric.
20
+ *
21
+ * This type is a workaround for [Microsoft/TypeScript#46109](https://github.com/microsoft/TypeScript/issues/46109#issuecomment-930307987).
22
+ */
23
+ export type IsNumeric<T extends string> = T extends `${number}`
24
+ ? Trim<T> extends T
25
+ ? true
26
+ : false
27
+ : false;
28
+
29
+ /**
30
+ * Returns a boolean for whether the string is lowercased.
31
+ */
32
+ export type IsLowerCase<T extends string> = T extends Lowercase<T> ? true : false;
33
+
34
+ /**
35
+ * Returns a boolean for whether the string is upper-cased.
36
+ */
37
+ export type IsUpperCase<T extends string> = T extends Uppercase<T> ? true : false;
38
+
39
+ export type WordSeparators = '-' | '_' | Whitespace;
40
+
41
+ export type Whitespace =
42
+ | '\u{9}' // '\t'
43
+ | '\u{A}' // '\n'
44
+ | '\u{B}' // '\v'
45
+ | '\u{C}' // '\f'
46
+ | '\u{D}' // '\r'
47
+ | '\u{20}' // ' '
48
+ | '\u{85}'
49
+ | '\u{A0}'
50
+ | '\u{1680}'
51
+ | '\u{2000}'
52
+ | '\u{2001}'
53
+ | '\u{2002}'
54
+ | '\u{2003}'
55
+ | '\u{2004}'
56
+ | '\u{2005}'
57
+ | '\u{2006}'
58
+ | '\u{2007}'
59
+ | '\u{2008}'
60
+ | '\u{2009}'
61
+ | '\u{200A}'
62
+ | '\u{2028}'
63
+ | '\u{2029}'
64
+ | '\u{202F}'
65
+ | '\u{205F}'
66
+ | '\u{3000}'
67
+ | '\u{FEFF}';
68
+
69
+ export type UpperCaseCharacters =
70
+ | 'A'
71
+ | 'B'
72
+ | 'C'
73
+ | 'D'
74
+ | 'E'
75
+ | 'F'
76
+ | 'G'
77
+ | 'H'
78
+ | 'I'
79
+ | 'J'
80
+ | 'K'
81
+ | 'L'
82
+ | 'M'
83
+ | 'N'
84
+ | 'O'
85
+ | 'P'
86
+ | 'Q'
87
+ | 'R'
88
+ | 'S'
89
+ | 'T'
90
+ | 'U'
91
+ | 'V'
92
+ | 'W'
93
+ | 'X'
94
+ | 'Y'
95
+ | 'Z';
@@ -1,3 +1,5 @@
1
+ // this type comes from https://github.com/sindresorhus/type-fest/blob/main/source/primitive.d.ts
2
+
1
3
  /**
2
4
  * Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
3
5
  *
@@ -0,0 +1,72 @@
1
+ // these types come from https://github.com/sindresorhus/type-fest/blob/main/source/split-words.d.ts
2
+
3
+ import type { IsLowerCase, IsNumeric, IsUpperCase, WordSeparators } from './internal';
4
+
5
+ type SkipEmptyWord<Word extends string> = Word extends '' ? [] : [Word];
6
+
7
+ type RemoveLastCharacter<
8
+ Sentence extends string,
9
+ Character extends string,
10
+ > = Sentence extends `${infer LeftSide}${Character}` ? SkipEmptyWord<LeftSide> : never;
11
+
12
+ /**
13
+ * Split a string (almost) like Lodash's `_.words()` function.
14
+ *
15
+ * - Split on each word that begins with a capital letter.
16
+ * - Split on each {@link WordSeparators}.
17
+ * - Split on numeric sequence.
18
+ *
19
+ * @example
20
+ * ```
21
+ * type Words0 = SplitWords<'helloWorld'>; // ['hello', 'World']
22
+ * type Words1 = SplitWords<'helloWORLD'>; // ['hello', 'WORLD']
23
+ * type Words2 = SplitWords<'hello-world'>; // ['hello', 'world']
24
+ * type Words3 = SplitWords<'--hello the_world'>; // ['hello', 'the', 'world']
25
+ * type Words4 = SplitWords<'lifeIs42'>; // ['life', 'Is', '42']
26
+ * ```
27
+ *
28
+ * @internal
29
+ * @category Change case
30
+ * @category Template literal
31
+ */
32
+ export type SplitWords<
33
+ Sentence extends string,
34
+ LastCharacter extends string = '',
35
+ CurrentWord extends string = '',
36
+ > = Sentence extends `${infer FirstCharacter}${infer RemainingCharacters}`
37
+ ? FirstCharacter extends WordSeparators
38
+ ? // Skip word separator
39
+ [...SkipEmptyWord<CurrentWord>, ...SplitWords<RemainingCharacters>]
40
+ : LastCharacter extends ''
41
+ ? // Fist char of word
42
+ SplitWords<RemainingCharacters, FirstCharacter, FirstCharacter>
43
+ : // Case change: non-numeric to numeric, push word
44
+ [false, true] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>]
45
+ ? [
46
+ ...SkipEmptyWord<CurrentWord>,
47
+ ...SplitWords<RemainingCharacters, FirstCharacter, FirstCharacter>,
48
+ ]
49
+ : // Case change: numeric to non-numeric, push word
50
+ [true, false] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>]
51
+ ? [
52
+ ...SkipEmptyWord<CurrentWord>,
53
+ ...SplitWords<RemainingCharacters, FirstCharacter, FirstCharacter>,
54
+ ]
55
+ : // No case change: concat word
56
+ [true, true] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>]
57
+ ? SplitWords<RemainingCharacters, FirstCharacter, `${CurrentWord}${FirstCharacter}`>
58
+ : // Case change: lower to upper, push word
59
+ [true, true] extends [IsLowerCase<LastCharacter>, IsUpperCase<FirstCharacter>]
60
+ ? [
61
+ ...SkipEmptyWord<CurrentWord>,
62
+ ...SplitWords<RemainingCharacters, FirstCharacter, FirstCharacter>,
63
+ ]
64
+ : // Case change: upper to lower, brings back the last character, push word
65
+ [true, true] extends [IsUpperCase<LastCharacter>, IsLowerCase<FirstCharacter>]
66
+ ? [
67
+ ...RemoveLastCharacter<CurrentWord, LastCharacter>,
68
+ ...SplitWords<RemainingCharacters, FirstCharacter, `${LastCharacter}${FirstCharacter}`>,
69
+ ]
70
+ : // No case change: concat word
71
+ SplitWords<RemainingCharacters, FirstCharacter, `${CurrentWord}${FirstCharacter}`>
72
+ : [...SkipEmptyWord<CurrentWord>];
@@ -1,12 +1,17 @@
1
+ // these types come from https://github.com/sindresorhus/type-fest/blob/main/source/trim.d.ts
2
+
1
3
  import type { Whitespace } from './internal';
4
+
2
5
  /**
3
6
  * Remove spaces from the left side.
4
7
  */
5
8
  type TrimLeft<V extends string> = V extends `${Whitespace}${infer R}` ? TrimLeft<R> : V;
9
+
6
10
  /**
7
11
  * Remove spaces from the right side.
8
12
  */
9
13
  type TrimRight<V extends string> = V extends `${infer R}${Whitespace}` ? TrimRight<R> : V;
14
+
10
15
  /**
11
16
  * Remove leading and trailing spaces from a string.
12
17
  * @example
@@ -21,4 +26,3 @@ type TrimRight<V extends string> = V extends `${infer R}${Whitespace}` ? TrimRig
21
26
  * @category Template literal
22
27
  */
23
28
  export type Trim<V extends string> = TrimLeft<TrimRight<V>>;
24
- export {};
@@ -1,5 +0,0 @@
1
- export type SelectedFilterOption = {
2
- id: string;
3
- displayName: string;
4
- value: string;
5
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import { type ButtonBaseProps } from './types';
2
- export declare const ButtonBase: ({ type, isDisabled, dataAttributes, buttonClass, text, textClass, icon, iconClass, dataTestId, onClick, disablePadding, }: ButtonBaseProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,41 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import classNames from 'classnames';
3
- import { createElement, useEffect, useRef } from 'react';
4
- import { ButtonBaseOverrides } from './types';
5
- import { Text } from '../../../../../../src/components/common/Text/Text';
6
- export const ButtonBase = ({ type = 'button', isDisabled = false, dataAttributes, buttonClass, text, textClass, icon, iconClass = 'spiffy-tw-w-[21px] spiffy-tw-h-[21px]', dataTestId, onClick, disablePadding = false, }) => {
7
- const buttonRef = useRef(null);
8
- const buttonClassName = classNames({
9
- [ButtonBaseOverrides.BUTTON]: true,
10
- 'spiffy-tw-flex': true,
11
- 'spiffy-tw-min-h-[36px]': true,
12
- 'spiffy-tw-cursor-pointer': true,
13
- 'spiffy-tw-items-center': true,
14
- 'spiffy-tw-gap-2': true,
15
- 'spiffy-tw-px-4': !disablePadding,
16
- 'spiffy-tw-transition-colors': true,
17
- 'spiffy-tw-opacity-40': isDisabled,
18
- 'spiffy-tw-cursor-not-allowed': isDisabled,
19
- [`${buttonClass}`]: buttonClass != null,
20
- });
21
- const textClassName = classNames({
22
- [ButtonBaseOverrides.BUTTON_TEXT]: true,
23
- 'spiffy-tw-whitespace-nowrap': true,
24
- [`${textClass}`]: textClass != null,
25
- });
26
- const iconClassName = classNames({
27
- [ButtonBaseOverrides.BUTTON_ICON]: true,
28
- [`${iconClass}`]: iconClass != null,
29
- });
30
- useEffect(() => {
31
- if (dataAttributes && buttonRef.current) {
32
- Object.entries(dataAttributes).forEach(([key, value]) => {
33
- buttonRef.current?.setAttribute(key, value);
34
- });
35
- }
36
- }, [dataAttributes]);
37
- return (_jsxs("button", { type: type, ref: buttonRef, className: buttonClassName, disabled: isDisabled, "data-testid": dataTestId, onClick: onClick, children: [icon &&
38
- createElement(icon, {
39
- className: iconClassName,
40
- }), _jsx(Text, { className: textClassName, children: text })] }));
41
- };
@@ -1,24 +0,0 @@
1
- import type { ButtonHTMLAttributes, CSSProperties } from 'react';
2
- import type { TestProps } from '../../../../../../src/components/test/types';
3
- export interface ButtonHoverStyles extends CSSProperties {
4
- backgroundColor?: string;
5
- color?: string;
6
- }
7
- export interface ButtonBaseProps extends TestProps {
8
- type?: ButtonHTMLAttributes<HTMLButtonElement>['type'];
9
- isDisabled?: boolean;
10
- dataAttributes?: Record<string, string>;
11
- buttonClass?: string;
12
- text: string;
13
- textClass?: string;
14
- icon?: React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
15
- iconClass?: string;
16
- onClick?: () => void;
17
- disablePadding?: boolean;
18
- dataTestId?: string;
19
- }
20
- export declare enum ButtonBaseOverrides {
21
- BUTTON = "spiffy-button-base-button",
22
- BUTTON_TEXT = "spiffy-button-base-button-text",
23
- BUTTON_ICON = "spiffy-button-base-button-icon"
24
- }
@@ -1,6 +0,0 @@
1
- export var ButtonBaseOverrides;
2
- (function (ButtonBaseOverrides) {
3
- ButtonBaseOverrides["BUTTON"] = "spiffy-button-base-button";
4
- ButtonBaseOverrides["BUTTON_TEXT"] = "spiffy-button-base-button-text";
5
- ButtonBaseOverrides["BUTTON_ICON"] = "spiffy-button-base-button-icon";
6
- })(ButtonBaseOverrides || (ButtonBaseOverrides = {}));
@@ -1,10 +0,0 @@
1
- export type HeadlineVariant = 't1' | 't2' | 't3' | 'h1' | 'h2' | 'h3' | 'h4';
2
- export type HeadlineProps = {
3
- children: React.ReactNode;
4
- className?: string;
5
- style?: React.CSSProperties;
6
- variant?: HeadlineVariant;
7
- testId?: string;
8
- id?: string;
9
- };
10
- export declare const Headline: ({ children, className, style, testId, variant }: HeadlineProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,34 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import classNames from 'classnames';
3
- import { HeadlineVariantMap } from '../Text/textVariantClasses';
4
- export const Headline = ({ children, className, style, testId, variant = 'h1' }) => {
5
- const variantClassNames = variant ? HeadlineVariantMap[variant] : {};
6
- const textClassNames = classNames(className, variantClassNames, {
7
- 'spiffy-tw-font-[Poppins,sans-serif]': true,
8
- });
9
- const T1 = () => (_jsx("h1", { "data-testid": testId, className: textClassNames, style: style, children: children }));
10
- const T2 = () => (_jsx("h2", { "data-testid": testId, className: textClassNames, style: style, children: children }));
11
- const T3 = () => (_jsx("h3", { "data-testid": testId, className: textClassNames, style: style, children: children }));
12
- const H1 = () => (_jsx("h1", { "data-testid": testId, className: textClassNames, style: style, children: children }));
13
- const H2 = () => (_jsx("h2", { "data-testid": testId, className: textClassNames, style: style, children: children }));
14
- const H3 = () => (_jsx("h3", { "data-testid": testId, className: textClassNames, style: style, children: children }));
15
- const H4 = () => (_jsx("h4", { "data-testid": testId, className: textClassNames, style: style, children: children }));
16
- switch (variant) {
17
- case 't1':
18
- return T1();
19
- case 't2':
20
- return T2();
21
- case 't3':
22
- return T3();
23
- case 'h1':
24
- return H1();
25
- case 'h2':
26
- return H2();
27
- case 'h3':
28
- return H3();
29
- case 'h4':
30
- return H4();
31
- default:
32
- throw new Error(`Invalid variant: ${variant}`);
33
- }
34
- };
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- export interface ImageWithFallbackProps {
3
- src: string | undefined;
4
- alt: string;
5
- fallbackClassnames?: string;
6
- fallback: React.ReactNode;
7
- dataTestId?: string;
8
- imageClassnames: string;
9
- onLoad?: () => void;
10
- onError?: () => void;
11
- }
12
- export declare const ImageWithFallback: ({ src, alt, dataTestId, fallbackClassnames, fallback, imageClassnames, onLoad, onError, }: ImageWithFallbackProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,26 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import classNames from 'classnames';
3
- import { useState } from 'react';
4
- export const ImageWithFallback = ({ src, alt, dataTestId, fallbackClassnames, fallback, imageClassnames, onLoad, onError, }) => {
5
- const [isLoaded, setIsLoaded] = useState(false);
6
- const [isError, setIsError] = useState(false);
7
- const imageExtraClassnames = classNames(imageClassnames, {
8
- 'spiffy-tw-block': isLoaded,
9
- 'spiffy-tw-hidden': !isLoaded,
10
- });
11
- const fallbackMergedClassNames = classNames({
12
- 'spiffy-tw-flex': true,
13
- 'spiffy-tw-flex-col': true,
14
- 'spiffy-tw-items-center': true,
15
- }, fallbackClassnames);
16
- if (isError) {
17
- return _jsx("div", { className: fallbackMergedClassNames, children: fallback });
18
- }
19
- return (_jsxs(_Fragment, { children: [!isLoaded && _jsx("div", { className: fallbackMergedClassNames, children: fallback }), _jsx("img", { src: src, className: imageExtraClassnames, "data-testid": dataTestId, alt: alt, onLoad: () => {
20
- setIsLoaded(true);
21
- onLoad?.();
22
- }, onError: () => {
23
- setIsError(true);
24
- onError?.();
25
- } })] }));
26
- };
@@ -1,39 +0,0 @@
1
- import type { ProductCardConfig, ProductCardHoverVariant, ProductCardLayoutVariant, ProductCardVariant } from './types';
2
- import { ChatElementDisplayLocation } from '@envive/components';
3
- import { TestProps } from '../../test/types';
4
- interface RatingSummaryProps {
5
- stars: number;
6
- reviewCount: number;
7
- className?: string;
8
- }
9
- export declare const RatingSummary: ({ stars, reviewCount, className }: RatingSummaryProps) => import("react/jsx-runtime").JSX.Element;
10
- interface PriceSectionProps {
11
- originalPrice?: string;
12
- salePrice?: string;
13
- pricePrefix?: string;
14
- }
15
- export declare const PriceSection: ({ originalPrice, salePrice, pricePrefix }: PriceSectionProps) => import("react/jsx-runtime").JSX.Element;
16
- interface ProductCardProps extends TestProps {
17
- productCardConfig?: ProductCardConfig;
18
- merchantShortName: string;
19
- title: string;
20
- url?: string;
21
- searchResponseId?: string;
22
- productResponseId?: string;
23
- cardDisplayLocation: ChatElementDisplayLocation.IN_CHAT | ChatElementDisplayLocation.PRODUCT_GRID;
24
- imageUrl?: string;
25
- originalPrice?: number;
26
- averageRating?: number;
27
- numberReviews?: number;
28
- salePrice?: number;
29
- variant?: ProductCardVariant;
30
- hoverVariant?: ProductCardHoverVariant;
31
- layoutVariant?: ProductCardLayoutVariant;
32
- zoomOnHover?: boolean;
33
- aspectRatio?: '3:4' | 'square' | 'none';
34
- clickPosition?: number | null;
35
- growWithContainer?: boolean;
36
- handleClick: (clickedUrl: string) => void;
37
- }
38
- export declare const ProductCard: ({ productCardConfig, merchantShortName, imageUrl, title, url, originalPrice, averageRating, numberReviews, salePrice, variant, hoverVariant, dataTestId, layoutVariant, zoomOnHover, aspectRatio, growWithContainer, handleClick, }: ProductCardProps) => import("react/jsx-runtime").JSX.Element;
39
- export {};