@apteva/apteva-kit 0.1.128 → 0.1.129
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/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -747,8 +747,8 @@ var WIDGET_DEFINITIONS = {
|
|
|
747
747
|
example: '@ui:button_group[{"buttons": [{"id": "ok", "label": "OK"}]}]'
|
|
748
748
|
},
|
|
749
749
|
form: {
|
|
750
|
-
schema: 'title?, fields: [{name, type: "text"|"password"|"number"|"select"|"checkbox"|"textarea"|"date", label, required?, placeholder?, options?: [{label, value}]}],
|
|
751
|
-
example: '@ui:form[{"title": "Settings", "fields": [{"name": "key", "type": "password", "label": "API Key", "required": true}]
|
|
750
|
+
schema: 'title?, fields: [{name, type: "text"|"password"|"number"|"select"|"checkbox"|"textarea"|"date", label, required?, placeholder?, options?: [{label, value}]}], submitLabel?: string',
|
|
751
|
+
example: '@ui:form[{"title": "Settings", "fields": [{"name": "key", "type": "password", "label": "API Key", "required": true}]}]'
|
|
752
752
|
},
|
|
753
753
|
table: {
|
|
754
754
|
schema: "columns: [{key, label}], rows: [{key: value, \u2026}], striped?, compact?",
|
|
@@ -797,9 +797,9 @@ Do NOT wrap widgets in code blocks or backticks. Write them directly in your res
|
|
|
797
797
|
`;
|
|
798
798
|
}
|
|
799
799
|
context += `### Notes
|
|
800
|
-
- **actions**: the \`type\` field is a custom string you choose (e.g. "edit", "delete"
|
|
800
|
+
- **actions**: the \`type\` field is a custom string you choose (e.g. "edit", "delete"). It is returned to the app when the user clicks the button.
|
|
801
801
|
- **metadata** on list items: any extra data attached to an item. Returned as the action payload when the user clicks that item.
|
|
802
|
-
- **form**:
|
|
802
|
+
- **form**: always has a submit button (label defaults to "Submit"). When clicked, the form data is sent as a chat message automatically. Do NOT add a separate button_group for form submission.
|
|
803
803
|
- **select fields**: \`options\` is an array of \`{label, value}\` objects.
|
|
804
804
|
`;
|
|
805
805
|
return context;
|
|
@@ -819,7 +819,7 @@ Use when structured display is clearer than plain text. Normal text can surround
|
|
|
819
819
|
`;
|
|
820
820
|
}
|
|
821
821
|
context += `
|
|
822
|
-
actions.type = custom string returned on click. list metadata = payload on item click. form
|
|
822
|
+
actions.type = custom string returned on click. list metadata = payload on item click. form submit sends data as chat message automatically, no button_group needed.
|
|
823
823
|
`;
|
|
824
824
|
return context;
|
|
825
825
|
}
|
|
@@ -1765,10 +1765,10 @@ function Form({ widget, onAction }) {
|
|
|
1765
1765
|
}, []);
|
|
1766
1766
|
const handleSubmit = (e) => {
|
|
1767
1767
|
e.preventDefault();
|
|
1768
|
-
if (
|
|
1768
|
+
if (onAction) {
|
|
1769
1769
|
onAction({
|
|
1770
|
-
type:
|
|
1771
|
-
payload: {
|
|
1770
|
+
type: "submit",
|
|
1771
|
+
payload: { formData },
|
|
1772
1772
|
widgetId: widget.id,
|
|
1773
1773
|
timestamp: /* @__PURE__ */ new Date()
|
|
1774
1774
|
});
|
|
@@ -1910,7 +1910,7 @@ function Form({ widget, onAction }) {
|
|
|
1910
1910
|
return null;
|
|
1911
1911
|
}
|
|
1912
1912
|
};
|
|
1913
|
-
const
|
|
1913
|
+
const submitLabel = widget.props.submitLabel || widget.actions?.find((a) => a.type === "submit")?.label || widget.actions?.[0]?.label || "Submit";
|
|
1914
1914
|
return /* @__PURE__ */ jsxs4("form", { onSubmit: handleSubmit, className: "border rounded-xl overflow-hidden", children: [
|
|
1915
1915
|
/* @__PURE__ */ jsxs4("div", { className: "p-4", children: [
|
|
1916
1916
|
title && /* @__PURE__ */ jsx6("h3", { className: "!text-lg font-semibold mb-4", children: title }),
|
|
@@ -1922,12 +1922,12 @@ function Form({ widget, onAction }) {
|
|
|
1922
1922
|
renderField(field)
|
|
1923
1923
|
] }, field.name)) })
|
|
1924
1924
|
] }),
|
|
1925
|
-
|
|
1925
|
+
/* @__PURE__ */ jsx6("div", { className: "px-4 pb-4", children: /* @__PURE__ */ jsx6(
|
|
1926
1926
|
"button",
|
|
1927
1927
|
{
|
|
1928
1928
|
type: "submit",
|
|
1929
1929
|
className: "px-3 py-1.5 !text-sm rounded-lg font-medium transition-colors",
|
|
1930
|
-
children:
|
|
1930
|
+
children: submitLabel
|
|
1931
1931
|
}
|
|
1932
1932
|
) })
|
|
1933
1933
|
] });
|