@dappworks/kit 0.4.140 → 0.4.141

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.
Files changed (42) hide show
  1. package/dist/{PromiseState-yojg0WLR.d.ts → PromiseState-b0cc408e.d.ts} +3 -3
  2. package/dist/aiem.d.mts +1 -1
  3. package/dist/aiem.mjs +21 -5
  4. package/dist/{chunk-R4SQKVDQ.mjs → chunk-6F7H4PAA.mjs} +1 -1
  5. package/dist/{chunk-SVPD6PC6.mjs → chunk-7FF4BCFW.mjs} +4 -4
  6. package/dist/{chunk-WS43BV7Y.mjs → chunk-DZMNL4BZ.mjs} +2 -2
  7. package/dist/{chunk-XJMRAPHI.mjs → chunk-HRWHDF2F.mjs} +7 -7
  8. package/dist/{chunk-XJMRAPHI.mjs.map → chunk-HRWHDF2F.mjs.map} +1 -1
  9. package/dist/{chunk-QWHU3HBK.mjs → chunk-PPYYRQDD.mjs} +2 -2
  10. package/dist/{chunk-HRYH37UI.mjs → chunk-WT2ARRCR.mjs} +2 -2
  11. package/dist/{chunk-AIZ7XDNV.mjs → chunk-WYGQ3Y4R.mjs} +14 -14
  12. package/dist/chunk-WYGQ3Y4R.mjs.map +1 -0
  13. package/dist/dev.d.mts +1 -1
  14. package/dist/dev.mjs +2 -2
  15. package/dist/experimental.d.mts +2 -2
  16. package/dist/experimental.mjs +3 -3
  17. package/dist/form.d.mts +5 -5
  18. package/dist/form.mjs +4 -4
  19. package/dist/{index-CUKoRIdy.d.ts → index-38be834f.d.ts} +1 -1
  20. package/dist/index.d.mts +4 -4
  21. package/dist/index.mjs +5 -5
  22. package/dist/inspector.d.mts +1 -1
  23. package/dist/inspector.mjs +1 -1
  24. package/dist/jsontable.d.mts +2 -2
  25. package/dist/jsontable.mjs +4 -4
  26. package/dist/metrics.d.mts +1 -1
  27. package/dist/metrics.mjs +4 -4
  28. package/dist/plugins.d.mts +33 -7
  29. package/dist/plugins.mjs +163 -34
  30. package/dist/plugins.mjs.map +1 -1
  31. package/dist/{root-C3lZnoCI.d.ts → root-766ae985.d.ts} +1 -1
  32. package/dist/ui.mjs +3 -3
  33. package/dist/utils.d.mts +3 -8
  34. package/dist/utils.mjs +1 -1
  35. package/package.json +1 -1
  36. package/dist/chunk-AIZ7XDNV.mjs.map +0 -1
  37. /package/dist/{PaginationState-Bmrrw0ky.d.ts → PaginationState-c19e621a.d.ts} +0 -0
  38. /package/dist/{chunk-R4SQKVDQ.mjs.map → chunk-6F7H4PAA.mjs.map} +0 -0
  39. /package/dist/{chunk-SVPD6PC6.mjs.map → chunk-7FF4BCFW.mjs.map} +0 -0
  40. /package/dist/{chunk-WS43BV7Y.mjs.map → chunk-DZMNL4BZ.mjs.map} +0 -0
  41. /package/dist/{chunk-QWHU3HBK.mjs.map → chunk-PPYYRQDD.mjs.map} +0 -0
  42. /package/dist/{chunk-HRYH37UI.mjs.map → chunk-WT2ARRCR.mjs.map} +0 -0
package/dist/plugins.mjs CHANGED
@@ -1,11 +1,12 @@
1
1
  export { ToastPlugin } from './chunk-4YCP5CJ4.mjs';
2
2
  import { getStyle } from './chunk-5SFAINN6.mjs';
3
- import { useStore, rootStore } from './chunk-WS43BV7Y.mjs';
4
- import './chunk-XJMRAPHI.mjs';
3
+ import { useStore, rootStore } from './chunk-DZMNL4BZ.mjs';
4
+ import './chunk-HRWHDF2F.mjs';
5
5
  import './chunk-MGU3KYGC.mjs';
6
- import { __spreadValues, __spreadProps } from './chunk-R4SQKVDQ.mjs';
7
- import { makeAutoObservable } from 'mobx';
8
- import React from 'react';
6
+ import { cn } from './chunk-WYGQ3Y4R.mjs';
7
+ import { __spreadValues, __spreadProps } from './chunk-6F7H4PAA.mjs';
8
+ import { makeAutoObservable, makeObservable } from 'mobx';
9
+ import React5 from 'react';
9
10
  import { observer } from 'mobx-react-lite';
10
11
  import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button, Spinner } from '@nextui-org/react';
11
12
  import { Check, X } from 'lucide-react';
