@automattic/jetpack-ai-client 0.1.3 → 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 +26 -0
- package/index.ts +1 -1
- package/package.json +4 -3
- package/src/components/ai-control/Readme.md +3 -2
- package/src/components/ai-control/index.tsx +61 -48
- package/src/components/ai-control/stories/index.stories.tsx +2 -2
- package/src/components/ai-control/style.scss +5 -1
- package/src/components/ai-status-indicator/style.scss +2 -0
- package/src/components/index.ts +2 -0
- package/src/data-flow/context.tsx +5 -0
- package/src/data-flow/with-ai-assistant-data.tsx +10 -1
- package/src/hooks/use-ai-suggestions/index.ts +50 -40
- 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,30 @@ 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
|
+
|
|
18
|
+
## [0.1.4] - 2023-08-14
|
|
19
|
+
### Added
|
|
20
|
+
- AI Client: Add border-box in AIControl. [#32419]
|
|
21
|
+
- AI Client: Export AiStatusIndicator. [#32397]
|
|
22
|
+
- AI Client: Import base styles in the AI status indicator component. [#32396]
|
|
23
|
+
- AI Control: Forward ref to consumer. [#32400]
|
|
24
|
+
- AI Control: Import jetpack-base-styles. [#32376]
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
- AI Client: Expose stopSuggestion function on useAiSuggestions hook so the consumer can stop a suggestion in the middle. [#32382]
|
|
28
|
+
|
|
29
|
+
### Removed
|
|
30
|
+
- AI Client: Remove redundant switch case [#32405]
|
|
31
|
+
|
|
8
32
|
## [0.1.3] - 2023-08-09
|
|
9
33
|
### Added
|
|
10
34
|
- AI Client: Introduce disabled prop in AI Control. [#32326]
|
|
@@ -68,6 +92,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
68
92
|
- Updated package dependencies. [#31659]
|
|
69
93
|
- Updated package dependencies. [#31785]
|
|
70
94
|
|
|
95
|
+
[0.1.5]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.4...v0.1.5
|
|
96
|
+
[0.1.4]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.3...v0.1.4
|
|
71
97
|
[0.1.3]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.2...v0.1.3
|
|
72
98
|
[0.1.2]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.1...v0.1.2
|
|
73
99
|
[0.1.1]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.0...v0.1.1
|
package/index.ts
CHANGED
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,8 +32,9 @@
|
|
|
32
32
|
".": "./index.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@automattic/jetpack-
|
|
36
|
-
"@automattic/jetpack-
|
|
35
|
+
"@automattic/jetpack-base-styles": "^0.6.6",
|
|
36
|
+
"@automattic/jetpack-connection": "^0.29.8",
|
|
37
|
+
"@automattic/jetpack-shared-extension-utils": "^0.11.3",
|
|
37
38
|
"@microsoft/fetch-event-source": "2.0.1",
|
|
38
39
|
"@wordpress/api-fetch": "6.35.0",
|
|
39
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.
|
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
import { PlainText } from '@wordpress/block-editor';
|
|
5
5
|
import { Button } from '@wordpress/components';
|
|
6
6
|
import { useKeyboardShortcut } from '@wordpress/compose';
|
|
7
|
-
import { useRef } from '@wordpress/element';
|
|
7
|
+
import { forwardRef, useImperativeHandle, useRef } from '@wordpress/element';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
9
|
import { Icon, closeSmall, check, arrowUp } from '@wordpress/icons';
|
|
10
10
|
import classNames from 'classnames';
|
|
11
|
+
import React from 'react';
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
13
14
|
*/
|
|
@@ -25,51 +26,61 @@ const noop = () => {};
|
|
|
25
26
|
/**
|
|
26
27
|
* AI Control component.
|
|
27
28
|
*
|
|
28
|
-
* @param {object} props
|
|
29
|
-
* @param {boolean} props.disabled
|
|
30
|
-
* @param {string} props.value
|
|
31
|
-
* @param {string} props.placeholder
|
|
32
|
-
* @param {boolean} props.showAccept
|
|
33
|
-
* @param {string} props.acceptLabel
|
|
34
|
-
* @param {boolean} props.
|
|
35
|
-
* @param {boolean} props.
|
|
36
|
-
* @param {string} props.state
|
|
37
|
-
* @param {
|
|
38
|
-
* @param {Function} props.
|
|
39
|
-
* @param {Function} props.
|
|
40
|
-
* @param {Function} props.
|
|
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
|
|
41
44
|
* @returns {object} - AI Control component
|
|
42
45
|
*/
|
|
43
|
-
export
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
46
|
+
export function AIControl(
|
|
47
|
+
{
|
|
48
|
+
disabled = false,
|
|
49
|
+
value = '',
|
|
50
|
+
placeholder = '',
|
|
51
|
+
showAccept = false,
|
|
52
|
+
acceptLabel = __( 'Accept', 'jetpack-ai-client' ),
|
|
53
|
+
showButtonLabels = true,
|
|
54
|
+
isTransparent = false,
|
|
55
|
+
state = 'init',
|
|
56
|
+
showClearButton = true,
|
|
57
|
+
onChange = noop,
|
|
58
|
+
onSend = noop,
|
|
59
|
+
onStop = noop,
|
|
60
|
+
onAccept = noop,
|
|
61
|
+
}: {
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
value: string;
|
|
64
|
+
placeholder?: string;
|
|
65
|
+
showAccept?: boolean;
|
|
66
|
+
acceptLabel?: string;
|
|
67
|
+
showButtonLabels?: boolean;
|
|
68
|
+
isTransparent?: boolean;
|
|
69
|
+
state?: RequestingStateProp;
|
|
70
|
+
showClearButton?: boolean;
|
|
71
|
+
onChange?: ( newValue: string ) => void;
|
|
72
|
+
onSend?: ( currentValue: string ) => void;
|
|
73
|
+
onStop?: () => void;
|
|
74
|
+
onAccept?: () => void;
|
|
75
|
+
},
|
|
76
|
+
ref
|
|
77
|
+
) {
|
|
70
78
|
const promptUserInputRef = useRef( null );
|
|
71
79
|
const loading = state === 'requesting' || state === 'suggesting';
|
|
72
|
-
const showGuideLine = ! ( loading || disabled || value?.length ||
|
|
80
|
+
const showGuideLine = ! ( loading || disabled || value?.length || isTransparent );
|
|
81
|
+
|
|
82
|
+
// Pass the ref to forwardRef.
|
|
83
|
+
useImperativeHandle( ref, () => promptUserInputRef.current );
|
|
73
84
|
|
|
74
85
|
useKeyboardShortcut(
|
|
75
86
|
'mod+enter',
|
|
@@ -95,14 +106,14 @@ export default function AIControl( {
|
|
|
95
106
|
);
|
|
96
107
|
|
|
97
108
|
const actionButtonClasses = classNames( 'jetpack-components-ai-control__controls-prompt_button', {
|
|
98
|
-
'has-label':
|
|
109
|
+
'has-label': showButtonLabels,
|
|
99
110
|
} );
|
|
100
111
|
|
|
101
112
|
return (
|
|
102
113
|
<div className="jetpack-components-ai-control__container">
|
|
103
114
|
<div
|
|
104
115
|
className={ classNames( 'jetpack-components-ai-control__wrapper', {
|
|
105
|
-
'is-
|
|
116
|
+
'is-transparent': isTransparent,
|
|
106
117
|
} ) }
|
|
107
118
|
>
|
|
108
119
|
<AiStatusIndicator state={ state } />
|
|
@@ -118,7 +129,7 @@ export default function AIControl( {
|
|
|
118
129
|
/>
|
|
119
130
|
</div>
|
|
120
131
|
|
|
121
|
-
{ value?.length > 0 && (
|
|
132
|
+
{ value?.length > 0 && showClearButton && (
|
|
122
133
|
<Button
|
|
123
134
|
icon={ closeSmall }
|
|
124
135
|
className="jetpack-components-ai-control__clear"
|
|
@@ -136,7 +147,7 @@ export default function AIControl( {
|
|
|
136
147
|
label={ __( 'Send request', 'jetpack-ai-client' ) }
|
|
137
148
|
>
|
|
138
149
|
<Icon icon={ arrowUp } />
|
|
139
|
-
{
|
|
150
|
+
{ showButtonLabels && __( 'Send', 'jetpack-ai-client' ) }
|
|
140
151
|
</Button>
|
|
141
152
|
) : (
|
|
142
153
|
<Button
|
|
@@ -146,7 +157,7 @@ export default function AIControl( {
|
|
|
146
157
|
label={ __( 'Stop request', 'jetpack-ai-client' ) }
|
|
147
158
|
>
|
|
148
159
|
<Icon icon={ closeSmall } />
|
|
149
|
-
{
|
|
160
|
+
{ showButtonLabels && __( 'Stop', 'jetpack-ai-client' ) }
|
|
150
161
|
</Button>
|
|
151
162
|
) }
|
|
152
163
|
</div>
|
|
@@ -160,7 +171,7 @@ export default function AIControl( {
|
|
|
160
171
|
label={ acceptLabel }
|
|
161
172
|
>
|
|
162
173
|
<Icon icon={ check } />
|
|
163
|
-
{
|
|
174
|
+
{ showButtonLabels && acceptLabel }
|
|
164
175
|
</Button>
|
|
165
176
|
</div>
|
|
166
177
|
) }
|
|
@@ -169,3 +180,5 @@ export default function AIControl( {
|
|
|
169
180
|
</div>
|
|
170
181
|
);
|
|
171
182
|
}
|
|
183
|
+
|
|
184
|
+
export default forwardRef( AIControl );
|
|
@@ -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' ),
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@import '@automattic/jetpack-base-styles/root-variables';
|
|
2
|
+
|
|
1
3
|
// AI CONTROL
|
|
2
4
|
|
|
3
5
|
.jetpack-components-ai-control__container {
|
|
@@ -13,8 +15,9 @@
|
|
|
13
15
|
padding: 12px 14px;
|
|
14
16
|
gap: 8px;
|
|
15
17
|
align-items: center;
|
|
18
|
+
box-sizing: border-box;
|
|
16
19
|
|
|
17
|
-
&.is-
|
|
20
|
+
&.is-transparent {
|
|
18
21
|
opacity: 0.4;
|
|
19
22
|
}
|
|
20
23
|
}
|
|
@@ -26,6 +29,7 @@
|
|
|
26
29
|
width: 100%;
|
|
27
30
|
|
|
28
31
|
textarea.jetpack-components-ai-control__input {
|
|
32
|
+
background-color: var( --jp-white );
|
|
29
33
|
width: 100%;
|
|
30
34
|
min-height: 20px;
|
|
31
35
|
border-radius: 2px;
|
|
@@ -33,6 +33,11 @@ export type AiDataContextProps = {
|
|
|
33
33
|
*/
|
|
34
34
|
requestSuggestion: ( prompt: PromptProp, options?: AskQuestionOptionsArgProps ) => void;
|
|
35
35
|
|
|
36
|
+
/*
|
|
37
|
+
* Stop suggestion function
|
|
38
|
+
*/
|
|
39
|
+
stopSuggestion: () => void;
|
|
40
|
+
|
|
36
41
|
/*
|
|
37
42
|
* The Suggestions Event Source instance
|
|
38
43
|
*/
|
|
@@ -25,6 +25,7 @@ const withAiDataProvider = createHigherOrderComponent( ( WrappedComponent: React
|
|
|
25
25
|
error: requestingError,
|
|
26
26
|
requestingState,
|
|
27
27
|
request: requestSuggestion,
|
|
28
|
+
stopSuggestion,
|
|
28
29
|
eventSource,
|
|
29
30
|
} = useAiSuggestions();
|
|
30
31
|
|
|
@@ -37,8 +38,16 @@ const withAiDataProvider = createHigherOrderComponent( ( WrappedComponent: React
|
|
|
37
38
|
eventSource,
|
|
38
39
|
|
|
39
40
|
requestSuggestion,
|
|
41
|
+
stopSuggestion,
|
|
40
42
|
} ),
|
|
41
|
-
[
|
|
43
|
+
[
|
|
44
|
+
suggestion,
|
|
45
|
+
requestingError,
|
|
46
|
+
requestingState,
|
|
47
|
+
eventSource,
|
|
48
|
+
requestSuggestion,
|
|
49
|
+
stopSuggestion,
|
|
50
|
+
]
|
|
42
51
|
);
|
|
43
52
|
|
|
44
53
|
return (
|
|
@@ -97,6 +97,11 @@ type useAiSuggestionsProps = {
|
|
|
97
97
|
* The request handler.
|
|
98
98
|
*/
|
|
99
99
|
request: ( prompt: PromptProp, options?: AskQuestionOptionsArgProps ) => Promise< void >;
|
|
100
|
+
|
|
101
|
+
/*
|
|
102
|
+
* The handler to stop a suggestion.
|
|
103
|
+
*/
|
|
104
|
+
stopSuggestion: () => void;
|
|
100
105
|
};
|
|
101
106
|
|
|
102
107
|
const debug = debugFactory( 'jetpack-ai-client:use-suggestion' );
|
|
@@ -140,14 +145,6 @@ export function getErrorData( errorCode: SuggestionErrorCode ): RequestingErrorP
|
|
|
140
145
|
severity: 'info',
|
|
141
146
|
};
|
|
142
147
|
case ERROR_NETWORK:
|
|
143
|
-
return {
|
|
144
|
-
code: ERROR_NETWORK,
|
|
145
|
-
message: __(
|
|
146
|
-
'It was not possible to process your request. Mind trying again?',
|
|
147
|
-
'jetpack-ai-client'
|
|
148
|
-
),
|
|
149
|
-
severity: 'info',
|
|
150
|
-
};
|
|
151
148
|
default:
|
|
152
149
|
return {
|
|
153
150
|
code: ERROR_NETWORK,
|
|
@@ -297,6 +294,46 @@ export default function useAiSuggestions( {
|
|
|
297
294
|
]
|
|
298
295
|
);
|
|
299
296
|
|
|
297
|
+
/**
|
|
298
|
+
* Stop suggestion handler.
|
|
299
|
+
*
|
|
300
|
+
* @returns {void}
|
|
301
|
+
*/
|
|
302
|
+
const stopSuggestion = useCallback( () => {
|
|
303
|
+
if ( ! eventSourceRef?.current ) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// Alias
|
|
308
|
+
const eventSource = eventSourceRef?.current;
|
|
309
|
+
|
|
310
|
+
// Close the connection.
|
|
311
|
+
eventSource.close();
|
|
312
|
+
|
|
313
|
+
// Clean up the event listeners.
|
|
314
|
+
eventSource.removeEventListener( 'suggestion', handleSuggestion );
|
|
315
|
+
|
|
316
|
+
eventSource.removeEventListener( ERROR_QUOTA_EXCEEDED, handleErrorQuotaExceededError );
|
|
317
|
+
eventSource.removeEventListener( ERROR_UNCLEAR_PROMPT, handleUnclearPromptError );
|
|
318
|
+
eventSource.removeEventListener( ERROR_SERVICE_UNAVAILABLE, handleServiceUnavailableError );
|
|
319
|
+
eventSource.removeEventListener( ERROR_MODERATION, handleModerationError );
|
|
320
|
+
eventSource.removeEventListener( ERROR_NETWORK, handleNetworkError );
|
|
321
|
+
|
|
322
|
+
eventSource.removeEventListener( 'done', handleDone );
|
|
323
|
+
|
|
324
|
+
// Set requesting state to done since the suggestion stopped.
|
|
325
|
+
setRequestingState( 'done' );
|
|
326
|
+
}, [
|
|
327
|
+
eventSourceRef,
|
|
328
|
+
handleSuggestion,
|
|
329
|
+
handleErrorQuotaExceededError,
|
|
330
|
+
handleUnclearPromptError,
|
|
331
|
+
handleServiceUnavailableError,
|
|
332
|
+
handleModerationError,
|
|
333
|
+
handleNetworkError,
|
|
334
|
+
handleDone,
|
|
335
|
+
] );
|
|
336
|
+
|
|
300
337
|
// Request suggestions automatically when ready.
|
|
301
338
|
useEffect( () => {
|
|
302
339
|
// Check if there is a prompt to request.
|
|
@@ -310,38 +347,10 @@ export default function useAiSuggestions( {
|
|
|
310
347
|
}
|
|
311
348
|
|
|
312
349
|
return () => {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
// Alias
|
|
318
|
-
const eventSource = eventSourceRef.current;
|
|
319
|
-
|
|
320
|
-
// Close the connection.
|
|
321
|
-
eventSource.close();
|
|
322
|
-
|
|
323
|
-
// Clean up the event listeners.
|
|
324
|
-
eventSource.removeEventListener( 'suggestion', handleSuggestion );
|
|
325
|
-
|
|
326
|
-
eventSource.removeEventListener( ERROR_QUOTA_EXCEEDED, handleErrorQuotaExceededError );
|
|
327
|
-
eventSource.removeEventListener( ERROR_UNCLEAR_PROMPT, handleUnclearPromptError );
|
|
328
|
-
eventSource.removeEventListener( ERROR_SERVICE_UNAVAILABLE, handleServiceUnavailableError );
|
|
329
|
-
eventSource.removeEventListener( ERROR_MODERATION, handleModerationError );
|
|
330
|
-
eventSource.removeEventListener( ERROR_NETWORK, handleNetworkError );
|
|
331
|
-
|
|
332
|
-
eventSource.removeEventListener( 'done', handleDone );
|
|
350
|
+
// Stop the suggestion if the component unmounts.
|
|
351
|
+
stopSuggestion();
|
|
333
352
|
};
|
|
334
|
-
}, [
|
|
335
|
-
autoRequest,
|
|
336
|
-
handleDone,
|
|
337
|
-
handleErrorQuotaExceededError,
|
|
338
|
-
handleModerationError,
|
|
339
|
-
handleServiceUnavailableError,
|
|
340
|
-
handleSuggestion,
|
|
341
|
-
handleUnclearPromptError,
|
|
342
|
-
prompt,
|
|
343
|
-
request,
|
|
344
|
-
] );
|
|
353
|
+
}, [ autoRequest, prompt, request, stopSuggestion ] );
|
|
345
354
|
|
|
346
355
|
return {
|
|
347
356
|
// Data
|
|
@@ -349,8 +358,9 @@ export default function useAiSuggestions( {
|
|
|
349
358
|
error,
|
|
350
359
|
requestingState,
|
|
351
360
|
|
|
352
|
-
// Request
|
|
361
|
+
// Request/stop handlers
|
|
353
362
|
request,
|
|
363
|
+
stopSuggestion,
|
|
354
364
|
|
|
355
365
|
// SuggestionsEventSource
|
|
356
366
|
eventSource: eventSourceRef.current,
|
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