@automattic/jetpack-ai-client 0.1.4 → 0.1.5
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 +11 -0
- package/package.json +4 -4
- package/src/components/ai-control/Readme.md +3 -2
- package/src/components/ai-control/index.tsx +28 -25
- package/src/components/ai-control/stories/index.stories.tsx +2 -2
- package/src/components/ai-control/style.scss +2 -1
- package/src/icons/index.ts +1 -0
- package/src/icons/mic.tsx +19 -0
- package/src/types.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,16 @@ 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.1.5] - 2023-08-28
|
|
9
|
+
### Added
|
|
10
|
+
- AI Client: add mic icon [#32665]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- AI Assistant: Change messages to turn content optional and start supporting a context property. [#32495]
|
|
14
|
+
- AI Extension: Add showClearButton prop to AIControl component and fix names [#32682]
|
|
15
|
+
- AI Extension: Specify input background color [#32628]
|
|
16
|
+
- Updated package dependencies. [#32605]
|
|
17
|
+
|
|
8
18
|
## [0.1.4] - 2023-08-14
|
|
9
19
|
### Added
|
|
10
20
|
- AI Client: Add border-box in AIControl. [#32419]
|
|
@@ -82,6 +92,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
82
92
|
- Updated package dependencies. [#31659]
|
|
83
93
|
- Updated package dependencies. [#31785]
|
|
84
94
|
|
|
95
|
+
[0.1.5]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.4...v0.1.5
|
|
85
96
|
[0.1.4]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.3...v0.1.4
|
|
86
97
|
[0.1.3]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.2...v0.1.3
|
|
87
98
|
[0.1.2]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.1...v0.1.2
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@automattic/jetpack-ai-client",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.5",
|
|
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": {
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
".": "./index.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@automattic/jetpack-base-styles": "^0.6.
|
|
36
|
-
"@automattic/jetpack-connection": "
|
|
37
|
-
"@automattic/jetpack-shared-extension-utils": "^0.11.
|
|
35
|
+
"@automattic/jetpack-base-styles": "^0.6.6",
|
|
36
|
+
"@automattic/jetpack-connection": "^0.29.8",
|
|
37
|
+
"@automattic/jetpack-shared-extension-utils": "^0.11.3",
|
|
38
38
|
"@microsoft/fetch-event-source": "2.0.1",
|
|
39
39
|
"@wordpress/api-fetch": "6.35.0",
|
|
40
40
|
"@wordpress/block-editor": "12.6.0",
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
- `placeholder` (**string**) (Optional): Placeholder text for the input field. Default value is `''`.
|
|
8
8
|
- `showAccept` (**boolean**) (Optional): Determines if the accept button is shown. Default value is `false`.
|
|
9
9
|
- `acceptLabel` (**string**) (Optional): Label text for the accept button. Default value is `'Accept'`.
|
|
10
|
-
- `
|
|
11
|
-
- `
|
|
10
|
+
- `showButtonLabels` (**boolean**) (Optional): Determines if button labels are shown. Default value is `true`.
|
|
11
|
+
- `isTransparent` (**boolean**) (Optional): Controls the opacity of the component. Default value is `false`.
|
|
12
12
|
- `state` (**RequestingStateProp**) (Optional): Determines the state of the component. Default value is `'init'`.
|
|
13
|
+
- `showClearButton` (**boolean**) (Optional): Determines if the clear button is shown when the input has a value. Default value is `true`.
|
|
13
14
|
- `onChange` (**Function**) (Optional): Handler for input change. Default action is no operation.
|
|
14
15
|
- `onSend` (**Function**) (Optional): Handler to send a request. Default action is no operation.
|
|
15
16
|
- `onStop` (**Function**) (Optional): Handler to stop a request. Default action is no operation.
|
|
@@ -26,20 +26,21 @@ const noop = () => {};
|
|
|
26
26
|
/**
|
|
27
27
|
* AI Control component.
|
|
28
28
|
*
|
|
29
|
-
* @param {object} props
|
|
30
|
-
* @param {boolean} props.disabled
|
|
31
|
-
* @param {string} props.value
|
|
32
|
-
* @param {string} props.placeholder
|
|
33
|
-
* @param {boolean} props.showAccept
|
|
34
|
-
* @param {string} props.acceptLabel
|
|
35
|
-
* @param {boolean} props.
|
|
36
|
-
* @param {boolean} props.
|
|
37
|
-
* @param {string} props.state
|
|
38
|
-
* @param {
|
|
39
|
-
* @param {Function} props.
|
|
40
|
-
* @param {Function} props.
|
|
41
|
-
* @param {Function} props.
|
|
42
|
-
* @param {
|
|
29
|
+
* @param {object} props - Component props
|
|
30
|
+
* @param {boolean} props.disabled - Input disabled state
|
|
31
|
+
* @param {string} props.value - The input value
|
|
32
|
+
* @param {string} props.placeholder - The input placeholder
|
|
33
|
+
* @param {boolean} props.showAccept - Whether to show the accept button
|
|
34
|
+
* @param {string} props.acceptLabel - The accept button label
|
|
35
|
+
* @param {boolean} props.showButtonLabels - Whether to show the button labels
|
|
36
|
+
* @param {boolean} props.isTransparent - Whether the component has low opacity
|
|
37
|
+
* @param {string} props.state - The request state
|
|
38
|
+
* @param {boolean} props.showClearButton - Whether to show the clear button when the input has a value
|
|
39
|
+
* @param {Function} props.onChange - Input change handler
|
|
40
|
+
* @param {Function} props.onSend - Request send handler
|
|
41
|
+
* @param {Function} props.onStop - Request stop handler
|
|
42
|
+
* @param {Function} props.onAccept - Response accept handler
|
|
43
|
+
* @param {object} ref - Auto injected ref from react
|
|
43
44
|
* @returns {object} - AI Control component
|
|
44
45
|
*/
|
|
45
46
|
export function AIControl(
|
|
@@ -49,9 +50,10 @@ export function AIControl(
|
|
|
49
50
|
placeholder = '',
|
|
50
51
|
showAccept = false,
|
|
51
52
|
acceptLabel = __( 'Accept', 'jetpack-ai-client' ),
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
showButtonLabels = true,
|
|
54
|
+
isTransparent = false,
|
|
54
55
|
state = 'init',
|
|
56
|
+
showClearButton = true,
|
|
55
57
|
onChange = noop,
|
|
56
58
|
onSend = noop,
|
|
57
59
|
onStop = noop,
|
|
@@ -62,9 +64,10 @@ export function AIControl(
|
|
|
62
64
|
placeholder?: string;
|
|
63
65
|
showAccept?: boolean;
|
|
64
66
|
acceptLabel?: string;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
showButtonLabels?: boolean;
|
|
68
|
+
isTransparent?: boolean;
|
|
67
69
|
state?: RequestingStateProp;
|
|
70
|
+
showClearButton?: boolean;
|
|
68
71
|
onChange?: ( newValue: string ) => void;
|
|
69
72
|
onSend?: ( currentValue: string ) => void;
|
|
70
73
|
onStop?: () => void;
|
|
@@ -74,7 +77,7 @@ export function AIControl(
|
|
|
74
77
|
) {
|
|
75
78
|
const promptUserInputRef = useRef( null );
|
|
76
79
|
const loading = state === 'requesting' || state === 'suggesting';
|
|
77
|
-
const showGuideLine = ! ( loading || disabled || value?.length ||
|
|
80
|
+
const showGuideLine = ! ( loading || disabled || value?.length || isTransparent );
|
|
78
81
|
|
|
79
82
|
// Pass the ref to forwardRef.
|
|
80
83
|
useImperativeHandle( ref, () => promptUserInputRef.current );
|
|
@@ -103,14 +106,14 @@ export function AIControl(
|
|
|
103
106
|
);
|
|
104
107
|
|
|
105
108
|
const actionButtonClasses = classNames( 'jetpack-components-ai-control__controls-prompt_button', {
|
|
106
|
-
'has-label':
|
|
109
|
+
'has-label': showButtonLabels,
|
|
107
110
|
} );
|
|
108
111
|
|
|
109
112
|
return (
|
|
110
113
|
<div className="jetpack-components-ai-control__container">
|
|
111
114
|
<div
|
|
112
115
|
className={ classNames( 'jetpack-components-ai-control__wrapper', {
|
|
113
|
-
'is-
|
|
116
|
+
'is-transparent': isTransparent,
|
|
114
117
|
} ) }
|
|
115
118
|
>
|
|
116
119
|
<AiStatusIndicator state={ state } />
|
|
@@ -126,7 +129,7 @@ export function AIControl(
|
|
|
126
129
|
/>
|
|
127
130
|
</div>
|
|
128
131
|
|
|
129
|
-
{ value?.length > 0 && (
|
|
132
|
+
{ value?.length > 0 && showClearButton && (
|
|
130
133
|
<Button
|
|
131
134
|
icon={ closeSmall }
|
|
132
135
|
className="jetpack-components-ai-control__clear"
|
|
@@ -144,7 +147,7 @@ export function AIControl(
|
|
|
144
147
|
label={ __( 'Send request', 'jetpack-ai-client' ) }
|
|
145
148
|
>
|
|
146
149
|
<Icon icon={ arrowUp } />
|
|
147
|
-
{
|
|
150
|
+
{ showButtonLabels && __( 'Send', 'jetpack-ai-client' ) }
|
|
148
151
|
</Button>
|
|
149
152
|
) : (
|
|
150
153
|
<Button
|
|
@@ -154,7 +157,7 @@ export function AIControl(
|
|
|
154
157
|
label={ __( 'Stop request', 'jetpack-ai-client' ) }
|
|
155
158
|
>
|
|
156
159
|
<Icon icon={ closeSmall } />
|
|
157
|
-
{
|
|
160
|
+
{ showButtonLabels && __( 'Stop', 'jetpack-ai-client' ) }
|
|
158
161
|
</Button>
|
|
159
162
|
) }
|
|
160
163
|
</div>
|
|
@@ -168,7 +171,7 @@ export function AIControl(
|
|
|
168
171
|
label={ acceptLabel }
|
|
169
172
|
>
|
|
170
173
|
<Icon icon={ check } />
|
|
171
|
-
{
|
|
174
|
+
{ showButtonLabels && acceptLabel }
|
|
172
175
|
</Button>
|
|
173
176
|
</div>
|
|
174
177
|
) }
|
|
@@ -52,10 +52,10 @@ const Template = args => {
|
|
|
52
52
|
|
|
53
53
|
const DefaultArgs = {
|
|
54
54
|
loading: false,
|
|
55
|
-
|
|
55
|
+
isTransparent: false,
|
|
56
56
|
placeholder: '',
|
|
57
57
|
requestingState: 'init',
|
|
58
|
-
|
|
58
|
+
showButtonLabels: true,
|
|
59
59
|
showAccept: false,
|
|
60
60
|
acceptLabel: 'Accept',
|
|
61
61
|
onChange: action( 'onChange' ),
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
align-items: center;
|
|
18
18
|
box-sizing: border-box;
|
|
19
19
|
|
|
20
|
-
&.is-
|
|
20
|
+
&.is-transparent {
|
|
21
21
|
opacity: 0.4;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
width: 100%;
|
|
30
30
|
|
|
31
31
|
textarea.jetpack-components-ai-control__input {
|
|
32
|
+
background-color: var( --jp-white );
|
|
32
33
|
width: 100%;
|
|
33
34
|
min-height: 20px;
|
|
34
35
|
border-radius: 2px;
|
package/src/icons/index.ts
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { SVG, Rect, Line, Path } from '@wordpress/components';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
const mic = (
|
|
8
|
+
<SVG width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/SVG">
|
|
9
|
+
<Rect x="8.75" y="2.75" width="6.5" height="11.5" rx="3.25" stroke="black" stroke-width="1.5" />
|
|
10
|
+
<Line x1="12" y1="17" x2="12" y2="21" stroke="black" stroke-width="1.5" />
|
|
11
|
+
<Path
|
|
12
|
+
d="M18 11C18 11.7879 17.8448 12.5681 17.5433 13.2961C17.2417 14.0241 16.7998 14.6855 16.2426 15.2426C15.6855 15.7998 15.0241 16.2418 14.2961 16.5433C13.5681 16.8448 12.7879 17 12 17C11.2121 17 10.4319 16.8448 9.7039 16.5433C8.97595 16.2417 8.31451 15.7998 7.75736 15.2426C7.20021 14.6855 6.75825 14.0241 6.45672 13.2961C6.15519 12.5681 6 11.7879 6 11"
|
|
13
|
+
stroke="black"
|
|
14
|
+
stroke-width="1.5"
|
|
15
|
+
/>
|
|
16
|
+
</SVG>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export default mic;
|
package/src/types.ts
CHANGED