@@ -14,7 +15,7 @@ var ConfirmModal = observer(() => {
14
15
  const rootStore2 = useStore();
15
16
  const confirmStore = rootStore2.get(ConfirmStore);
16
17
  const { isOpen, title, description, size, className, classNames, cancelText, okText } = confirmStore;
17
- return /* @__PURE__ */ React.createElement(
18
+ return /* @__PURE__ */ React5.createElement(
18
19
  Modal,
19
20
  {
20
21
  isOpen,
@@ -27,7 +28,7 @@ var ConfirmModal = observer(() => {
27
28
  }
28
29
  }
29
30
  },
30
- /* @__PURE__ */ React.createElement(ModalContent, { className: "max-h-screen overflow-auto" }, () => /* @__PURE__ */ React.createElement(React.Fragment, null, title && /* @__PURE__ */ React.createElement(ModalHeader, { className: "flex flex-col gap-1" }, title), /* @__PURE__ */ React.createElement(ModalBody, null, /* @__PURE__ */ React.createElement("div", null, description)), /* @__PURE__ */ React.createElement(ModalFooter, null, /* @__PURE__ */ React.createElement(
31
+ /* @__PURE__ */ React5.createElement(ModalContent, { className: "max-h-screen overflow-auto" }, () => /* @__PURE__ */ React5.createElement(React5.Fragment, null, title && /* @__PURE__ */ React5.createElement(ModalHeader, { className: "flex flex-col gap-1" }, title), /* @__PURE__ */ React5.createElement(ModalBody, null, /* @__PURE__ */ React5.createElement("div", null, description)), /* @__PURE__ */ React5.createElement(ModalFooter, null, /* @__PURE__ */ React5.createElement(
31
32
  Button,
32
33
  {
33
34
  color: "primary",
@@ -38,7 +39,7 @@ var ConfirmModal = observer(() => {
38
39
  }
39
40
  },
40
41
  cancelText
41
- ), /* @__PURE__ */ React.createElement(
42
+ ), /* @__PURE__ */ React5.createElement(
42
43
  Button,
43
44
  {
44
45
  color: "primary",
@@ -55,7 +56,7 @@ var Provider_default = ConfirmModal;
55
56
  var ConfirmStore = class {
56
57
  constructor() {
57
58
  this.sid = "ConfirmStore";
58
- this.provider = () => /* @__PURE__ */ React.createElement(Provider_default, null);
59
+ this.provider = () => /* @__PURE__ */ React5.createElement(Provider_default, null);
59
60
  this.isOpen = false;
60
61
  this.title = "";
61
62
  this.description = "";
@@ -93,7 +94,7 @@ var Dialog = observer(() => {
93
94
  const modal = rootStore2.get(DialogStore);
94
95
  const { className, classNames, isOpen, placement, title, size, content, isDismissable } = modal;
95
96
  const Content = typeof content === "function" ? content : () => content;
96
- return /* @__PURE__ */ React.createElement(
97
+ return /* @__PURE__ */ React5.createElement(
97
98
  Modal,
98
99
  {
99
100
  isOpen,
@@ -108,7 +109,7 @@ var Dialog = observer(() => {
108
109
  classNames,
109
110
  isDismissable
110
111
  },
111
- /* @__PURE__ */ React.createElement(ModalContent, { className: "max-h-screen overflow-auto" }, () => /* @__PURE__ */ React.createElement(React.Fragment, null, title && /* @__PURE__ */ React.createElement(ModalHeader, { className: "flex flex-col gap-1" }, title), /* @__PURE__ */ React.createElement(ModalBody, null, /* @__PURE__ */ React.createElement(Content, null))))
112
+ /* @__PURE__ */ React5.createElement(ModalContent, { className: "max-h-screen overflow-auto" }, () => /* @__PURE__ */ React5.createElement(React5.Fragment, null, title && /* @__PURE__ */ React5.createElement(ModalHeader, { className: "flex flex-col gap-1" }, title), /* @__PURE__ */ React5.createElement(ModalBody, null, /* @__PURE__ */ React5.createElement(Content, null))))
112
113
  );
113
114
  });
114
115
  var Provider_default2 = Dialog;
@@ -117,7 +118,7 @@ var Provider_default2 = Dialog;
117
118
  var DialogStore = class _DialogStore {
118
119
  constructor(args) {
119
120
  this.sid = "DialogStore";
120
- this.provider = () => /* @__PURE__ */ React.createElement(Provider_default2, null);
121
+ this.provider = () => /* @__PURE__ */ React5.createElement(Provider_default2, null);
121
122
  this.isOpen = false;
122
123
  this.title = "";
123
124
  this.size = "md";
@@ -152,39 +153,97 @@ var DialogStore = class _DialogStore {
152
153
  rootStore.get(_DialogStore).close();
153
154
  }
154
155
  };
155
- var DialogContent = observer(({ group, groupOptions }) => {
156
- return /* @__PURE__ */ React.createElement("div", { className: "pb-4 space-y-4" }, group.map((promiseState, index) => {
156
+ var DialogContentUI = observer(({
157
+ group,
158
+ groupOptions,
159
+ className,
160
+ itemClassName,
161
+ numberClassName,
162
+ spinnerProps = {
163
+ size: "sm"
164
+ },
165
+ SuccessIcon,
166
+ FailureIcon
167
+ }) => {
168
+ return /* @__PURE__ */ React5.createElement("div", { className: cn("space-y-4", className) }, group.map((promiseState, index) => {
157
169
  const uiOptions = groupOptions[index];
158
- return /* @__PURE__ */ React.createElement("div", { key: index, className: "w-full flex items-center justify-between" }, uiOptions == null ? void 0 : uiOptions.title, /* @__PURE__ */ React.createElement("div", null, promiseState.loading.value ? /* @__PURE__ */ React.createElement(Spinner, { size: "sm" }) : /* @__PURE__ */ React.createElement(React.Fragment, null, promiseState.value && /* @__PURE__ */ React.createElement(Check, { size: 20, color: "#605BFF" }), promiseState.errMsg && /* @__PURE__ */ React.createElement(X, { size: 20, color: "red" }))));
170
+ const no = index + 1;
171
+ return /* @__PURE__ */ React5.createElement("div", { key: index, className: cn("w-full flex items-center justify-between", itemClassName) }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center justify-between" }, /* @__PURE__ */ React5.createElement("div", { className: cn("w-6 h-6 flex items-center justify-center text-sm rounded-full border-2 border-[#000000] dark:border-[#cacbcb] mr-2", numberClassName) }, no), uiOptions == null ? void 0 : uiOptions.title), promiseState.loading.value ? /* @__PURE__ */ React5.createElement(Spinner, __spreadValues({}, spinnerProps)) : /* @__PURE__ */ React5.createElement(React5.Fragment, null, promiseState.value && (SuccessIcon || /* @__PURE__ */ React5.createElement(Check, { size: 20, color: "#605BFF" })), promiseState.errMsg && (FailureIcon || /* @__PURE__ */ React5.createElement(X, { size: 20, color: "red" }))));
172
+ }));
173
+ });
174
+ var StepUI = observer(({
175
+ group,
176
+ groupOptions,
177
+ currentCallStepNo,
178
+ className,
179
+ itemClassName,
180
+ activatedItemClassName = "",
181
+ numberClassName,
182
+ activatedNumberClassName = "",
183
+ spinnerProps = {
184
+ size: "sm"
185
+ },
186
+ SuccessIcon,
187
+ FailureIcon
188
+ }) => {
189
+ return /* @__PURE__ */ React5.createElement("div", { className: cn("space-y-4", className) }, group.map((promiseState, index) => {
190
+ const uiOptions = groupOptions[index];
191
+ const no = index + 1;
192
+ return /* @__PURE__ */ React5.createElement(
193
+ "div",
194
+ {
195
+ key: index,
196
+ className: cn(
197
+ "w-full flex items-center justify-between text-[#909091] dark:text-[#6b6c6c]",
198
+ no <= currentCallStepNo ? `text-[#000] dark:text-[#fff] ${activatedItemClassName}` : "",
199
+ itemClassName
200
+ )
201
+ },
202
+ /* @__PURE__ */ React5.createElement("div", { className: "flex items-center justify-between" }, /* @__PURE__ */ React5.createElement(
203
+ "div",
204
+ {
205
+ className: cn(
206
+ "w-6 h-6 flex items-center justify-center text-sm rounded-full border-2 border-[#909091] dark:border-[#6b6c6c] mr-2",
207
+ no <= currentCallStepNo ? `border-[#000] dark:border-[#fff] ${activatedNumberClassName}` : "",
208
+ numberClassName
209
+ )
210
+ },
211
+ no
212
+ ), uiOptions == null ? void 0 : uiOptions.title),
213
+ promiseState.loading.value ? /* @__PURE__ */ React5.createElement(Spinner, __spreadValues({}, spinnerProps)) : /* @__PURE__ */ React5.createElement(React5.Fragment, null, promiseState.value && no <= currentCallStepNo && (SuccessIcon || /* @__PURE__ */ React5.createElement(Check, { size: 20, color: "#605BFF" })), promiseState.errMsg && no <= currentCallStepNo && (FailureIcon || /* @__PURE__ */ React5.createElement(X, { size: 20, color: "red" })))
214
+ );
159
215
  }));
160
216
  });
161
-
162
- // module/PromiseStateGroup/index.tsx
163
217
  var PromiseStateGroup = class {
164
218
  constructor({ group, groupOptions = [] }) {
165
219
  this.group = [];
166
220
  this.groupOptions = [];
221
+ this.currentCallStepNo = 1;
222
+ group.forEach((p) => {
223
+ Object.assign(p, {
224
+ autoAlert: false,
225
+ value: p.defaultValue,
226
+ errMsg: ""
227
+ });
228
+ });
167
229
  Object.assign(this, {
168
230
  group,
169
231
  groupOptions
170
232
  });
233
+ makeObservable(this, {
234
+ currentCallStepNo: true
235
+ });
171
236
  }
172
237
  async call() {
173
238
  let result = [];
174
239
  let errMsg = "";
175
- this.group.forEach((p) => {
176
- Object.assign(p, {
177
- autoAlert: false,
178
- value: p.defaultValue,
179
- errMsg: ""
180
- });
181
- });
182
240
  for (let i = 0; i < this.group.length; i++) {
241
+ this.currentCallStepNo = i + 1;
183
242
  const promiseState = this.group[i];
184
- const options = this.groupOptions[i];
185
- if (promiseState && options) {
243
+ if (promiseState) {
186
244
  try {
187
- const args = options.args || [];
245
+ const options = this.groupOptions[i];
246
+ const args = (options == null ? void 0 : options.args) || [];
188
247
  const data = await promiseState.call(...args);
189
248
  result.push(data);
190
249
  } catch (e) {
@@ -202,19 +261,89 @@ var PromiseStateGroup = class {
202
261
  errMsg
203
262
  };
204
263
  }
205
- async ui(dialogOptions) {
264
+ showDialog(dialogOptions, dialogContentOptions) {
206
265
  DialogStore.show(__spreadValues({
207
266
  title: "",
208
267
  size: "md",
209
- content: /* @__PURE__ */ React.createElement(DialogContent, { group: this.group, groupOptions: this.groupOptions }),
210
- isDismissable: false
211
- }, dialogOptions || {}));
212
- const res = await this.call();
213
- return res;
268
+ isDismissable: false,
269
+ content: /* @__PURE__ */ React5.createElement(
270
+ DialogContentUI,
271
+ __spreadValues({
272
+ group: this.group,
273
+ groupOptions: this.groupOptions
274
+ }, dialogContentOptions)
275
+ )
276
+ }, dialogOptions));
277
+ return this;
214
278
  }
215
- closeUI() {
279
+ closeDialog() {
216
280
  DialogStore.close();
217
281
  }
282
+ async stepCall(stepNo) {
283
+ const index = stepNo - 1;
284
+ if (index < 0 || index >= this.group.length) {
285
+ return {
286
+ result: null,
287
+ errMsg: "Invalid step number"
288
+ };
289
+ }
290
+ const prePromiseState = this.group[index - 1];
291
+ if (prePromiseState && prePromiseState.errMsg) {
292
+ return {
293
+ result: null,
294
+ errMsg: prePromiseState.errMsg
295
+ };
296
+ }
297
+ this.currentCallStepNo = stepNo;
298
+ const promiseState = this.group[index];
299
+ if (promiseState && !promiseState.loading.value) {
300
+ const options = this.groupOptions[index];
301
+ const args = (options == null ? void 0 : options.args) || [];
302
+ try {
303
+ const result = await promiseState.call(...args);
304
+ return {
305
+ result,
306
+ errMsg: ""
307
+ };
308
+ } catch (e) {
309
+ let errMsg = e.message;
310
+ if ((errMsg == null ? void 0 : errMsg.includes("User rejected the request")) || String(e).toLowerCase().includes("user rejected")) {
311
+ errMsg = "User rejected the request";
312
+ }
313
+ promiseState.errMsg = errMsg;
314
+ return {
315
+ result: null,
316
+ errMsg
317
+ };
318
+ }
319
+ }
320
+ }
321
+ onNext() {
322
+ if (this.currentCallStepNo < this.group.length) {
323
+ this.currentCallStepNo += 1;
324
+ }
325
+ }
326
+ onPrevious() {
327
+ if (this.currentCallStepNo > 1) {
328
+ const index = this.currentCallStepNo - 1;
329
+ const promiseState = this.group[index];
330
+ if (promiseState) {
331
+ promiseState.value = "";
332
+ promiseState.errMsg = "";
333
+ }
334
+ this.currentCallStepNo -= 1;
335
+ }
336
+ }
337
+ render(props) {
338
+ return /* @__PURE__ */ React5.createElement(
339
+ StepUI,
340
+ __spreadValues({
341
+ group: this.group,
342
+ groupOptions: this.groupOptions,
343
+ currentCallStepNo: this.currentCallStepNo
344
+ }, props)
345
+ );
346
+ }
218
347
  };
219
348
 
220
349
  export { ConfirmStore, DialogStore, PromiseStateGroup };
@@ -1 +1 @@
1
- {"version":3,"sources":["../module/Confirm/index.tsx","../module/Confirm/Provider.tsx","../module/Dialog/index.tsx","../module/Dialog/Provider.tsx","../module/PromiseStateGroup/index.tsx","../module/PromiseStateGroup/ui.tsx"],"names":["rootStore","React","makeAutoObservable","Modal","ModalBody","ModalContent","ModalHeader","observer","Provider_default"],"mappings":";;;;;;;;;;;;;;;;;;AACA,SAAS,0BAA0B;;;ACDnC,OAAO,WAAW;AAClB,SAAS,gBAAgB;AACzB,SAAS,QAAQ,OAAO,WAAW,cAAc,aAAa,mBAAmB;AAIjF,IAAM,eAAe,SAAS,MAAM;AAClC,QAAMA,aAAY,SAAS;AAC3B,QAAM,eAAeA,WAAU,IAAI,YAAY;AAC/C,QAAM,EAAE,Q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M,GAAG,eAAsC;AAC7C,gBAAY,KAAK;AAAA,MACf,OAAO;AAAA,MACP,MAAM;AAAA,MACN,SAAS,gBAAAA,OAAA,cAAC,iBAAc,OAAO,KAAK,OAAO,cAAc,KAAK,cAAc;AAAA,MAC5E,eAAe;AAAA,OACX,iBAAiB,CAAC,EACvB;AAED,UAAM,MAAM,MAAM,KAAK,KAAK;AAC5B,WAAO;AAAA,EACT;AAAA,EAEA,UAAU;AACR,gBAAY,MAAM;AAAA,EACpB;AACF","sourcesContent":["import { Store } from \"../../store/standard/base\";\nimport { makeAutoObservable } from \"mobx\";\nimport Provider from \"./Provider\";\nimport React from \"react\";\nimport { ModalSlots, SlotsToClasses } from \"@nextui-org/react\";\nimport { getStyle, ThemeType } from \"../../themes\";\n\nexport class ConfirmStore implements Store {\n sid = 'ConfirmStore';\n provider = () => <Provider />;\n\n isOpen: boolean = false;\n title?: string = '';\n description?: string = '';\n size: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full' | 'xs' | '3xl' | '4xl' | '5xl' = 'md';\n className: string = '';\n classNames?: SlotsToClasses<ModalSlots>;\n theme: ThemeType = \"default\";\n cancelText?: string = 'Cancel';\n okText?: string = 'Apply';\n\n constructor() {\n makeAutoObservable(this);\n }\n\n toggleOpen(val: boolean) {\n this.isOpen = val;\n }\n\n onOk() { }\n\n onCancel() { }\n\n show(confirmProps: Partial<ConfirmStore>) {\n const modalStyle = getStyle(confirmProps?.theme || 'default', 'Modal');\n const classNames = {\n ...modalStyle.classNames,\n ...confirmProps?.classNames\n }\n Object.assign(this, confirmProps, { classNames });\n\n this.toggleOpen(true);\n }\n\n close() {\n this.isOpen = false;\n this.title = '';\n this.description = '';\n this.size = 'md';\n this.cancelText = 'Cancel';\n this.okText = 'Apply';\n }\n}\n","import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { Button, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader } from '@nextui-org/react';\nimport { useStore } from \"../../store\";\nimport { ConfirmStore } from \".\";\n\nconst ConfirmModal = observer(() => {\n const rootStore = useStore();\n const confirmStore = rootStore.get(ConfirmStore);\n const { isOpen, title, description, size, className, classNames, cancelText, okText } = confirmStore;\n return (\n <Modal\n isOpen={isOpen}\n size={size}\n className={className}\n classNames={classNames}\n onOpenChange={(open: boolean) => {\n if (!open) {\n confirmStore.close();\n }\n }}\n >\n <ModalContent className=\"max-h-screen overflow-auto\">\n {() => (\n <>\n {title && <ModalHeader className=\"flex flex-col gap-1\">{title}</ModalHeader>}\n <ModalBody>\n <div>{description}</div>\n </ModalBody>\n <ModalFooter>\n <Button\n color=\"primary\"\n variant=\"flat\"\n onClick={() => {\n confirmStore.close();\n confirmStore.onCancel();\n }}\n >\n {cancelText}\n </Button>\n <Button\n color=\"primary\"\n onPress={() => {\n confirmStore.close();\n confirmStore.onOk();\n }}\n >\n {okText}\n </Button>\n </ModalFooter>\n </>\n )}\n </ModalContent>\n </Modal>\n );\n});\n\nexport default ConfirmModal;","import React from \"react\";\nimport { makeAutoObservable } from \"mobx\";\nimport { rootStore } from \"../../store\";\nimport { Store } from \"../../store/standard/base\";\nimport Provider from \"./Provider\";\nimport { ModalSlots, SlotsToClasses } from \"@nextui-org/react\";\nimport { getStyle, ThemeType } from \"../../themes\";\n\nexport class DialogStore implements Store {\n sid = \"DialogStore\";\n provider = () => <Provider />;\n\n isOpen = false;\n placement: \"center\" | \"auto\" | \"top\" | \"bottom\" | \"top-center\" | \"bottom-center\";\n title = \"\";\n size: \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\" | \"full\" | \"xs\" | \"3xl\" | \"4xl\" | \"5xl\" = \"md\";\n className: string = \"\";\n classNames?: SlotsToClasses<ModalSlots>;\n theme: ThemeType = \"default\";\n content: React.ReactNode | ((props: any) => React.ReactNode) = \"\";\n isDismissable = true;\n\n constructor(args?: Partial<DialogStore>) {\n const modalStyle = getStyle(args?.theme || 'default', 'Modal');\n const classNames = {\n ...modalStyle.classNames,\n ...args?.classNames\n }\n Object.assign(this, args, { classNames });\n makeAutoObservable(this);\n }\n\n\n setData(v: Partial<DialogStore>) {\n Object.assign(this, v);\n }\n\n close() {\n this.isOpen = false;\n this.title = \"\";\n this.content = \"\";\n this.size = \"md\";\n this.isDismissable = true;\n }\n\n static show(v: Partial<DialogStore>) {\n const modalStyle = getStyle(v?.theme || 'default', 'Modal');\n const classNames = {\n ...modalStyle.classNames,\n ...v?.classNames\n }\n rootStore.get(DialogStore).setData({\n ...v,\n classNames,\n isOpen: true,\n\n });\n }\n\n static close() {\n rootStore.get(DialogStore).close();\n }\n}\n","import React from \"react\";\nimport { Modal, ModalBody, ModalContent, ModalHeader } from \"@nextui-org/react\";\nimport { observer } from \"mobx-react-lite\";\nimport { DialogStore } from \".\";\nimport { useStore } from \"../../store/index\";\n\nconst Dialog = observer(() => {\n const rootStore = useStore();\n const modal = rootStore.get(DialogStore);\n const { className, classNames, isOpen, placement, title, size, content, isDismissable } = modal;\n const Content = typeof content === 'function' ? content : () => content;\n return (\n <Modal\n isOpen={isOpen}\n size={size}\n placement={placement}\n onOpenChange={(open: boolean) => {\n if (!open) {\n modal.close();\n }\n }}\n className={className}\n classNames={classNames}\n isDismissable={isDismissable}\n >\n <ModalContent className=\"max-h-screen overflow-auto\">\n {() => (\n <>\n {title && <ModalHeader className=\"flex flex-col gap-1\">{title}</ModalHeader>}\n <ModalBody>\n <Content />\n </ModalBody>\n </>\n )}\n </ModalContent>\n </Modal >\n );\n});\n\nexport default Dialog;","import React from 'react';\nimport { PromiseState } from '../../store/standard/PromiseState';\nimport { DialogStore } from '../Dialog';\nimport { DialogContent, GroupOptions } from './ui';\n\nexport class PromiseStateGroup {\n group: PromiseState<any, any>[] = [];\n groupOptions: GroupOptions = [];\n\n constructor({ group, groupOptions = [] }: { group: PromiseState<any, any>[]; groupOptions: GroupOptions }) {\n Object.assign(this, {\n group,\n groupOptions,\n });\n }\n\n async call() {\n let result: any[] = [];\n let errMsg: string = '';\n this.group.forEach((p) => {\n Object.assign(p, {\n autoAlert: false,\n value: p.defaultValue,\n errMsg: '',\n });\n });\n for (let i = 0; i < this.group.length; i++) {\n const promiseState = this.group[i];\n const options = this.groupOptions[i];\n if (promiseState && options) {\n try {\n const args = options.args || [];\n const data = await promiseState.call(...args);\n result.push(data);\n } catch (e) {\n errMsg = e.message;\n if (errMsg?.includes('User rejected the request') || String(e).toLowerCase().includes('user rejected')) {\n errMsg = 'User rejected the request';\n }\n promiseState.errMsg = errMsg;\n break;\n }\n }\n }\n return {\n result,\n errMsg,\n };\n }\n\n async ui(dialogOptions?: Partial<DialogStore>) {\n DialogStore.show({\n title: '',\n size: 'md',\n content: <DialogContent group={this.group} groupOptions={this.groupOptions} />,\n isDismissable: false,\n ...(dialogOptions || {}),\n });\n\n const res = await this.call();\n return res;\n }\n\n closeUI() {\n DialogStore.close();\n }\n}\n\n","import React from 'react';\nimport { PromiseState } from '../../store/standard/PromiseState';\nimport { Spinner } from '@nextui-org/react';\nimport { Check, X } from 'lucide-react';\nimport { observer } from 'mobx-react-lite';\n\nexport type GroupOptions = {\n args?: any[];\n title: React.ReactNode;\n}[];\n\nexport const DialogContent = observer(({ group, groupOptions }: { group: PromiseState<any, any>[]; groupOptions: GroupOptions }) => {\n return (\n <div className=\"pb-4 space-y-4\">\n {group.map((promiseState, index) => {\n const uiOptions = groupOptions[index];\n return (\n <div key={index} className=\"w-full flex items-center justify-between\">\n {uiOptions?.title}\n <div>\n {promiseState.loading.value ? (\n <Spinner size=\"sm\" />\n ) : (\n <>\n {promiseState.value && <Check size={20} color=\"#605BFF\" />}\n {promiseState.errMsg && <X size={20} color=\"red\" />}\n </>\n )}\n </div>\n </div>\n );\n })}\n </div>\n );\n});\n"]}
1
+ {"version":3,"sources":["../module/Confirm/index.tsx","../module/Confirm/Provider.tsx","../module/Dialog/index.tsx","../module/Dialog/Provider.tsx","../module/PromiseStateGroup/index.tsx","../module/PromiseStateGroup/ui.tsx"],"names":["rootStore","React","makeAutoObservable","Modal","ModalBody","ModalContent","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,CAAC,aAAa,QAAQ,OAAO;AAC/C,YAAM,UAAU,KAAK,aAAa,KAAK;AACvC,YAAM,QAAO,mCAAS,SAAQ,CAAC;AAC/B,UAAI;AACF,cAAM,SAAS,MAAM,aAAa,KAAK,GAAG,IAAI;AAC9C,eAAO;AAAA,UACL;AAAA,UACA,QAAQ;AAAA,QACV;AAAA,MACF,SAAS,GAAG;AACV,YAAI,SAAS,EAAE;AACf,aAAI,iCAAQ,SAAS,iCAAgC,OAAO,CAAC,EAAE,YAAY,EAAE,SAAS,eAAe,GAAG;AACtG,mBAAS;AAAA,QACX;AACA,qBAAa,SAAS;AACtB,eAAO;AAAA,UACL,QAAQ;AAAA,UACR;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,SAAS;AACP,QAAI,KAAK,oBAAoB,KAAK,MAAM,QAAQ;AAC9C,WAAK,qBAAqB;AAAA,IAC5B;AAAA,EACF;AAAA,EAEA,aAAa;AACX,QAAI,KAAK,oBAAoB,GAAG;AAG9B,YAAM,QAAQ,KAAK,oBAAoB;AACvC,YAAM,eAAe,KAAK,MAAM,KAAK;AACrC,UAAI,cAAc;AAChB,qBAAa,QAAQ;AACrB,qBAAa,SAAS;AAAA,MACxB;AAGA,WAAK,qBAAqB;AAAA,IAC5B;AAAA,EACF;AAAA,EAEA,OAAO,OAAqB;AAC1B,WACE,gBAAAA,OAAA;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,KAAK;AAAA,QACZ,cAAc,KAAK;AAAA,QACnB,mBAAmB,KAAK;AAAA,SACpB;AAAA,IACN;AAAA,EAEJ;AACF","sourcesContent":["import { Store } from \"../../store/standard/base\";\nimport { makeAutoObservable } from \"mobx\";\nimport Provider from \"./Provider\";\nimport React from \"react\";\nimport { ModalSlots, SlotsToClasses } from \"@nextui-org/react\";\nimport { getStyle, ThemeType } from \"../../themes\";\n\nexport class ConfirmStore implements Store {\n sid = 'ConfirmStore';\n provider = () => <Provider />;\n\n isOpen: boolean = false;\n title?: string = '';\n description?: string = '';\n size: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full' | 'xs' | '3xl' | '4xl' | '5xl' = 'md';\n className: string = '';\n classNames?: SlotsToClasses<ModalSlots>;\n theme: ThemeType = \"default\";\n cancelText?: string = 'Cancel';\n okText?: string = 'Apply';\n\n constructor() {\n makeAutoObservable(this);\n }\n\n toggleOpen(val: boolean) {\n this.isOpen = val;\n }\n\n onOk() { }\n\n onCancel() { }\n\n show(confirmProps: Partial<ConfirmStore>) {\n const modalStyle = getStyle(confirmProps?.theme || 'default', 'Modal');\n const classNames = {\n ...modalStyle.classNames,\n ...confirmProps?.classNames\n }\n Object.assign(this, confirmProps, { classNames });\n\n this.toggleOpen(true);\n }\n\n close() {\n this.isOpen = false;\n this.title = '';\n this.description = '';\n this.size = 'md';\n this.cancelText = 'Cancel';\n this.okText = 'Apply';\n }\n}\n","import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { Button, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader } from '@nextui-org/react';\nimport { useStore } from \"../../store\";\nimport { ConfirmStore } from \".\";\n\nconst ConfirmModal = observer(() => {\n const rootStore = useStore();\n const confirmStore = rootStore.get(ConfirmStore);\n const { isOpen, title, description, size, className, classNames, cancelText, okText } = confirmStore;\n return (\n <Modal\n isOpen={isOpen}\n size={size}\n className={className}\n classNames={classNames}\n onOpenChange={(open: boolean) => {\n if (!open) {\n confirmStore.close();\n }\n }}\n >\n <ModalContent className=\"max-h-screen overflow-auto\">\n {() => (\n <>\n {title && <ModalHeader className=\"flex flex-col gap-1\">{title}</ModalHeader>}\n <ModalBody>\n <div>{description}</div>\n </ModalBody>\n <ModalFooter>\n <Button\n color=\"primary\"\n variant=\"flat\"\n onClick={() => {\n confirmStore.close();\n confirmStore.onCancel();\n }}\n >\n {cancelText}\n </Button>\n <Button\n color=\"primary\"\n onPress={() => {\n confirmStore.close();\n confirmStore.onOk();\n }}\n >\n {okText}\n </Button>\n </ModalFooter>\n </>\n )}\n </ModalContent>\n </Modal>\n );\n});\n\nexport default ConfirmModal;","import React from \"react\";\nimport { makeAutoObservable } from \"mobx\";\nimport { rootStore } from \"../../store\";\nimport { Store } from \"../../store/standard/base\";\nimport Provider from \"./Provider\";\nimport { ModalSlots, SlotsToClasses } from \"@nextui-org/react\";\nimport { getStyle, ThemeType } from \"../../themes\";\n\nexport class DialogStore implements Store {\n sid = \"DialogStore\";\n provider = () => <Provider />;\n\n isOpen = false;\n placement: \"center\" | \"auto\" | \"top\" | \"bottom\" | \"top-center\" | \"bottom-center\";\n title = \"\";\n size: \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\" | \"full\" | \"xs\" | \"3xl\" | \"4xl\" | \"5xl\" = \"md\";\n className: string = \"\";\n classNames?: SlotsToClasses<ModalSlots>;\n theme: ThemeType = \"default\";\n content: React.ReactNode | ((props: any) => React.ReactNode) = \"\";\n isDismissable = true;\n\n constructor(args?: Partial<DialogStore>) {\n const modalStyle = getStyle(args?.theme || 'default', 'Modal');\n const classNames = {\n ...modalStyle.classNames,\n ...args?.classNames\n }\n Object.assign(this, args, { classNames });\n makeAutoObservable(this);\n }\n\n\n setData(v: Partial<DialogStore>) {\n Object.assign(this, v);\n }\n\n close() {\n this.isOpen = false;\n this.title = \"\";\n this.content = \"\";\n this.size = \"md\";\n this.isDismissable = true;\n }\n\n static show(v: Partial<DialogStore>) {\n const modalStyle = getStyle(v?.theme || 'default', 'Modal');\n const classNames = {\n ...modalStyle.classNames,\n ...v?.classNames\n }\n rootStore.get(DialogStore).setData({\n ...v,\n classNames,\n isOpen: true,\n\n });\n }\n\n static close() {\n rootStore.get(DialogStore).close();\n }\n}\n","import React from \"react\";\nimport { Modal, ModalBody, ModalContent, ModalHeader } from \"@nextui-org/react\";\nimport { observer } from \"mobx-react-lite\";\nimport { DialogStore } from \".\";\nimport { useStore } from \"../../store/index\";\n\nconst Dialog = observer(() => {\n const rootStore = useStore();\n const modal = rootStore.get(DialogStore);\n const { className, classNames, isOpen, placement, title, size, content, isDismissable } = modal;\n const Content = typeof content === 'function' ? content : () => content;\n return (\n <Modal\n isOpen={isOpen}\n size={size}\n placement={placement}\n onOpenChange={(open: boolean) => {\n if (!open) {\n modal.close();\n }\n }}\n className={className}\n classNames={classNames}\n isDismissable={isDismissable}\n >\n <ModalContent className=\"max-h-screen overflow-auto\">\n {() => (\n <>\n {title && <ModalHeader className=\"flex flex-col gap-1\">{title}</ModalHeader>}\n <ModalBody>\n <Content />\n </ModalBody>\n </>\n )}\n </ModalContent>\n </Modal >\n );\n});\n\nexport default Dialog;","import React from 'react';\nimport { PromiseState } from '../../store/standard/PromiseState';\nimport { DialogStore } from '../Dialog';\nimport { DialogContentUI, DialogContentUIProps, GroupOptions, StepUI, StepUIProps } from './ui';\nimport { makeObservable } from 'mobx';\n\nexport class PromiseStateGroup {\n group: PromiseState<any, any>[] = [];\n groupOptions: GroupOptions = [];\n currentCallStepNo = 1;\n\n constructor({ group, groupOptions = [] }: { group: PromiseState<any, any>[]; groupOptions: GroupOptions }) {\n group.forEach((p) => {\n Object.assign(p, {\n autoAlert: false,\n value: p.defaultValue,\n errMsg: '',\n });\n });\n Object.assign(this, {\n group,\n groupOptions\n });\n makeObservable(this, {\n currentCallStepNo: true,\n });\n }\n\n async call() {\n let result: any[] = [];\n let errMsg: string = '';\n for (let i = 0; i < this.group.length; i++) {\n this.currentCallStepNo = i + 1;\n const promiseState = this.group[i];\n if (promiseState) {\n try {\n const options = this.groupOptions[i];\n const args = options?.args || [];\n const data = await promiseState.call(...args);\n result.push(data);\n } catch (e) {\n errMsg = e.message;\n if (errMsg?.includes('User rejected the request') || String(e).toLowerCase().includes('user rejected')) {\n errMsg = 'User rejected the request';\n }\n promiseState.errMsg = errMsg;\n break;\n }\n }\n }\n return {\n result,\n errMsg,\n };\n }\n\n showDialog(\n dialogOptions?: Partial<DialogStore>,\n dialogContentOptions?: DialogContentUIProps) {\n DialogStore.show({\n title: '',\n size: 'md',\n isDismissable: false,\n content:\n <DialogContentUI\n group={this.group}\n groupOptions={this.groupOptions}\n {...dialogContentOptions}\n />,\n ...dialogOptions,\n });\n return this;\n }\n\n closeDialog() {\n DialogStore.close();\n }\n\n async stepCall(stepNo: number) {\n const index = stepNo - 1;\n if (index < 0 || index >= this.group.length) {\n return {\n result: null,\n errMsg: 'Invalid step number',\n };\n }\n\n const prePromiseState = this.group[index - 1];\n if (prePromiseState && prePromiseState.errMsg) {\n return {\n result: null,\n errMsg: prePromiseState.errMsg,\n };\n }\n\n this.currentCallStepNo = stepNo;\n\n const promiseState = this.group[index];\n if (promiseState && !promiseState.loading.value) {\n const options = this.groupOptions[index];\n const args = options?.args || [];\n try {\n const result = await promiseState.call(...args);\n return {\n result,\n errMsg: '',\n };\n } catch (e) {\n let errMsg = e.message;\n if (errMsg?.includes('User rejected the request') || String(e).toLowerCase().includes('user rejected')) {\n errMsg = 'User rejected the request';\n }\n promiseState.errMsg = errMsg;\n return {\n result: null,\n errMsg,\n };\n }\n }\n }\n\n onNext() {\n if (this.currentCallStepNo < this.group.length) {\n this.currentCallStepNo += 1;\n }\n }\n\n onPrevious() {\n if (this.currentCallStepNo > 1) {\n\n // reset value and errMsg of the current promiseState\n const index = this.currentCallStepNo - 1;\n const promiseState = this.group[index];\n if (promiseState) {\n promiseState.value = '';\n promiseState.errMsg = '';\n }\n\n // go to the previous step\n this.currentCallStepNo -= 1;\n }\n }\n\n render(props?: StepUIProps) {\n return (\n <StepUI\n group={this.group}\n groupOptions={this.groupOptions}\n currentCallStepNo={this.currentCallStepNo}\n {...props}\n />\n )\n }\n}\n","import React from 'react';\nimport { PromiseState } from '../../store/standard/PromiseState';\nimport { Spinner, SpinnerProps } from '@nextui-org/react';\nimport { Check, X } from 'lucide-react';\nimport { observer } from 'mobx-react-lite';\nimport { cn } from '../../lib/utils';\n\nexport type GroupOptions = {\n args?: any[];\n title: React.ReactNode;\n}[];\n\n\nexport type DialogContentUIProps = {\n className?: string;\n itemClassName?: string;\n numberClassName?: string;\n spinnerProps?: SpinnerProps;\n SuccessIcon?: React.ReactNode;\n FailureIcon?: React.ReactNode;\n};\n\nexport const DialogContentUI = observer(({\n group,\n groupOptions,\n className,\n itemClassName,\n numberClassName,\n spinnerProps = {\n size: 'sm'\n },\n SuccessIcon,\n FailureIcon\n}: {\n group: PromiseState<any, any>[];\n groupOptions: GroupOptions;\n} & DialogContentUIProps) => {\n return (\n <div className={cn(\"space-y-4\", className)}>\n {group.map((promiseState, index) => {\n const uiOptions = groupOptions[index];\n const no = index + 1;\n return (\n <div key={index} className={cn(\"w-full flex items-center justify-between\", itemClassName)}>\n <div className='flex items-center justify-between'>\n <div className={cn('w-6 h-6 flex items-center justify-center text-sm rounded-full border-2 border-[#000000] dark:border-[#cacbcb] mr-2', numberClassName)}>{no}</div>\n {uiOptions?.title}\n </div>\n {promiseState.loading.value ? (\n <Spinner {...spinnerProps} />\n ) : (\n <>\n {promiseState.value && (SuccessIcon || <Check size={20} color=\"#605BFF\" />)}\n {promiseState.errMsg && (FailureIcon || <X size={20} color=\"red\" />)}\n </>\n )}\n </div>\n );\n })}\n </div>\n );\n});\n\n\nexport type StepUIProps = {\n className?: string;\n itemClassName?: string;\n activatedItemClassName?: string;\n numberClassName?: string;\n activatedNumberClassName?: string;\n spinnerProps?: SpinnerProps;\n SuccessIcon?: React.ReactNode;\n FailureIcon?: React.ReactNode;\n};\n\nexport const StepUI = observer(({\n group,\n groupOptions,\n currentCallStepNo,\n className,\n itemClassName,\n activatedItemClassName = '',\n numberClassName,\n activatedNumberClassName = '',\n spinnerProps = {\n size: 'sm'\n },\n SuccessIcon,\n FailureIcon\n}: {\n group: PromiseState<any, any>[];\n groupOptions: GroupOptions;\n currentCallStepNo?: number;\n} & StepUIProps) => {\n return (\n <div className={cn(\"space-y-4\", className)}>\n {group.map((promiseState, index) => {\n const uiOptions = groupOptions[index];\n const no = index + 1;\n return (\n <div\n key={index}\n className={cn(\"w-full flex items-center justify-between text-[#909091] dark:text-[#6b6c6c]\",\n no <= currentCallStepNo ? `text-[#000] dark:text-[#fff] ${activatedItemClassName}` : '',\n itemClassName\n )}\n >\n <div className='flex items-center justify-between'>\n <div\n className={cn('w-6 h-6 flex items-center justify-center text-sm rounded-full border-2 border-[#909091] dark:border-[#6b6c6c] mr-2',\n no <= currentCallStepNo ? `border-[#000] dark:border-[#fff] ${activatedNumberClassName}` : '',\n numberClassName\n )}\n >\n {no}\n </div>\n {uiOptions?.title}\n </div>\n {promiseState.loading.value ? (\n <Spinner {...spinnerProps} />\n ) : (\n <>\n {promiseState.value && no <= currentCallStepNo && (SuccessIcon || <Check size={20} color=\"#605BFF\" />)}\n {promiseState.errMsg && no <= currentCallStepNo && (FailureIcon || <X size={20} color=\"red\" />)}\n </>\n )}\n </div>\n );\n })}\n </div>\n );\n});\n"]}
@@ -106,4 +106,4 @@ declare class RootStore<T extends EventMap = any> {
106
106
  }, ann?: any): T;
107
107
  }
108
108
 
109
- export { type BaseState as B, type EventMap as E, NumberState as N, RootStore as R, Store as S, ValueState as V, type StoreClass as a, StringState as b, BooleanState as c };
109
+ export { BaseState as B, EventMap as E, NumberState as N, RootStore as R, Store as S, ValueState as V, StoreClass as a, StringState as b, BooleanState as c };
package/dist/ui.mjs CHANGED
@@ -1,6 +1,6 @@
1
- export { SkeletonBox } from './chunk-HRYH37UI.mjs';
2
- import { cn } from './chunk-AIZ7XDNV.mjs';
3
- import './chunk-R4SQKVDQ.mjs';
1
+ export { SkeletonBox } from './chunk-WT2ARRCR.mjs';
2
+ import { cn } from './chunk-WYGQ3Y4R.mjs';
3
+ import './chunk-6F7H4PAA.mjs';
4
4
  import { Card } from '@nextui-org/react';
5
5
  import React, { useState, useEffect } from 'react';
6
6
  import copyToClipboard from 'copy-to-clipboard';
package/dist/utils.d.mts CHANGED
@@ -1,5 +1,6 @@
1
- import DataLoader from 'dataloader';
1
+ import * as _dexie from 'dexie';
2
2
  import { Table } from 'dexie';
3
+ import DataLoader from 'dataloader';
3
4
  import BigNumber from 'bignumber.js';
4
5
 
5
6
  declare class DexieCache {
@@ -9,13 +10,7 @@ declare class DexieCache {
9
10
  value: any;
10
11
  expiration: number;
11
12
  };
12
- }, any, {
13
- key: string;
14
- value: {
15
- value: any;
16
- expiration: number;
17
- };
18
- }>;
13
+ }, _dexie.IndexableType>;
19
14
  kv_get: DataLoader<string, {
20
15
  value: any;
21
16
  expiration: number;
package/dist/utils.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  export { cache } from './chunk-7MDKCI65.mjs';
2
2
  export { helper } from './chunk-Q3AD5RHQ.mjs';
3
3
  import './chunk-MGU3KYGC.mjs';
4
- import './chunk-R4SQKVDQ.mjs';
4
+ import './chunk-6F7H4PAA.mjs';
5
5
  //# sourceMappingURL=out.js.map
6
6
  //# sourceMappingURL=utils.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dappworks/kit",
3
- "version": "0.4.140",
3
+ "version": "0.4.141",
4
4
  "description": "",
5
5
  "main": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.mts",