@automattic/jetpack-ai-client 0.5.0 → 0.6.0
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.
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.6.0] - 2024-02-05
|
|
9
|
+
### Added
|
|
10
|
+
- Jetpack AI: Support floating error messaging on the AI Control component. [#35322]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- Updated package dependencies. [#35384]
|
|
14
|
+
|
|
15
|
+
## [0.5.1] - 2024-01-29
|
|
16
|
+
### Changed
|
|
17
|
+
- Update dependencies. [#35170]
|
|
18
|
+
|
|
8
19
|
## [0.5.0] - 2024-01-25
|
|
9
20
|
### Changed
|
|
10
21
|
- AI Control: Do not call onAccept from the discard handler. A fix has been put in place on #35236. [#35238]
|
|
@@ -195,6 +206,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
195
206
|
- Updated package dependencies. [#31659]
|
|
196
207
|
- Updated package dependencies. [#31785]
|
|
197
208
|
|
|
209
|
+
[0.6.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.5.1...v0.6.0
|
|
210
|
+
[0.5.1]: https://github.com/Automattic/jetpack-ai-client/compare/v0.5.0...v0.5.1
|
|
198
211
|
[0.5.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.4.1...v0.5.0
|
|
199
212
|
[0.4.1]: https://github.com/Automattic/jetpack-ai-client/compare/v0.4.0...v0.4.1
|
|
200
213
|
[0.4.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.3.1...v0.4.0
|
|
@@ -25,6 +25,7 @@ type AiControlProps = {
|
|
|
25
25
|
onDiscard?: () => void;
|
|
26
26
|
showRemove?: boolean;
|
|
27
27
|
bannerComponent?: React.ReactElement;
|
|
28
|
+
errorComponent?: React.ReactElement;
|
|
28
29
|
};
|
|
29
30
|
/**
|
|
30
31
|
* AI Control component.
|
|
@@ -33,6 +34,6 @@ type AiControlProps = {
|
|
|
33
34
|
* @param {React.MutableRefObject} ref - Ref to the component.
|
|
34
35
|
* @returns {React.ReactElement} Rendered component.
|
|
35
36
|
*/
|
|
36
|
-
export declare function AIControl({ disabled, value, placeholder, showAccept, acceptLabel, showButtonLabels, isTransparent, state, showGuideLine, customFooter, onChange, onSend, onStop, onAccept, onDiscard, showRemove, bannerComponent, }: AiControlProps, ref: React.MutableRefObject<null>): React.ReactElement;
|
|
37
|
+
export declare function AIControl({ disabled, value, placeholder, showAccept, acceptLabel, showButtonLabels, isTransparent, state, showGuideLine, customFooter, onChange, onSend, onStop, onAccept, onDiscard, showRemove, bannerComponent, errorComponent, }: AiControlProps, ref: React.MutableRefObject<null>): React.ReactElement;
|
|
37
38
|
declare const _default: React.ForwardRefExoticComponent<AiControlProps & React.RefAttributes<null>>;
|
|
38
39
|
export default _default;
|
|
@@ -25,7 +25,7 @@ const noop = () => { };
|
|
|
25
25
|
* @param {React.MutableRefObject} ref - Ref to the component.
|
|
26
26
|
* @returns {React.ReactElement} Rendered component.
|
|
27
27
|
*/
|
|
28
|
-
export function AIControl({ disabled = false, value = '', placeholder = '', showAccept = false, acceptLabel = __('Accept', 'jetpack-ai-client'), showButtonLabels = true, isTransparent = false, state = 'init', showGuideLine = false, customFooter = null, onChange = noop, onSend = noop, onStop = noop, onAccept = noop, onDiscard = null, showRemove = false, bannerComponent = null, }, ref // eslint-disable-line @typescript-eslint/ban-types
|
|
28
|
+
export function AIControl({ disabled = false, value = '', placeholder = '', showAccept = false, acceptLabel = __('Accept', 'jetpack-ai-client'), showButtonLabels = true, isTransparent = false, state = 'init', showGuideLine = false, customFooter = null, onChange = noop, onSend = noop, onStop = noop, onAccept = noop, onDiscard = null, showRemove = false, bannerComponent = null, errorComponent = null, }, ref // eslint-disable-line @typescript-eslint/ban-types
|
|
29
29
|
) {
|
|
30
30
|
const promptUserInputRef = useRef(null);
|
|
31
31
|
const loading = state === 'requesting' || state === 'suggesting';
|
|
@@ -80,8 +80,8 @@ export function AIControl({ disabled = false, value = '', placeholder = '', show
|
|
|
80
80
|
}, {
|
|
81
81
|
target: promptUserInputRef,
|
|
82
82
|
});
|
|
83
|
-
return (
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
return (_jsxs("div", { className: "jetpack-components-ai-control__container-wrapper", children: [errorComponent, _jsxs("div", { className: "jetpack-components-ai-control__container", children: [bannerComponent, _jsxs("div", { className: classNames('jetpack-components-ai-control__wrapper', {
|
|
84
|
+
'is-transparent': isTransparent,
|
|
85
|
+
}), children: [_jsx(AiStatusIndicator, { state: state }), _jsx("div", { className: "jetpack-components-ai-control__input-wrapper", children: _jsx(PlainText, { value: value, onChange: changeHandler, placeholder: placeholder, className: "jetpack-components-ai-control__input", disabled: loading || disabled, ref: promptUserInputRef }) }), (!showAccept || editRequest) && (_jsx("div", { className: "jetpack-components-ai-control__controls-prompt_button_wrapper", children: !loading ? (_jsxs(_Fragment, { children: [editRequest && (_jsx(Button, { className: "jetpack-components-ai-control__controls-prompt_button", onClick: cancelEdit, variant: "secondary", label: __('Cancel', 'jetpack-ai-client'), children: showButtonLabels ? (__('Cancel', 'jetpack-ai-client')) : (_jsx(Icon, { icon: closeSmall })) })), showRemove && !editRequest && !value?.length && onDiscard && (_jsx(Button, { className: "jetpack-components-ai-control__controls-prompt_button", onClick: discardHandler, variant: "secondary", label: __('Cancel', 'jetpack-ai-client'), children: showButtonLabels ? (__('Cancel', 'jetpack-ai-client')) : (_jsx(Icon, { icon: closeSmall })) })), value?.length > 0 && (_jsx(Button, { className: "jetpack-components-ai-control__controls-prompt_button", onClick: sendRequest, variant: "primary", disabled: !value?.length || disabled, label: __('Send request', 'jetpack-ai-client'), children: showButtonLabels ? (__('Generate', 'jetpack-ai-client')) : (_jsx(Icon, { icon: arrowUp })) }))] })) : (_jsx(Button, { className: "jetpack-components-ai-control__controls-prompt_button", onClick: onStop, variant: "secondary", label: __('Stop request', 'jetpack-ai-client'), children: showButtonLabels ? (__('Stop', 'jetpack-ai-client')) : (_jsx(Icon, { icon: closeSmall })) })) })), showAccept && !editRequest && (_jsxs("div", { className: "jetpack-components-ai-control__controls-prompt_button_wrapper", children: [(value?.length > 0 || lastValue === null) && (_jsxs(ButtonGroup, { children: [_jsx(Button, { className: "jetpack-components-ai-control__controls-prompt_button", label: __('Discard', 'jetpack-ai-client'), onClick: discardHandler, tooltipPosition: "top", children: _jsx(Icon, { icon: trash }) }), _jsx(Button, { className: "jetpack-components-ai-control__controls-prompt_button", label: __('Regenerate', 'jetpack-ai-client'), onClick: () => onSend?.(value), tooltipPosition: "top", disabled: !value?.length || value === null || disabled, children: _jsx(Icon, { icon: reusableBlock }) })] })), _jsx(Button, { className: "jetpack-components-ai-control__controls-prompt_button", onClick: onAccept, variant: "primary", label: acceptLabel, children: showButtonLabels ? acceptLabel : _jsx(Icon, { icon: check }) })] }))] }), showGuideLine && !loading && !editRequest && (customFooter || _jsx(GuidelineMessage, {}))] })] }));
|
|
86
86
|
}
|
|
87
87
|
export default forwardRef(AIControl);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@automattic/jetpack-ai-client",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"description": "A JS client for consuming Jetpack AI services",
|
|
6
6
|
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/ai-client/#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -38,19 +38,19 @@
|
|
|
38
38
|
"main": "./build/index.js",
|
|
39
39
|
"types": "./build/index.d.ts",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@automattic/jetpack-base-styles": "^0.6.
|
|
42
|
-
"@automattic/jetpack-connection": "^0.
|
|
43
|
-
"@automattic/jetpack-shared-extension-utils": "^0.
|
|
41
|
+
"@automattic/jetpack-base-styles": "^0.6.16",
|
|
42
|
+
"@automattic/jetpack-connection": "^0.32.0",
|
|
43
|
+
"@automattic/jetpack-shared-extension-utils": "^0.14.1",
|
|
44
44
|
"@microsoft/fetch-event-source": "2.0.1",
|
|
45
45
|
"@types/react": "18.2.33",
|
|
46
|
-
"@wordpress/api-fetch": "6.
|
|
47
|
-
"@wordpress/block-editor": "12.
|
|
48
|
-
"@wordpress/components": "25.
|
|
49
|
-
"@wordpress/compose": "6.
|
|
50
|
-
"@wordpress/data": "9.
|
|
51
|
-
"@wordpress/element": "5.
|
|
52
|
-
"@wordpress/i18n": "4.
|
|
53
|
-
"@wordpress/icons": "9.
|
|
46
|
+
"@wordpress/api-fetch": "6.47.0",
|
|
47
|
+
"@wordpress/block-editor": "12.18.2",
|
|
48
|
+
"@wordpress/components": "25.16.0",
|
|
49
|
+
"@wordpress/compose": "6.27.0",
|
|
50
|
+
"@wordpress/data": "9.20.0",
|
|
51
|
+
"@wordpress/element": "5.27.0",
|
|
52
|
+
"@wordpress/i18n": "4.50.0",
|
|
53
|
+
"@wordpress/icons": "9.41.0",
|
|
54
54
|
"classnames": "2.3.2",
|
|
55
55
|
"debug": "4.3.4",
|
|
56
56
|
"react": "18.2.0",
|
|
@@ -43,6 +43,7 @@ type AiControlProps = {
|
|
|
43
43
|
onDiscard?: () => void;
|
|
44
44
|
showRemove?: boolean;
|
|
45
45
|
bannerComponent?: React.ReactElement;
|
|
46
|
+
errorComponent?: React.ReactElement;
|
|
46
47
|
};
|
|
47
48
|
|
|
48
49
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
@@ -74,6 +75,7 @@ export function AIControl(
|
|
|
74
75
|
onDiscard = null,
|
|
75
76
|
showRemove = false,
|
|
76
77
|
bannerComponent = null,
|
|
78
|
+
errorComponent = null,
|
|
77
79
|
}: AiControlProps,
|
|
78
80
|
ref: React.MutableRefObject< null > // eslint-disable-line @typescript-eslint/ban-types
|
|
79
81
|
): React.ReactElement {
|
|
@@ -153,6 +155,7 @@ export function AIControl(
|
|
|
153
155
|
|
|
154
156
|
return (
|
|
155
157
|
<div className="jetpack-components-ai-control__container-wrapper">
|
|
158
|
+
{ errorComponent }
|
|
156
159
|
<div className="jetpack-components-ai-control__container">
|
|
157
160
|
{ bannerComponent }
|
|
158
161
|
<div
|