@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 CHANGED
@@ -237,8 +237,8 @@ declare const WIDGET_DEFINITIONS: {
237
237
  readonly example: "@ui:button_group[{\"buttons\": [{\"id\": \"ok\", \"label\": \"OK\"}]}]";
238
238
  };
239
239
  readonly form: {
240
- readonly schema: "title?, fields: [{name, type: \"text\"|\"password\"|\"number\"|\"select\"|\"checkbox\"|\"textarea\"|\"date\", label, required?, placeholder?, options?: [{label, value}]}], actions: [{type, label}]";
241
- readonly example: "@ui:form[{\"title\": \"Settings\", \"fields\": [{\"name\": \"key\", \"type\": \"password\", \"label\": \"API Key\", \"required\": true}], \"actions\": [{\"type\": \"save\", \"label\": \"Save\"}]}]";
240
+ readonly schema: "title?, fields: [{name, type: \"text\"|\"password\"|\"number\"|\"select\"|\"checkbox\"|\"textarea\"|\"date\", label, required?, placeholder?, options?: [{label, value}]}], submitLabel?: string";
241
+ readonly example: "@ui:form[{\"title\": \"Settings\", \"fields\": [{\"name\": \"key\", \"type\": \"password\", \"label\": \"API Key\", \"required\": true}]}]";
242
242
  };
243
243
  readonly table: {
244
244
  readonly schema: "columns: [{key, label}], rows: [{key: value, …}], striped?, compact?";
package/dist/index.d.ts CHANGED
@@ -237,8 +237,8 @@ declare const WIDGET_DEFINITIONS: {
237
237
  readonly example: "@ui:button_group[{\"buttons\": [{\"id\": \"ok\", \"label\": \"OK\"}]}]";
238
238
  };
239
239
  readonly form: {
240
- readonly schema: "title?, fields: [{name, type: \"text\"|\"password\"|\"number\"|\"select\"|\"checkbox\"|\"textarea\"|\"date\", label, required?, placeholder?, options?: [{label, value}]}], actions: [{type, label}]";
241
- readonly example: "@ui:form[{\"title\": \"Settings\", \"fields\": [{\"name\": \"key\", \"type\": \"password\", \"label\": \"API Key\", \"required\": true}], \"actions\": [{\"type\": \"save\", \"label\": \"Save\"}]}]";
240
+ readonly schema: "title?, fields: [{name, type: \"text\"|\"password\"|\"number\"|\"select\"|\"checkbox\"|\"textarea\"|\"date\", label, required?, placeholder?, options?: [{label, value}]}], submitLabel?: string";
241
+ readonly example: "@ui:form[{\"title\": \"Settings\", \"fields\": [{\"name\": \"key\", \"type\": \"password\", \"label\": \"API Key\", \"required\": true}]}]";
242
242
  };
243
243
  readonly table: {
244
244
  readonly schema: "columns: [{key, label}], rows: [{key: value, …}], striped?, compact?";
package/dist/index.js 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}]}], actions: [{type, label}]',
751
- example: '@ui:form[{"title": "Settings", "fields": [{"name": "key", "type": "password", "label": "API Key", "required": true}], "actions": [{"type": "save", "label": "Save"}]}]'
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", "submit"). It is returned to the app when the user clicks the button.
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**: buttons are defined in \`actions\`, do NOT add a separate button_group for form submission.
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 buttons go in actions, not button_group.
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 (_optionalChain([widget, 'access', _24 => _24.actions, 'optionalAccess', _25 => _25[0]]) && onAction) {
1768
+ if (onAction) {
1769
1769
  onAction({
1770
- type: widget.actions[0].type,
1771
- payload: { ...widget.actions[0].payload, formData },
1770
+ type: "submit",
1771
+ payload: { formData },
1772
1772
  widgetId: widget.id,
1773
1773
  timestamp: /* @__PURE__ */ new Date()
1774
1774
  });
@@ -1873,7 +1873,7 @@ function Form({ widget, onAction }) {
1873
1873
  "button",
1874
1874
  {
1875
1875
  type: "button",
1876
- onClick: () => _optionalChain([fileInputRefs, 'access', _26 => _26.current, 'access', _27 => _27[field.name], 'optionalAccess', _28 => _28.click, 'call', _29 => _29()]),
1876
+ onClick: () => _optionalChain([fileInputRefs, 'access', _24 => _24.current, 'access', _25 => _25[field.name], 'optionalAccess', _26 => _26.click, 'call', _27 => _27()]),
1877
1877
  className: "apteva-file-drop w-full px-3 py-3 rounded-lg border-2 border-dashed transition-colors cursor-pointer !text-sm",
1878
1878
  children: field.placeholder || "Click to add files"
1879
1879
  }
@@ -1910,7 +1910,7 @@ function Form({ widget, onAction }) {
1910
1910
  return null;
1911
1911
  }
1912
1912
  };
1913
- const submitAction = _optionalChain([widget, 'access', _30 => _30.actions, 'optionalAccess', _31 => _31.find, 'call', _32 => _32((a) => a.type === "submit")]) || _optionalChain([widget, 'access', _33 => _33.actions, 'optionalAccess', _34 => _34[0]]);
1913
+ const submitLabel = widget.props.submitLabel || _optionalChain([widget, 'access', _28 => _28.actions, 'optionalAccess', _29 => _29.find, 'call', _30 => _30((a) => a.type === "submit"), 'optionalAccess', _31 => _31.label]) || _optionalChain([widget, 'access', _32 => _32.actions, 'optionalAccess', _33 => _33[0], 'optionalAccess', _34 => _34.label]) || "Submit";
1914
1914
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: handleSubmit, className: "border rounded-xl overflow-hidden", children: [
1915
1915
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "p-4", children: [
1916
1916
  title && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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
- submitAction && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "px-4 pb-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1925
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "px-4 pb-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
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: submitAction.label || "Submit"
1930
+ children: submitLabel
1931
1931
  }
1932
1932
  ) })
1933
1933
  ] });