@automattic/jetpack-ai-client 0.24.3 → 0.25.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 +9 -0
- package/build/ai-client/src/logo-generator/components/prompt.d.ts +2 -2
- package/build/ai-client/src/logo-generator/components/prompt.js +3 -4
- package/package.json +13 -13
- package/src/logo-generator/components/prompt.scss +4 -0
- package/src/logo-generator/components/prompt.tsx +4 -5
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@ 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.25.0] - 2024-11-25
|
|
9
|
+
### Added
|
|
10
|
+
- AI Client: split disabled prop to allow disabling input and action button separately [#40210]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- AI Client: fix prompt cursor to text when editable [#40247]
|
|
14
|
+
- Updated package dependencies. [#40288]
|
|
15
|
+
|
|
8
16
|
## [0.24.3] - 2024-11-18
|
|
9
17
|
### Changed
|
|
10
18
|
- AI Client: add effect on AiModalInputPrompt to update/set prompt on prop update [#40113]
|
|
@@ -463,6 +471,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
463
471
|
- AI Client: stop using smart document visibility handling on the fetchEventSource library, so it does not restart the completion when changing tabs. [#32004]
|
|
464
472
|
- Updated package dependencies. [#31468] [#31659] [#31785]
|
|
465
473
|
|
|
474
|
+
[0.25.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.24.3...v0.25.0
|
|
466
475
|
[0.24.3]: https://github.com/Automattic/jetpack-ai-client/compare/v0.24.2...v0.24.3
|
|
467
476
|
[0.24.2]: https://github.com/Automattic/jetpack-ai-client/compare/v0.24.1...v0.24.2
|
|
468
477
|
[0.24.1]: https://github.com/Automattic/jetpack-ai-client/compare/v0.24.0...v0.24.1
|
|
@@ -3,14 +3,14 @@ import './prompt.scss';
|
|
|
3
3
|
type PromptProps = {
|
|
4
4
|
initialPrompt?: string;
|
|
5
5
|
};
|
|
6
|
-
export declare const AiModalPromptInput: ({ prompt, setPrompt, disabled, generateHandler, placeholder, buttonLabel,
|
|
6
|
+
export declare const AiModalPromptInput: ({ prompt, setPrompt, disabled, actionDisabled, generateHandler, placeholder, buttonLabel, }: {
|
|
7
7
|
prompt: string;
|
|
8
8
|
setPrompt: Dispatch<SetStateAction<string>>;
|
|
9
9
|
disabled: boolean;
|
|
10
|
+
actionDisabled: boolean;
|
|
10
11
|
generateHandler: () => void;
|
|
11
12
|
placeholder?: string;
|
|
12
13
|
buttonLabel?: string;
|
|
13
|
-
minPromptLength?: number;
|
|
14
14
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
15
15
|
export declare const Prompt: ({ initialPrompt }: PromptProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
16
|
export {};
|
|
@@ -21,9 +21,8 @@ import { FairUsageNotice } from './fair-usage-notice.js';
|
|
|
21
21
|
import { UpgradeNudge } from './upgrade-nudge.js';
|
|
22
22
|
import './prompt.scss';
|
|
23
23
|
const debug = debugFactory('jetpack-ai-calypso:prompt-box');
|
|
24
|
-
export const AiModalPromptInput = ({ prompt = '', setPrompt = () => { }, disabled = false, generateHandler = () => { }, placeholder = '', buttonLabel = '',
|
|
24
|
+
export const AiModalPromptInput = ({ prompt = '', setPrompt = () => { }, disabled = false, actionDisabled = false, generateHandler = () => { }, placeholder = '', buttonLabel = '', }) => {
|
|
25
25
|
const inputRef = useRef(null);
|
|
26
|
-
const hasPrompt = prompt?.length >= (minPromptLength === null ? MINIMUM_PROMPT_LENGTH : minPromptLength);
|
|
27
26
|
const onPromptInput = (event) => {
|
|
28
27
|
setPrompt(event.target.textContent || '');
|
|
29
28
|
};
|
|
@@ -63,7 +62,7 @@ export const AiModalPromptInput = ({ prompt = '', setPrompt = () => { }, disable
|
|
|
63
62
|
};
|
|
64
63
|
return (_jsxs("div", { className: "jetpack-ai-logo-generator__prompt-query", children: [_jsx("div", { role: "textbox", tabIndex: 0, ref: inputRef, contentEditable: !disabled,
|
|
65
64
|
// The content editable div is expected to be updated by the enhance prompt, so warnings are suppressed
|
|
66
|
-
suppressContentEditableWarning: true, className: "prompt-query__input", onInput: onPromptInput, onPaste: onPromptPaste, onKeyDown: onKeyDown, onKeyUp: onKeyUp, "data-placeholder": placeholder }), _jsx(Button, { variant: "primary", className: "jetpack-ai-logo-generator__prompt-submit", onClick: generateHandler, disabled:
|
|
65
|
+
suppressContentEditableWarning: true, className: "prompt-query__input", onInput: onPromptInput, onPaste: onPromptPaste, onKeyDown: onKeyDown, onKeyUp: onKeyUp, "data-placeholder": placeholder }), _jsx(Button, { variant: "primary", className: "jetpack-ai-logo-generator__prompt-submit", onClick: generateHandler, disabled: actionDisabled, children: buttonLabel || __('Generate', 'jetpack-ai-client') })] }));
|
|
67
66
|
};
|
|
68
67
|
export const Prompt = ({ initialPrompt = '' }) => {
|
|
69
68
|
const { tracks } = useAnalytics();
|
|
@@ -155,7 +154,7 @@ export const Prompt = ({ initialPrompt = '' }) => {
|
|
|
155
154
|
setStyle(imageStyle);
|
|
156
155
|
recordTracksEvent(EVENT_SWITCH_STYLE, { context, style: imageStyle });
|
|
157
156
|
}, [context, setStyle, recordTracksEvent]);
|
|
158
|
-
return (_jsxs("div", { className: "jetpack-ai-logo-generator__prompt", children: [_jsxs("div", { className: "jetpack-ai-logo-generator__prompt-header", children: [_jsx("div", { className: "jetpack-ai-logo-generator__prompt-label", children: __('Describe your site:', 'jetpack-ai-client') }), _jsx("div", { className: "jetpack-ai-logo-generator__prompt-actions", children: _jsxs(Button, { variant: "link", disabled: isBusy || requireUpgrade || !hasPrompt, onClick: onEnhance, children: [_jsx(AiIcon, {}), enhanceButtonLabel] }) }), showStyleSelector && (_jsx(SelectControl, { __nextHasNoMarginBottom: true, value: style, options: styles, onChange: updateStyle, disabled: isBusy || requireUpgrade }))] }), _jsx(AiModalPromptInput, { prompt: prompt, setPrompt: setPrompt, generateHandler: onGenerate, disabled: isBusy || requireUpgrade, placeholder: __('Describe your site or simply ask for a logo specifying some details about it', 'jetpack-ai-client') }), _jsxs("div", { className: "jetpack-ai-logo-generator__prompt-footer", children: [!isUnlimited && !requireUpgrade && (_jsxs("div", { className: "jetpack-ai-logo-generator__prompt-requests", children: [_jsx("div", { children: sprintf(
|
|
157
|
+
return (_jsxs("div", { className: "jetpack-ai-logo-generator__prompt", children: [_jsxs("div", { className: "jetpack-ai-logo-generator__prompt-header", children: [_jsx("div", { className: "jetpack-ai-logo-generator__prompt-label", children: __('Describe your site:', 'jetpack-ai-client') }), _jsx("div", { className: "jetpack-ai-logo-generator__prompt-actions", children: _jsxs(Button, { variant: "link", disabled: isBusy || requireUpgrade || !hasPrompt, onClick: onEnhance, children: [_jsx(AiIcon, {}), enhanceButtonLabel] }) }), showStyleSelector && (_jsx(SelectControl, { __nextHasNoMarginBottom: true, value: style, options: styles, onChange: updateStyle, disabled: isBusy || requireUpgrade }))] }), _jsx(AiModalPromptInput, { prompt: prompt, setPrompt: setPrompt, generateHandler: onGenerate, disabled: isBusy || requireUpgrade, actionDisabled: isBusy || requireUpgrade || !hasPrompt, placeholder: __('Describe your site or simply ask for a logo specifying some details about it', 'jetpack-ai-client') }), _jsxs("div", { className: "jetpack-ai-logo-generator__prompt-footer", children: [!isUnlimited && !requireUpgrade && (_jsxs("div", { className: "jetpack-ai-logo-generator__prompt-requests", children: [_jsx("div", { children: sprintf(
|
|
159
158
|
// translators: %u is the number of requests
|
|
160
159
|
__('%u requests remaining.', 'jetpack-ai-client'), requestsRemaining) }), hasNextTier && (_jsxs(_Fragment, { children: ["\u00A0", _jsx(Button, { variant: "link", href: checkoutUrl, target: "_blank", onClick: onUpgradeClick, children: __('Upgrade', 'jetpack-ai-client') })] })), "\u00A0", _jsx(Tooltip, { text: __('Logo generation costs 10 requests; prompt enhancement costs 1 request each', 'jetpack-ai-client'), placement: "bottom", children: _jsx(Icon, { className: "prompt-footer__icon", icon: info }) })] })), requireUpgrade && tierPlansEnabled && _jsx(UpgradeNudge, {}), requireUpgrade && !tierPlansEnabled && _jsx(FairUsageNotice, {}), enhancePromptFetchError && (_jsx("div", { className: "jetpack-ai-logo-generator__prompt-error", children: __('Error enhancing prompt. Please try again.', 'jetpack-ai-client') })), logoFetchError && (_jsx("div", { className: "jetpack-ai-logo-generator__prompt-error", children: __('Error generating logo. Please try again.', 'jetpack-ai-client') }))] })] }));
|
|
161
160
|
};
|
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.25.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": {
|
|
@@ -44,21 +44,21 @@
|
|
|
44
44
|
"main": "./build/index.js",
|
|
45
45
|
"types": "./build/index.d.ts",
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@automattic/jetpack-base-styles": "^0.6.
|
|
48
|
-
"@automattic/jetpack-connection": "^0.35.
|
|
49
|
-
"@automattic/jetpack-shared-extension-utils": "^0.15.
|
|
47
|
+
"@automattic/jetpack-base-styles": "^0.6.37",
|
|
48
|
+
"@automattic/jetpack-connection": "^0.35.19",
|
|
49
|
+
"@automattic/jetpack-shared-extension-utils": "^0.15.18",
|
|
50
50
|
"@microsoft/fetch-event-source": "2.0.1",
|
|
51
51
|
"@types/react": "18.3.12",
|
|
52
52
|
"@types/wordpress__block-editor": "11.5.15",
|
|
53
|
-
"@wordpress/api-fetch": "7.
|
|
54
|
-
"@wordpress/blob": "4.
|
|
55
|
-
"@wordpress/block-editor": "14.
|
|
56
|
-
"@wordpress/components": "28.
|
|
57
|
-
"@wordpress/compose": "7.
|
|
58
|
-
"@wordpress/data": "10.
|
|
59
|
-
"@wordpress/element": "6.
|
|
60
|
-
"@wordpress/i18n": "5.
|
|
61
|
-
"@wordpress/icons": "10.
|
|
53
|
+
"@wordpress/api-fetch": "7.12.0",
|
|
54
|
+
"@wordpress/blob": "4.12.0",
|
|
55
|
+
"@wordpress/block-editor": "14.7.0",
|
|
56
|
+
"@wordpress/components": "28.12.0",
|
|
57
|
+
"@wordpress/compose": "7.12.0",
|
|
58
|
+
"@wordpress/data": "10.12.0",
|
|
59
|
+
"@wordpress/element": "6.12.0",
|
|
60
|
+
"@wordpress/i18n": "5.12.0",
|
|
61
|
+
"@wordpress/icons": "10.12.0",
|
|
62
62
|
"clsx": "2.1.1",
|
|
63
63
|
"debug": "4.3.4",
|
|
64
64
|
"markdown-it": "14.0.0",
|
|
@@ -42,22 +42,20 @@ export const AiModalPromptInput = ( {
|
|
|
42
42
|
prompt = '',
|
|
43
43
|
setPrompt = () => {},
|
|
44
44
|
disabled = false,
|
|
45
|
+
actionDisabled = false,
|
|
45
46
|
generateHandler = () => {},
|
|
46
47
|
placeholder = '',
|
|
47
48
|
buttonLabel = '',
|
|
48
|
-
minPromptLength = null,
|
|
49
49
|
}: {
|
|
50
50
|
prompt: string;
|
|
51
51
|
setPrompt: Dispatch< SetStateAction< string > >;
|
|
52
52
|
disabled: boolean;
|
|
53
|
+
actionDisabled: boolean;
|
|
53
54
|
generateHandler: () => void;
|
|
54
55
|
placeholder?: string;
|
|
55
56
|
buttonLabel?: string;
|
|
56
|
-
minPromptLength?: number;
|
|
57
57
|
} ) => {
|
|
58
58
|
const inputRef = useRef< HTMLDivElement | null >( null );
|
|
59
|
-
const hasPrompt =
|
|
60
|
-
prompt?.length >= ( minPromptLength === null ? MINIMUM_PROMPT_LENGTH : minPromptLength );
|
|
61
59
|
|
|
62
60
|
const onPromptInput = ( event: React.ChangeEvent< HTMLInputElement > ) => {
|
|
63
61
|
setPrompt( event.target.textContent || '' );
|
|
@@ -125,7 +123,7 @@ export const AiModalPromptInput = ( {
|
|
|
125
123
|
variant="primary"
|
|
126
124
|
className="jetpack-ai-logo-generator__prompt-submit"
|
|
127
125
|
onClick={ generateHandler }
|
|
128
|
-
disabled={
|
|
126
|
+
disabled={ actionDisabled }
|
|
129
127
|
>
|
|
130
128
|
{ buttonLabel || __( 'Generate', 'jetpack-ai-client' ) }
|
|
131
129
|
</Button>
|
|
@@ -283,6 +281,7 @@ export const Prompt = ( { initialPrompt = '' }: PromptProps ) => {
|
|
|
283
281
|
setPrompt={ setPrompt }
|
|
284
282
|
generateHandler={ onGenerate }
|
|
285
283
|
disabled={ isBusy || requireUpgrade }
|
|
284
|
+
actionDisabled={ isBusy || requireUpgrade || ! hasPrompt }
|
|
286
285
|
placeholder={ __(
|
|
287
286
|
'Describe your site or simply ask for a logo specifying some details about it',
|
|
288
287
|
'jetpack-ai-client'
|