@dappworks/kit 0.4.70 → 0.4.72

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/form.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import { helper } from './chunk-66N3D7MI.mjs';
1
+ import { helper } from './chunk-XAIZMT2F.mjs';
2
2
  import { useStore } from './chunk-DZMNL4BZ.mjs';
3
3
  import { RootStore } from './chunk-HRWHDF2F.mjs';
4
4
  import { _ } from './chunk-MGU3KYGC.mjs';
5
5
  import { cn } from './chunk-6UHBBDKI.mjs';
6
6
  import { __objRest, __spreadValues, __spreadProps } from './chunk-6F7H4PAA.mjs';
7
7
  import React6, { useEffect, useMemo, useState, createRef } from 'react';
8
- import { Modal, ModalContent, ModalHeader, ModalBody, Button, Checkbox, Input, Card, Tabs, Tab } from '@nextui-org/react';
9
- import { ChevronUp, ChevronDown, Check } from 'lucide-react';
8
+ import { Modal, ModalContent, ModalHeader, ModalBody, Checkbox, Input, Button, Textarea, Card, Tabs, Tab } from '@nextui-org/react';
9
+ import { Check, ChevronUp, ChevronDown } from 'lucide-react';
10
10
  import MonacoEditor from '@monaco-editor/react';
11
11
  import validator from '@rjsf/validator-ajv8';
12
12
  import { makeAutoObservable, makeObservable, computed, observable, action, toJS } from 'mobx';
@@ -49,7 +49,6 @@ function CheckboxWidget({
49
49
  label
50
50
  ), description && /* @__PURE__ */ React6.createElement("div", { className: "mt-1 text-xs text-[#A1A1A9] dark:text-[#717179]" }, description));
51
51
  }
52
- var CheckboxWidget_default = CheckboxWidget;
53
52
  function InputWidget(props) {
54
53
  const {
55
54
  onChange,
@@ -80,7 +79,6 @@ function InputWidget(props) {
80
79
  }
81
80
  );
82
81
  }
83
- var InputWidget_default = InputWidget;
84
82
  function SelectWidget(props) {
85
83
  const { onChange, options, label, value, required, disabled, schema } = props;
86
84
  const { className, labelPlacement = "top", placeholder = "Select an option" } = options;
@@ -111,7 +109,6 @@ function SelectWidget(props) {
111
109
  }))
112
110
  ));
113
111
  }
114
- var SelectWidget_default = SelectWidget;
115
112
  var EditorWidget = ({ label, options = {}, value, required, schema, disabled, onChange }) => {
116
113
  const { editorHeight = "200px", readOnly = false, language = "json", jsonStrSpace, languageSelectorOptions = [], onChangeLanguage, onRun, onMount } = options;
117
114
  const [selectedLanguage, setSelectedLanguage] = useState("");
@@ -170,7 +167,6 @@ var EditorWidget = ({ label, options = {}, value, required, schema, disabled, on
170
167
  "Run"
171
168
  ));
172
169
  };
