@constructor-io/constructorio-ui-pia 2.12.0 → 2.13.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 (49) hide show
  1. package/dist/constructorio-ui-pia-bundled.js +54 -54
  2. package/lib/cjs/components/CioPia/CioPiaQna.js +8 -3
  3. package/lib/cjs/components/CioPia/CioPiaStyles.css +5 -0
  4. package/lib/cjs/components/CioPia/PiaCustomCarousel.js +11 -1
  5. package/lib/cjs/components/ConversationHistory/ConversationHistory.js +10 -5
  6. package/lib/cjs/components/Error/ErrorBlock.js +7 -5
  7. package/lib/cjs/components/Feedback/Feedback.js +4 -4
  8. package/lib/cjs/components/Input/Input.js +2 -1
  9. package/lib/cjs/components/LoadingSkeleton/LoadingSkeleton.js +2 -1
  10. package/lib/cjs/components/PiaConversation/PiaModal.js +22 -4
  11. package/lib/cjs/components/StatusRegion/StatusRegion.js +34 -0
  12. package/lib/cjs/components/SuggestedQuestionsContainer/SuggestedQuestionsSkeleton.js +1 -1
  13. package/lib/cjs/components/icons/QuestionIcon.js +1 -1
  14. package/lib/cjs/components/icons/SendIcon.js +1 -1
  15. package/lib/cjs/components/icons/SparklesIcon.js +1 -1
  16. package/lib/cjs/hooks/useAnswerResults.js +12 -3
  17. package/lib/cjs/hooks/useConversation.js +24 -10
  18. package/lib/cjs/hooks/useRecsPod.js +15 -7
  19. package/lib/cjs/hooks/useSuggestedQuestions.js +12 -3
  20. package/lib/cjs/utils/translate.js +12 -0
  21. package/lib/cjs/version.js +1 -1
  22. package/lib/mjs/components/CioPia/CioPiaQna.js +8 -3
  23. package/lib/mjs/components/CioPia/CioPiaStyles.css +5 -0
  24. package/lib/mjs/components/CioPia/PiaCustomCarousel.js +11 -1
  25. package/lib/mjs/components/ConversationHistory/ConversationHistory.js +10 -5
  26. package/lib/mjs/components/Error/ErrorBlock.js +7 -5
  27. package/lib/mjs/components/Feedback/Feedback.js +4 -4
  28. package/lib/mjs/components/Input/Input.js +2 -1
  29. package/lib/mjs/components/LoadingSkeleton/LoadingSkeleton.js +2 -1
  30. package/lib/mjs/components/PiaConversation/PiaModal.js +22 -4
  31. package/lib/mjs/components/StatusRegion/StatusRegion.js +28 -0
  32. package/lib/mjs/components/SuggestedQuestionsContainer/SuggestedQuestionsSkeleton.js +1 -1
  33. package/lib/mjs/components/icons/QuestionIcon.js +1 -1
  34. package/lib/mjs/components/icons/SendIcon.js +1 -1
  35. package/lib/mjs/components/icons/SparklesIcon.js +1 -1
  36. package/lib/mjs/hooks/useAnswerResults.js +13 -4
  37. package/lib/mjs/hooks/useConversation.js +21 -7
  38. package/lib/mjs/hooks/useRecsPod.js +15 -7
  39. package/lib/mjs/hooks/useSuggestedQuestions.js +13 -4
  40. package/lib/mjs/utils/translate.js +12 -0
  41. package/lib/mjs/version.js +1 -1
  42. package/lib/types/components/ConversationHistory/ConversationHistory.d.ts +7 -1
  43. package/lib/types/components/Error/ErrorBlock.d.ts +9 -1
  44. package/lib/types/components/StatusRegion/StatusRegion.d.ts +13 -0
  45. package/lib/types/types.d.ts +10 -0
  46. package/lib/types/utils/contentTransformers.d.ts +2 -2
  47. package/lib/types/utils/translate.d.ts +3 -0
  48. package/lib/types/version.d.ts +1 -1
  49. package/package.json +7 -6
@@ -1,7 +1,15 @@
1
1
  import React from 'react';
2
+ import { Translations } from '../../types';
2
3
  interface ErrorBlockProps {
3
4
  message: string;
4
5
  onRetry?: () => void;
6
+ translations?: Translations;
7
+ /**
8
+ * Whether the message is a `role='alert'` live region. Turn off when the block is rendered
9
+ * inside another live region (such as the conversation `role='log'`), which already announces
10
+ * inserted text: nesting the two would announce the error twice. Defaults to true.
11
+ */
12
+ announce?: boolean;
5
13
  }
6
- declare function ErrorBlock({ message, onRetry }: ErrorBlockProps): React.JSX.Element;
14
+ declare function ErrorBlock({ message, onRetry, translations, announce, }: ErrorBlockProps): React.JSX.Element;
7
15
  export default ErrorBlock;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { Translations } from '../../types';
