@truedat/ai 7.2.11 → 7.3.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/ai",
3
- "version": "7.2.11",
3
+ "version": "7.3.1",
4
4
  "description": "Truedat Web Artificial Intelligence package",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -35,7 +35,7 @@
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/react-hooks": "^8.0.1",
37
37
  "@testing-library/user-event": "^13.2.1",
38
- "@truedat/test": "7.2.11",
38
+ "@truedat/test": "7.3.1",
39
39
  "babel-jest": "^28.1.0",
40
40
  "babel-plugin-dynamic-import-node": "^2.3.3",
41
41
  "babel-plugin-lodash": "^3.3.4",
@@ -85,7 +85,7 @@
85
85
  ]
86
86
  },
87
87
  "dependencies": {
88
- "@truedat/core": "7.2.11",
88
+ "@truedat/core": "7.3.1",
89
89
  "prop-types": "^15.8.1",
90
90
  "react-hook-form": "^7.45.4",
91
91
  "react-intl": "^5.20.10",
@@ -97,5 +97,5 @@
97
97
  "react-dom": ">= 16.8.6 < 17",
98
98
  "semantic-ui-react": ">= 2.0.3 < 2.2"
99
99
  },
100
- "gitHead": "74eb04f81dd49275229cf3050b56b897ff78410e"
100
+ "gitHead": "7101536d0432c47d5045efaf2cbb3f87d77c4c95"
101
101
  }
@@ -10,6 +10,7 @@ import {
10
10
  List,
11
11
  Message,
12
12
  Segment,
13
+ Popup,
13
14
  } from "semantic-ui-react";
14
15
  import { FormattedMessage } from "react-intl";
15
16
  import { toEnrichedTextFormat } from "@truedat/core/services/format";
@@ -19,6 +20,8 @@ export default function SuggestionsWidget({
19
20
  applySuggestions,
20
21
  template,
21
22
  isModification,
23
+ enableRequestButton = true,
24
+ disabledButtonMessage = "",
22
25
  }) {
23
26
  const [loadingSuggestion, setLoadingSuggestion] = useState();
24
27
  const [suggestions, setSuggestions] = useState();
@@ -115,8 +118,22 @@ export default function SuggestionsWidget({
115
118
  <FormattedMessage id="structure_note.ai_suggestion.header" />
116
119
  </h4>
117
120
  <Divider hidden />
118
- {suggestions ? null : (
119
- <Button onClick={handleRequestSuggestions}>
121
+ {suggestions ? null : !enableRequestButton && disabledButtonMessage ? (
122
+ <Popup
123
+ content={disabledButtonMessage}
124
+ trigger={
125
+ <span>
126
+ <Button onClick={handleRequestSuggestions} disabled>
127
+ <FormattedMessage id="actions.ai_suggestion" />
128
+ </Button>
129
+ </span>
130
+ }
131
+ />
132
+ ) : (
133
+ <Button
134
+ onClick={handleRequestSuggestions}
135
+ disabled={!enableRequestButton}
136
+ >
120
137
  <FormattedMessage id="actions.ai_suggestion" />
121
138
  </Button>
122
139
  )}
@@ -189,8 +206,10 @@ export default function SuggestionsWidget({
189
206
  }
190
207
 
191
208
  SuggestionsWidget.propTypes = {
192
- aiSuggestionsUrl: PropTypes.object,
209
+ requestAiSuggestion: PropTypes.func,
193
210
  applySuggestions: PropTypes.func,
194
211
  template: PropTypes.object,
195
212
  isModification: PropTypes.bool,
213
+ enableRequestButton: PropTypes.bool,
214
+ disabledButtonMessage: PropTypes.string,
196
215
  };