173
- var EditorWidget_default = EditorWidget;
174
170
  var JSONSchemaFormState = class {
175
171
  constructor(args = {}) {
176
172
  this.value = new JSONValue();
@@ -280,14 +276,14 @@ var getFormState = (props, formLayout = {}) => {
280
276
  const uiOptions = formConfigData[k]["ui:options"] || {};
281
277
  if (type === "string" || type === "number") {
282
278
  if ((_a2 = formConfigData[k]) == null ? void 0 : _a2.selectOptions) {
283
- formConfigData[k]["ui:widget"] = SelectWidget_default;
279
+ formConfigData[k]["ui:widget"] = SelectWidget;
284
280
  p[k].selectOptions = formConfigData[k].selectOptions;
285
281
  formConfigData[k]["ui:options"] = __spreadValues({
286
282
  size: "sm"
287
283
  }, uiOptions);
288
284
  } else {
289
285
  if (!formConfigData[k]["ui:widget"]) {
290
- formConfigData[k]["ui:widget"] = InputWidget_default;
286
+ formConfigData[k]["ui:widget"] = InputWidget;
291
287
  formConfigData[k]["ui:options"] = __spreadValues({
292
288
  labelPlacement: "inside",
293
289
  size: "sm"
@@ -296,7 +292,7 @@ var getFormState = (props, formLayout = {}) => {
296
292
  p[k].inputType = "number";
297
293
  }
298
294
  if (helper.json.isJsonString(v)) {
299
- formConfigData[k]["ui:widget"] = EditorWidget_default;
295
+ formConfigData[k]["ui:widget"] = EditorWidget;
300
296
  formConfigData[k]["ui:options"] = __spreadValues({
301
297
  jsonStrSpace: 2
302
298
  }, uiOptions);
@@ -305,7 +301,7 @@ var getFormState = (props, formLayout = {}) => {
305
301
  }
306
302
  }
307
303
  if (type === "boolean") {
308
- formConfigData[k]["ui:widget"] = CheckboxWidget_default;
304
+ formConfigData[k]["ui:widget"] = CheckboxWidget;
309
305
  formConfigData[k]["ui:options"] = __spreadValues({
310
306
  size: "sm"
311
307
  }, uiOptions);
@@ -698,7 +694,7 @@ var GridLayout = (props) => {
698
694
  return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(grid_default, { numItems: $gridColumn != null ? $gridColumn : 1, className: "gap-2" }, Object.keys(formStates).map((key) => {
699
695
  var _a2;
700
696
  const layout = formLayout[key];
701
- return /* @__PURE__ */ React6.createElement(col_default, { numColSpan: (_a2 = layout == null ? void 0 : layout.colSpan) != null ? _a2 : 1, key, id: `form-${key}` }, /* @__PURE__ */ React6.createElement(Card, { className: cn("h-full m-0 p-4 shadow-sm border-1", layout == null ? void 0 : layout.cardCss) }, /* @__PURE__ */ React6.createElement("div", { className: cn("mb-2 font-bold text-center", layout == null ? void 0 : layout.titleBoxCss) }, (layout == null ? void 0 : layout.title) || key), /* @__PURE__ */ React6.createElement(JSONSchemaForm, { formState: formStates[key] }, (layout == null ? void 0 : layout.submitButtonProps) && /* @__PURE__ */ React6.createElement(SubmitButton, { formKey: key, formState: formStates[key], buttonProps: layout.submitButtonProps }))));
697
+ return /* @__PURE__ */ React6.createElement(col_default, { numColSpan: (_a2 = layout == null ? void 0 : layout.colSpan) != null ? _a2 : 1, key, id: `form-${key}` }, /* @__PURE__ */ React6.createElement(Card, { className: cn("h-full m-0 p-4 shadow-sm border dark:border-[#3e3e3e]", layout == null ? void 0 : layout.cardCss) }, /* @__PURE__ */ React6.createElement("div", { className: cn("mb-2 font-bold text-center", layout == null ? void 0 : layout.titleBoxCss) }, (layout == null ? void 0 : layout.title) || key), /* @__PURE__ */ React6.createElement(JSONSchemaForm, { formState: formStates[key] }, (layout == null ? void 0 : layout.submitButtonProps) && /* @__PURE__ */ React6.createElement(SubmitButton, { formKey: key, formState: formStates[key], buttonProps: layout.submitButtonProps }))));
702
698
  })), (onBatchSubmit || (batchSubmitButtonProps == null ? void 0 : batchSubmitButtonProps.onBatchSubmit)) && /* @__PURE__ */ React6.createElement("div", { className: "w-full flex" }, /* @__PURE__ */ React6.createElement(BatchSubmitButton, { formStates, onSubmit: onBatchSubmit, buttonProps: batchSubmitButtonProps })));
703
699
  };
704
700
  var CollapsibleBox = ({ formKey, title, titleBoxCss, formState, submitButtonProps }) => {
@@ -805,9 +801,31 @@ var JSONForm = (props) => {
805
801
  /* @__PURE__ */ React6.createElement(Component, __spreadValues({}, props))
806
802
  );
807
803
  };
804
+ function TextareaWidget(props) {
805
+ const { onChange, options, label, value, required, disabled, schema } = props;
806
+ const { className, labelPlacement = "inside", size = "md", minRows = 2, maxRows = 8 } = options;
807
+ const placeholder = props.placeholder || options.placeholder;
808
+ return /* @__PURE__ */ React6.createElement(
809
+ Textarea,
810
+ {
811
+ className: cn("w-full", className),
812
+ label,
813
+ placeholder,
814
+ value,
815
+ isRequired: required,
816
+ isDisabled: disabled,
817
+ minRows,
818
+ maxRows,
819
+ size,
820
+ labelPlacement,
821
+ description: schema.description || "",
822
+ onChange: (e) => onChange(e.target.value)
823
+ }
824
+ );
825
+ }
808
826
  var JSONViewModal = observer(() => {
809
827
  const rootStore = useStore();
810
- const complexFormModal = rootStore.get(FormPlugin);
828
+ const complexFormModal = rootStore.get(ComplexFormModalStore);
811
829
  const { formData, isOpen } = complexFormModal;
812
830
  const store = useLocalObservable(() => ({
813
831
  isMobile: false
@@ -871,9 +889,9 @@ var JSONViewModal = observer(() => {
871
889
  return ModalMemo;
872
890
  });
873
891
  var Provider_default = JSONViewModal;
874
- var FormPlugin = class {
892
+ var ComplexFormModalStore = class {
875
893
  constructor(args) {
876
- this.sid = "FormPlugin";
894
+ this.sid = "ComplexFormModalStore";
877
895
  this.provider = () => /* @__PURE__ */ React6.createElement(Provider_default, null);
878
896
  this.isOpen = false;
879
897
  this.title = "";
@@ -908,7 +926,7 @@ var FormPlugin = class {
908
926
  };
909
927
  async function getComplexFormData(v) {
910
928
  return new Promise((resolve, reject) => {
911
- const complexFormModal = RootStore.Get(FormPlugin);
929
+ const complexFormModal = RootStore.Get(ComplexFormModalStore);
912
930
  complexFormModal.setData(__spreadProps(__spreadValues({}, v), {
913
931
  isOpen: true
914
932
  }));
@@ -960,7 +978,6 @@ var FormModalStore = class {
960
978
  this.provider = () => /* @__PURE__ */ React6.createElement(Provider_default2, null);
961
979
  this.isOpen = false;
962
980
  this.title = "";
963
- //@ts-ignore
964
981
  this.form = null;
965
982
  this.className = "";
966
983
  this.modalSize = "md";
@@ -1026,11 +1043,11 @@ function getFormState2({
1026
1043
  }
1027
1044
  if (type === "string" || type === "number") {
1028
1045
  if ((_a = metadata[k]) == null ? void 0 : _a.selectOptions) {
1029
- metadata[k]["ui:widget"] = SelectWidget_default;
1046
+ metadata[k]["ui:widget"] = SelectWidget;
1030
1047
  p[k].selectOptions = metadata[k].selectOptions;
1031
1048
  } else {
1032
1049
  if (!metadata[k]["ui:widget"]) {
1033
- metadata[k]["ui:widget"] = InputWidget_default;
1050
+ metadata[k]["ui:widget"] = InputWidget;
1034
1051
  metadata[k]["ui:options"] = {
1035
1052
  // labelPlacement: 'outside-left',
1036
1053
  size: "sm"
@@ -1042,7 +1059,7 @@ function getFormState2({
1042
1059
  }
1043
1060
  }
1044
1061
  if (type === "boolean") {
1045
- metadata[k]["ui:widget"] = CheckboxWidget_default;
1062
+ metadata[k]["ui:widget"] = CheckboxWidget;
1046
1063
  metadata[k]["ui:options"] = {
1047
1064
  size: "sm"
1048
1065
  };
@@ -1147,6 +1164,6 @@ _JSONViewPlugin.JSONView = (props) => {
1147
1164
  };
1148
1165
  var JSONViewPlugin = _JSONViewPlugin;
1149
1166
 
1150
- export { FormModalStore, FormPlugin, JSONForm, JSONSchemaForm, JSONViewPlugin, getComplexFormData, getFormData, getFormState2 as getFormState, getSimpleFormData };
1167
+ export { CheckboxWidget, ComplexFormModalStore, EditorWidget, FormModalStore, InputWidget, JSONForm, JSONSchemaForm, JSONViewPlugin, SelectWidget, TextareaWidget, getComplexFormData, getFormData, getFormState2 as getFormState, getSimpleFormData };
1151
1168
  //# sourceMappingURL=out.js.map
1152
1169
  //# sourceMappingURL=form.mjs.map