3
+ interface StatusRegionProps {
4
+ message: string;
5
+ 'data-testid'?: string;
6
+ }
7
+ /**
8
+ * Visually hidden `role='status'`. Keep it mounted and change only `message`:
9
+ * a live region created together with its text is announced inconsistently.
10
+ */
11
+ export default function StatusRegion({ message, 'data-testid': testId }: StatusRegionProps): React.JSX.Element;
12
+ export declare function answerStatusMessage(isLoading: boolean, hasAnswer: boolean, translations?: Translations): string;
13
+ export {};
@@ -60,12 +60,22 @@ export type CioPiaDisplayConfigs = {
60
60
  export type Translations = {
61
61
  'Any questions about this product?'?: string;
62
62
  'Ask anything'?: string;
63
+ /** Accessible name of the question field when its placeholder is blanked out. */
64
+ 'Your question'?: string;
63
65
  Send?: string;
64
66
  'AI-generated answers aim to help, but they may occasionally miss details or be inaccurate. Double-check important information before purchasing.'?: string;
65
67
  'Is this answer useful?'?: string;
66
68
  'Learn More.'?: string;
67
69
  'Ask about this product'?: string;
68
70
  'Add to Cart'?: string;
71
+ 'Unexpected error'?: string;
72
+ 'thumbs up'?: string;
73
+ 'thumbs down'?: string;
74
+ Close?: string;
75
+ Retry?: string;
76
+ 'Conversation history'?: string;
77
+ 'Loading answer'?: string;
78
+ 'Answer ready'?: string;
69
79
  /** Recommendations pod title shown while a request is in flight. */
70
80
  'Adapting recommendations to your preference'?: string;
71
81
  /** Recommendations pod title shown when a request fails or comes back degraded. */
@@ -1,6 +1,6 @@
1
- import DOMPurify from 'dompurify';
1
+ import DOMPurify, { type Config } from 'dompurify';
2
2
  export interface SanitizeOptions {
3
- config: DOMPurify.Config;
3
+ config: Config;
4
4
  }
5
5
  /** Options for {@link renderMarkdown}. */
6
6
  export interface RenderMarkdownOptions {
@@ -3,6 +3,9 @@ import { Translations } from '../types';
3
3
  * Translates a word using the provided translations object.
4
4
  * Falls back to English defaults if translation is not provided.
5
5
  *
6
+ * An explicitly empty string is returned as-is: blanking out a string is how
7
+ * consumers hide it.
8
+ *
6
9
  * @param word - The key to translate
7
10
  * @param translations - Optional user-provided translations object
8
11
  * @returns The translated string or the original word if no translation exists
@@ -1,2 +1,2 @@
1
- declare const _default: "2.12.0";
1
+ declare const _default: "2.13.1";
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-ui-pia",
3
- "version": "2.12.0",
3
+ "version": "2.13.1",
4
4
  "description": "Constructor.io AI Product Insights Agent UI library for web applications",
5
5
  "author": "Constructor.io Corporation",
6
6
  "license": "MIT",
@@ -77,7 +77,6 @@
77
77
  "tslib": "^2.4.0"
78
78
  },
79
79
  "devDependencies": {
80
- "@axe-core/react": "^4.10.1",
81
80
  "@babel/core": "^7.24.0",
82
81
  "@babel/preset-env": "^7.24.0",
83
82
  "@babel/preset-react": "^7.23.3",
@@ -100,10 +99,10 @@
100
99
  "@storybook/testing-library": "^0.2.1",
101
100
  "@testing-library/jest-dom": "^6.6.3",
102
101
  "@testing-library/react": "^16.2.0",
103
- "@types/dompurify": "^3.0.5",
104
102
  "@types/jest": "^30.0.0",
105
103
  "@types/react": "^19.0.10",
106
104
  "@types/react-dom": "^19.0.4",
105
+ "axe-playwright": "^2.2.2",
107
106
  "chromatic": "^11.27.0",
108
107
  "eslint": "^9.39.4",
109
108
  "eslint-config-prettier": "^10.1.1",
@@ -127,17 +126,19 @@
127
126
  "typescript-eslint": "^8.59.2",
128
127
  "vite": "^6.4.3",
129
128
  "vite-plugin-css-injected-by-js": "^3.5.2",
130
- "webpack": "^5.98.0"
129
+ "webpack": "^5.104.1"
131
130
  },
132
131
  "volta": {
133
132
  "node": "22.18.0",
134
133
  "npm": "10.9.3"
135
134
  },
136
135
  "dependencies": {
137
- "dompurify": "^3.4.2",
136
+ "dompurify": "^3.4.15",
138
137
  "marked": "^15.0.12"
139
138
  },
140
139
  "overrides": {
141
- "uuid": "^11.1.1"
140
+ "uuid": "^11.1.1",
141
+ "browserslist": "^4.28.9",
142
+ "postcss-selector-parser": "^7.1.6"
142
143
  }
143
144
  }