@blocklet/pages-kit 0.2.335 → 0.2.337

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.
@@ -18,11 +18,25 @@ const jsx_runtime_1 = require("react/jsx-runtime");
18
18
  const icons_material_1 = require("@mui/icons-material");
19
19
  const material_1 = require("@mui/material");
20
20
  const react_1 = require("react");
21
+ const react_helmet_1 = require("react-helmet");
21
22
  const runtime_1 = require("../state/runtime");
22
23
  const GlobalLoading_1 = __importDefault(require("./GlobalLoading"));
24
+ const getFontUrl = (fontList) => {
25
+ var _a;
26
+ if (!fontList.length)
27
+ return;
28
+ const BASE_URL = 'https://fonts.googleapis.com/css?family=';
29
+ const newFontList = (_a = fontList
30
+ .filter((font) => typeof font === 'string')) === null || _a === void 0 ? void 0 : _a.map((font) => font.replace(/ /g, '+')).join('|');
31
+ // eslint-disable-next-line consistent-return
32
+ return `${BASE_URL}${newFontList}`;
33
+ };
23
34
  function ThemeProvider({ children }) {
35
+ var _a, _b, _c;
24
36
  const { appearance } = (0, runtime_1.useRuntimeState)().agent.project;
25
37
  const theme = (0, material_1.useTheme)();
38
+ const titleFont = (_a = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _a === void 0 ? void 0 : _a.fontFamily;
39
+ const headFont = (_c = (_b = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _b === void 0 ? void 0 : _b.heading) === null || _c === void 0 ? void 0 : _c.fontFamily;
26
40
  const newTheme = (0, react_1.useMemo)(() => {
27
41
  var _a, _b, _c, _d, _e, _f;
28
42
  let { primary } = theme.palette;
@@ -149,22 +163,22 @@ function ThemeProvider({ children }) {
149
163
  ],
150
164
  });
151
165
  }, [theme]);
152
- return ((0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: newTheme, children: (0, jsx_runtime_1.jsxs)(material_1.CssBaseline, { children: [(0, jsx_runtime_1.jsx)(material_1.GlobalStyles, { styles: (theme) => theme.unstable_sx({
153
- 'h1,h2,h3,h4,h5': {
154
- fontFamily: `${theme.typography.h1.fontFamily} !important`,
155
- },
156
- body: {
157
- fontFamily: `${theme.typography.fontFamily} !important`,
158
- },
159
- '.page-header': {
160
- borderBottom: '1px solid rgba(229, 231, 235, 1)',
161
- },
162
- '.white-tooltip .MuiTooltip-tooltip': {
163
- background: 'white !important',
164
- boxShadow: '0px 4px 8px 0px rgba(3, 7, 18, 0.08)',
165
- border: '1px solid rgba(229, 231, 235, 1)',
166
- padding: 4,
167
- },
168
- }) }), (0, jsx_runtime_1.jsx)(GlobalLoading_1.default, { sx: { position: 'fixed', left: 0, top: 0, width: '100%', zIndex: 'snackbar' } }), (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(material_1.Stack, { flexGrow: 1, alignItems: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 24 }) }), children: children })] }) }));
166
+ return ((0, jsx_runtime_1.jsxs)(material_1.ThemeProvider, { theme: newTheme, children: [(0, jsx_runtime_1.jsx)(react_helmet_1.Helmet, { children: (0, jsx_runtime_1.jsx)("link", { rel: "stylesheet", href: getFontUrl([titleFont, headFont]) }) }), (0, jsx_runtime_1.jsxs)(material_1.CssBaseline, { children: [(0, jsx_runtime_1.jsx)(material_1.GlobalStyles, { styles: (theme) => theme.unstable_sx({
167
+ 'h1,h2,h3,h4,h5': {
168
+ fontFamily: `${theme.typography.h1.fontFamily} !important`,
169
+ },
170
+ body: {
171
+ fontFamily: `${theme.typography.fontFamily} !important`,
172
+ },
173
+ '.page-header': {
174
+ borderBottom: '1px solid rgba(229, 231, 235, 1)',
175
+ },
176
+ '.white-tooltip .MuiTooltip-tooltip': {
177
+ background: 'white !important',
178
+ boxShadow: '0px 4px 8px 0px rgba(3, 7, 18, 0.08)',
179
+ border: '1px solid rgba(229, 231, 235, 1)',
180
+ padding: 4,
181
+ },
182
+ }) }), (0, jsx_runtime_1.jsx)(GlobalLoading_1.default, { sx: { position: 'fixed', left: 0, top: 0, width: '100%', zIndex: 'snackbar' } }), (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(material_1.Stack, { flexGrow: 1, alignItems: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 24 }) }), children: children })] })] }));
169
183
  }
170
184
  exports.default = ThemeProvider;
@@ -16,7 +16,9 @@ function UserMessageView() {
16
16
  const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
17
17
  const params = (0, react_1.useMemo)(() => {
18
18
  var _a;
19
- return (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.filter(agent_inputs_1.isValidInput).map((i) => { var _a, _b; return [((_a = i.label) === null || _a === void 0 ? void 0 : _a.trim()) || i.key, (_b = message.parameters) === null || _b === void 0 ? void 0 : _b[i.key]]; }).filter((i) => i[1]);
19
+ const inputs = (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.filter(agent_inputs_1.isValidInput).map((i) => { var _a, _b; return [((_a = i.label) === null || _a === void 0 ? void 0 : _a.trim()) || i.key, (_b = message.parameters) === null || _b === void 0 ? void 0 : _b[i.key]]; }).filter((i) => i[1]);
20
+ const q = inputs === null || inputs === void 0 ? void 0 : inputs.find((i) => i[0] === 'question');
21
+ return q ? [q] : inputs;
20
22
  }, [agent.parameters, message.parameters]);
21
23
  if ((params === null || params === void 0 ? void 0 : params.length) === 1) {
22
24
  return (0, jsx_runtime_1.jsx)(MarkdownRenderer_1.default, { children: (_a = params[0]) === null || _a === void 0 ? void 0 : _a[1] });