@blocklet/pages-kit 0.2.306 → 0.2.307

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.
@@ -15,7 +15,21 @@ const jsx_runtime_1 = require("react/jsx-runtime");
15
15
  const material_1 = require("@mui/material");
16
16
  const react_1 = require("react");
17
17
  const StringField = (0, react_1.forwardRef)((_a, ref) => {
18
+ var _b;
18
19
  var { readOnly, parameter, onChange } = _a, props = __rest(_a, ["readOnly", "parameter", "onChange"]);
19
- return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({ ref: ref, multiline: parameter === null || parameter === void 0 ? void 0 : parameter.multiline, minRows: (parameter === null || parameter === void 0 ? void 0 : parameter.multiline) ? 2 : undefined, onChange: (e) => onChange(e.target.value) }, props, { InputProps: Object.assign(Object.assign({}, props.InputProps), { inputProps: Object.assign(Object.assign({}, props.inputProps), { maxLength: parameter === null || parameter === void 0 ? void 0 : parameter.maxLength }), readOnly }) })));
20
+ const isQuestion = (parameter === null || parameter === void 0 ? void 0 : parameter.key) === 'question';
21
+ const onKeyDown = (0, react_1.useCallback)((e) => {
22
+ var _a;
23
+ if (!isQuestion)
24
+ return;
25
+ // NOTE: Pressing Enter in the IME will trigger the 229 event
26
+ if (e.keyCode === 229)
27
+ return;
28
+ if (e.key === 'Enter' && !e.shiftKey && !e.repeat) {
29
+ e.preventDefault();
30
+ (_a = e.target.form) === null || _a === void 0 ? void 0 : _a.requestSubmit();
31
+ }
32
+ }, [isQuestion]);
33
+ return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({ ref: ref, multiline: isQuestion || (parameter === null || parameter === void 0 ? void 0 : parameter.multiline) || isQuestion, minRows: isQuestion ? 1 : (parameter === null || parameter === void 0 ? void 0 : parameter.multiline) ? 2 : undefined, onChange: (e) => onChange(e.target.value), onKeyDown: onKeyDown }, props, { InputProps: Object.assign(Object.assign({ readOnly }, props.InputProps), { sx: Object.assign({ py: 0, [`.${material_1.inputBaseClasses.input}`]: { py: 1 } }, (_b = props.InputProps) === null || _b === void 0 ? void 0 : _b.sx), inputProps: Object.assign(Object.assign({}, props.inputProps), { maxLength: parameter === null || parameter === void 0 ? void 0 : parameter.maxLength }) }) })));
20
34
  });
21
35
  exports.default = StringField;
@@ -123,7 +123,7 @@ function ShareSave() {
123
123
  const image = (_f = (_e = (_d = (_c = (_b = message.result) === null || _b === void 0 ? void 0 : _b.objects) === null || _c === void 0 ? void 0 : _c.find((i) => { var _a; return (_a = i.data[types_1.RuntimeOutputVariable.images]) === null || _a === void 0 ? void 0 : _a.length; })) === null || _d === void 0 ? void 0 : _d.data[types_1.RuntimeOutputVariable.images]) === null || _e === void 0 ? void 0 : _e.at(0)) === null || _f === void 0 ? void 0 : _f.url;
124
124
  if (!content && !image)
125
125
  return null;
126
- return ((0, jsx_runtime_1.jsx)(StyledActionButton, { tip: t('save'), tipSucceed: t('saved'), title: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:file" }), titleSucceed: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:file-check" }), onClick: () => __awaiter(this, void 0, void 0, function* () {
126
+ return ((0, jsx_runtime_1.jsx)(StyledActionButton, { tip: t('save'), tipSucceed: t('saved'), title: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:file-download" }), titleSucceed: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:file-check" }), onClick: () => __awaiter(this, void 0, void 0, function* () {
127
127
  // @ts-ignore
128
128
  const { default: html2pdf } = yield Promise.resolve().then(() => __importStar(require('html2pdf.js')));
129
129
  if (content) {
@@ -76,7 +76,7 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
76
76
  var _a;
77
77
  return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "form-item", children: [parameter.label && (0, jsx_runtime_1.jsx)(material_1.FormLabel, { children: parameter.label }), (0, jsx_runtime_1.jsx)(AgentInputField_1.default, { inputRef: field.ref, autoFocus: index === 0, size: "small", hiddenLabel: true, fullWidth: true, label: undefined, parameter: parameter, maxRows: !(parameter === null || parameter === void 0 ? void 0 : parameter.type) || (parameter === null || parameter === void 0 ? void 0 : parameter.type) === 'string' ? 5 : undefined, value: field.value || '', onChange: (value) => field.onChange({ target: { value } }), error: Boolean(fieldState.error), helperText: ((_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message) || (parameter === null || parameter === void 0 ? void 0 : parameter.helper), InputProps: parameter.key === 'question' && submitInQuestionField
78
78
  ? {
79
- endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", sx: { py: 3, mr: -0.75 }, children: (0, jsx_runtime_1.jsx)(LoadingButton_1.default, { type: "submit", variant: "contained", loading: running, sx: { borderRadius: 100 }, children: submitText }) })),
79
+ endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", sx: { py: 3, mr: -0.75, alignSelf: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(LoadingButton_1.default, { type: "submit", variant: "contained", loading: running, sx: { borderRadius: 100 }, children: submitText }) })),
80
80
  }
81
81
  : undefined })] }));
82
82
  } }) }, parameter.id));
