@automattic/jetpack-ai-client 0.12.2 → 0.12.4

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.
@@ -1,118 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { ExternalLink, Button } from '@wordpress/components';
5
- import { createInterpolateElement } from '@wordpress/element';
6
- import { __, sprintf } from '@wordpress/i18n';
7
- import {
8
- Icon,
9
- warning,
10
- info,
11
- cancelCircleFilled as error,
12
- check as success,
13
- } from '@wordpress/icons';
14
- /**
15
- * Types
16
- */
17
- import type React from 'react';
18
-
19
- import './style.scss';
20
-
21
- export const MESSAGE_SEVERITY_WARNING = 'warning';
22
- export const MESSAGE_SEVERITY_ERROR = 'error';
23
- export const MESSAGE_SEVERITY_SUCCESS = 'success';
24
- export const MESSAGE_SEVERITY_INFO = 'info';
25
-
26
- const messageSeverityTypes = [
27
- MESSAGE_SEVERITY_WARNING,
28
- MESSAGE_SEVERITY_ERROR,
29
- MESSAGE_SEVERITY_SUCCESS,
30
- MESSAGE_SEVERITY_INFO,
31
- ] as const;
32
-
33
- export type MessageSeverityProp = ( typeof messageSeverityTypes )[ number ] | null;
34
-
35
- export type MessageProps = {
36
- icon?: React.ReactNode;
37
- children: React.ReactNode;
38
- severity: MessageSeverityProp;
39
- };
40
-
41
- const messageIconsMap = {
42
- [ MESSAGE_SEVERITY_WARNING ]: warning,
43
- [ MESSAGE_SEVERITY_ERROR ]: error,
44
- [ MESSAGE_SEVERITY_SUCCESS ]: success,
45
- [ MESSAGE_SEVERITY_INFO ]: info,
46
- };
47
-
48
- /**
49
- * React component to render a block message.
50
- *
51
- * @param {MessageProps} props - Component props.
52
- * @returns {React.ReactElement } Banner component.
53
- */
54
- export default function Message( {
55
- severity = null,
56
- icon = null,
57
- children,
58
- }: MessageProps ): React.ReactElement {
59
- return (
60
- <div className="jetpack-ai-assistant__message">
61
- { ( severity || icon ) && <Icon icon={ messageIconsMap[ severity ] || icon } /> }
62
- <div className="jetpack-ai-assistant__message-content">{ children }</div>
63
- </div>
64
- );
65
- }
66
-
67
- /**
68
- * React component to render a guideline message.
69
- *
70
- * @returns {React.ReactElement } - Message component.
71
- */
72
- export function GuidelineMessage(): React.ReactElement {
73
- return (
74
- <Message severity={ MESSAGE_SEVERITY_INFO }>
75
- { createInterpolateElement(
76
- __(
77
- 'AI-generated content could be inaccurate or biased. <link>Learn more</link>',
78
- 'jetpack-ai-client'
79
- ),
80
- {
81
- link: <ExternalLink href="https://automattic.com/ai-guidelines" />,
82
- }
83
- ) }
84
- </Message>
85
- );
86
- }
87
-
88
- /**
89
- * React component to render a upgrade message.
90
- *
91
- * @param {number} requestsRemaining - Number of requests remaining.
92
- * @returns {React.ReactElement } - Message component.
93
- */
94
- export function UpgradeMessage( {
95
- requestsRemaining,
96
- onUpgradeClick,
97
- }: {
98
- requestsRemaining: number;
99
- onUpgradeClick: () => void;
100
- } ): React.ReactElement {
101
- return (
102
- <Message severity={ MESSAGE_SEVERITY_INFO }>
103
- { createInterpolateElement(
104
- sprintf(
105
- // translators: %1$d: number of requests remaining
106
- __(
107
- 'You have %1$d free requests remaining. <link>Upgrade</link> and avoid interruptions',
108
- 'jetpack-ai-client'
109
- ),
110
- requestsRemaining
111
- ),
112
- {
113
- link: <Button variant="link" onClick={ onUpgradeClick } />,
114
- }
115
- ) }
116
- </Message>
117
- );
118
- }