@@ -10,10 +10,24 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import { TextField } from '@mui/material';
14
- import { forwardRef } from 'react';
13
+ import { TextField, inputBaseClasses } from '@mui/material';
14
+ import { forwardRef, useCallback } from 'react';
15
15
  const StringField = forwardRef((_a, ref) => {
16
+ var _b;
16
17
  var { readOnly, parameter, onChange } = _a, props = __rest(_a, ["readOnly", "parameter", "onChange"]);
17
- return (_jsx(TextField, Object.assign({ ref: ref, multiline: parameter === null || parameter === void 0 ? void 0 : parameter.multiline, minRows: (parameter === null || parameter === void 0 ? void 0 : parameter.multiline) ? 2 : undefined, onChange: (e) => onChange(e.target.value) }, props, { InputProps: Object.assign(Object.assign({}, props.InputProps), { inputProps: Object.assign(Object.assign({}, props.inputProps), { maxLength: parameter === null || parameter === void 0 ? void 0 : parameter.maxLength }), readOnly }) })));
18
+ const isQuestion = (parameter === null || parameter === void 0 ? void 0 : parameter.key) === 'question';
19
+ const onKeyDown = useCallback((e) => {
20
+ var _a;
21
+ if (!isQuestion)
22
+ return;
23
+ // NOTE: Pressing Enter in the IME will trigger the 229 event
24
+ if (e.keyCode === 229)
25
+ return;
26
+ if (e.key === 'Enter' && !e.shiftKey && !e.repeat) {
27
+ e.preventDefault();
28
+ (_a = e.target.form) === null || _a === void 0 ? void 0 : _a.requestSubmit();
29
+ }
30
+ }, [isQuestion]);
31
+ return (_jsx(TextField, Object.assign({ ref: ref, multiline: isQuestion || (parameter === null || parameter === void 0 ? void 0 : parameter.multiline) || isQuestion, minRows: isQuestion ? 1 : (parameter === null || parameter === void 0 ? void 0 : parameter.multiline) ? 2 : undefined, onChange: (e) => onChange(e.target.value), onKeyDown: onKeyDown }, props, { InputProps: Object.assign(Object.assign({ readOnly }, props.InputProps), { sx: Object.assign({ py: 0, [`.${inputBaseClasses.input}`]: { py: 1 } }, (_b = props.InputProps) === null || _b === void 0 ? void 0 : _b.sx), inputProps: Object.assign(Object.assign({}, props.inputProps), { maxLength: parameter === null || parameter === void 0 ? void 0 : parameter.maxLength }) }) })));
18
32
  });
19
33
  export default StringField;
@@ -94,7 +94,7 @@ function ShareSave() {
94
94
  const image = (_f = (_e = (_d = (_c = (_b = message.result) === null || _b === void 0 ? void 0 : _b.objects) === null || _c === void 0 ? void 0 : _c.find((i) => { var _a; return (_a = i.data[RuntimeOutputVariable.images]) === null || _a === void 0 ? void 0 : _a.length; })) === null || _d === void 0 ? void 0 : _d.data[RuntimeOutputVariable.images]) === null || _e === void 0 ? void 0 : _e.at(0)) === null || _f === void 0 ? void 0 : _f.url;
95
95
  if (!content && !image)
96
96
  return null;
97
- return (_jsx(StyledActionButton, { tip: t('save'), tipSucceed: t('saved'), title: _jsx(Icon, { icon: "tabler:file" }), titleSucceed: _jsx(Icon, { icon: "tabler:file-check" }), onClick: () => __awaiter(this, void 0, void 0, function* () {
97
+ return (_jsx(StyledActionButton, { tip: t('save'), tipSucceed: t('saved'), title: _jsx(Icon, { icon: "tabler:file-download" }), titleSucceed: _jsx(Icon, { icon: "tabler:file-check" }), onClick: () => __awaiter(this, void 0, void 0, function* () {
98
98
  // @ts-ignore
99
99
  const { default: html2pdf } = yield import('html2pdf.js');
100
100
  if (content) {
@@ -71,7 +71,7 @@ export default function AutoForm({ submitText, inlineLabel, autoFillLastForm = t
71
71
  var _a;
72
72
  return (_jsxs(Stack, { className: "form-item", children: [parameter.label && _jsx(FormLabel, { children: parameter.label }), _jsx(AgentInputField, { inputRef: field.ref, autoFocus: index === 0, size: "small", hiddenLabel: true, fullWidth: true, label: undefined, parameter: parameter, maxRows: !(parameter === null || parameter === void 0 ? void 0 : parameter.type) || (parameter === null || parameter === void 0 ? void 0 : parameter.type) === 'string' ? 5 : undefined, value: field.value || '', onChange: (value) => field.onChange({ target: { value } }), error: Boolean(fieldState.error), helperText: ((_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message) || (parameter === null || parameter === void 0 ? void 0 : parameter.helper), InputProps: parameter.key === 'question' && submitInQuestionField
73
73
  ? {
74
- endAdornment: (_jsx(InputAdornment, { position: "end", sx: { py: 3, mr: -0.75 }, children: _jsx(LoadingButton, { type: "submit", variant: "contained", loading: running, sx: { borderRadius: 100 }, children: submitText }) })),
74
+ endAdornment: (_jsx(InputAdornment, { position: "end", sx: { py: 3, mr: -0.75, alignSelf: 'flex-end' }, children: _jsx(LoadingButton, { type: "submit", variant: "contained", loading: running, sx: { borderRadius: 100 }, children: submitText }) })),
75
75
  }
76
76
  : undefined })] }));
77
77
  } }) }, parameter.id));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/pages-kit",
3
- "version": "0.2.306",
3
+ "version": "0.2.307",
4
4
  "description": "Pages Kit components and utils",
5
5
  "publishConfig": {
6
6
  "access": "public"