@dappworks/kit 0.4.141 → 0.4.142

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 (43) hide show
  1. package/dist/{PromiseState-b0cc408e.d.ts → PromiseState-yojg0WLR.d.ts} +3 -3
  2. package/dist/aiem.d.mts +6 -3
  3. package/dist/aiem.mjs +31 -44
  4. package/dist/aiem.mjs.map +1 -1
  5. package/dist/{chunk-WYGQ3Y4R.mjs → chunk-AIZ7XDNV.mjs} +14 -14
  6. package/dist/chunk-AIZ7XDNV.mjs.map +1 -0
  7. package/dist/{chunk-WT2ARRCR.mjs → chunk-HRYH37UI.mjs} +2 -2
  8. package/dist/{chunk-PPYYRQDD.mjs → chunk-QWHU3HBK.mjs} +2 -2
  9. package/dist/{chunk-6F7H4PAA.mjs → chunk-R4SQKVDQ.mjs} +1 -1
  10. package/dist/{chunk-7FF4BCFW.mjs → chunk-SVPD6PC6.mjs} +4 -4
  11. package/dist/{chunk-DZMNL4BZ.mjs → chunk-WS43BV7Y.mjs} +2 -2
  12. package/dist/{chunk-HRWHDF2F.mjs → chunk-XJMRAPHI.mjs} +7 -7
  13. package/dist/{chunk-HRWHDF2F.mjs.map → chunk-XJMRAPHI.mjs.map} +1 -1
  14. package/dist/dev.d.mts +1 -1
  15. package/dist/dev.mjs +2 -2
  16. package/dist/experimental.d.mts +2 -2
  17. package/dist/experimental.mjs +3 -3
  18. package/dist/form.d.mts +5 -5
  19. package/dist/form.mjs +4 -4
  20. package/dist/{index-38be834f.d.ts → index-CUKoRIdy.d.ts} +1 -1
  21. package/dist/index.d.mts +4 -4
  22. package/dist/index.mjs +5 -5
  23. package/dist/inspector.d.mts +1 -1
  24. package/dist/inspector.mjs +1 -1
  25. package/dist/jsontable.d.mts +2 -2
  26. package/dist/jsontable.mjs +4 -4
  27. package/dist/metrics.d.mts +1 -1
  28. package/dist/metrics.mjs +4 -4
  29. package/dist/plugins.d.mts +7 -33
  30. package/dist/plugins.mjs +34 -163
  31. package/dist/plugins.mjs.map +1 -1
  32. package/dist/{root-766ae985.d.ts → root-C3lZnoCI.d.ts} +1 -1
  33. package/dist/ui.mjs +3 -3
  34. package/dist/utils.d.mts +8 -3
  35. package/dist/utils.mjs +1 -1
  36. package/package.json +1 -1
  37. package/dist/chunk-WYGQ3Y4R.mjs.map +0 -1
  38. /package/dist/{PaginationState-c19e621a.d.ts → PaginationState-Bmrrw0ky.d.ts} +0 -0
  39. /package/dist/{chunk-WT2ARRCR.mjs.map → chunk-HRYH37UI.mjs.map} +0 -0
  40. /package/dist/{chunk-PPYYRQDD.mjs.map → chunk-QWHU3HBK.mjs.map} +0 -0
  41. /package/dist/{chunk-6F7H4PAA.mjs.map → chunk-R4SQKVDQ.mjs.map} +0 -0
  42. /package/dist/{chunk-7FF4BCFW.mjs.map → chunk-SVPD6PC6.mjs.map} +0 -0
  43. /package/dist/{chunk-DZMNL4BZ.mjs.map → chunk-WS43BV7Y.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
- export { BooleanState, NumberState, PromiseState, Store, StringState, ValueState } from './chunk-PPYYRQDD.mjs';
1
+ export { BooleanState, NumberState, PromiseState, Store, StringState, ValueState } from './chunk-QWHU3HBK.mjs';
2
2
  import './chunk-4YCP5CJ4.mjs';
3
- export { rootStore, useStore } from './chunk-DZMNL4BZ.mjs';
4
- import { RootStore } from './chunk-HRWHDF2F.mjs';
5
- export { RootStore } from './chunk-HRWHDF2F.mjs';
3
+ export { rootStore, useStore } from './chunk-WS43BV7Y.mjs';
4
+ import { RootStore } from './chunk-XJMRAPHI.mjs';
5
+ export { RootStore } from './chunk-XJMRAPHI.mjs';
6
6
  import { helper } from './chunk-Q3AD5RHQ.mjs';
7
7
  export { PaginationState } from './chunk-ONVPCAMQ.mjs';
8
8
  import './chunk-MGU3KYGC.mjs';
9
- import './chunk-6F7H4PAA.mjs';
9
+ import './chunk-R4SQKVDQ.mjs';
10
10
  import { observable, makeAutoObservable } from 'mobx';
11
11
  import BigNumber2 from 'bignumber.js';
12
12
  import React from 'react';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { S as Store } from './root-766ae985.js';
2
+ import { S as Store } from './root-C3lZnoCI.js';
3
3
  import 'typed-emitter';
4
4
 
5
5
  declare class DevInspectorPlugin implements Store {
@@ -1,4 +1,4 @@
1
- import './chunk-6F7H4PAA.mjs';
1
+ import './chunk-R4SQKVDQ.mjs';
2
2
  import React from 'react';
3
3
  import { Inspector } from 'react-dev-inspector';
4
4
 
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { SlotsToClasses, TableSlots, PaginationProps, SpinnerProps } from '@nextui-org/react';
3
- import { P as PaginationState } from './PaginationState-c19e621a.js';
3
+ import { P as PaginationState } from './PaginationState-Bmrrw0ky.js';
4
4
 
5
5
  type HeaderKeys<T extends Record<string, any>> = Array<keyof T | '$actions'>;
6
6
  type ColumnOptions<T> = {
@@ -97,4 +97,4 @@ declare const JSONTable: (<T extends Record<string, any>>(props: JSONTableProps<
97
97
  displayName: string;
98
98
  };
99
99
 
100
- export { CardOptions, Column, ColumnOptions, ExtendedTable, HeaderKeys, JSONTable };
100
+ export { type CardOptions, type Column, type ColumnOptions, type ExtendedTable, type HeaderKeys, JSONTable };
@@ -1,8 +1,8 @@
1
- export { JSONTable } from './chunk-7FF4BCFW.mjs';
1
+ export { JSONTable } from './chunk-SVPD6PC6.mjs';
2
2
  import './chunk-ONVPCAMQ.mjs';
3
- import './chunk-WT2ARRCR.mjs';
3
+ import './chunk-HRYH37UI.mjs';
4
4
  import './chunk-MGU3KYGC.mjs';
5
- import './chunk-WYGQ3Y4R.mjs';
6
- import './chunk-6F7H4PAA.mjs';
5
+ import './chunk-AIZ7XDNV.mjs';
6
+ import './chunk-R4SQKVDQ.mjs';
7
7
  //# sourceMappingURL=out.js.map
8
8
  //# sourceMappingURL=jsontable.mjs.map
@@ -118,4 +118,4 @@ declare const MetricsView: ({ data }: {
118
118
  data: JSONMetricsViewType;
119
119
  }) => React.JSX.Element;
120
120
 
121
- export { JSONMetricsView, JSONMetricsViewType, MetricsView };
121
+ export { JSONMetricsView, type JSONMetricsViewType, MetricsView };
package/dist/metrics.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { JSONTable } from './chunk-7FF4BCFW.mjs';
1
+ import { JSONTable } from './chunk-SVPD6PC6.mjs';
2
2
  import './chunk-ONVPCAMQ.mjs';
3
- import { SkeletonBox } from './chunk-WT2ARRCR.mjs';
3
+ import { SkeletonBox } from './chunk-HRYH37UI.mjs';
4
4
  import './chunk-MGU3KYGC.mjs';
5
- import { cn } from './chunk-WYGQ3Y4R.mjs';
6
- import { __spreadValues } from './chunk-6F7H4PAA.mjs';
5
+ import { cn } from './chunk-AIZ7XDNV.mjs';
6
+ import { __spreadValues } from './chunk-R4SQKVDQ.mjs';
7
7
  import React8 from 'react';
8
8
  import { Grid, Col, BarChart, LineChart, AreaChart, DonutChart, Text } from '@tremor/react';
9
9
  import { Card } from '@nextui-org/react';
@@ -1,9 +1,9 @@
1
- import { S as Store } from './root-766ae985.js';
1
+ import { S as Store } from './root-C3lZnoCI.js';
2
2
  import React from 'react';
3
- import { SlotsToClasses, ModalSlots, SpinnerProps } from '@nextui-org/react';
4
- import { T as ThemeType } from './index-38be834f.js';
3
+ import { SlotsToClasses, ModalSlots } from '@nextui-org/react';
4
+ import { T as ThemeType } from './index-CUKoRIdy.js';
5
5
  import * as react_hot_toast from 'react-hot-toast';
6
- import { P as PromiseState } from './PromiseState-b0cc408e.js';
6
+ import { P as PromiseState } from './PromiseState-yojg0WLR.js';
7
7
  import 'typed-emitter';
8
8
  import 'events';
9
9
 
@@ -66,29 +66,10 @@ type GroupOptions = {
66
66
  args?: any[];
67
67
  title: React.ReactNode;
68
68
  }[];
69
- type DialogContentUIProps = {
70
- className?: string;
71
- itemClassName?: string;
72
- numberClassName?: string;
73
- spinnerProps?: SpinnerProps;
74
- SuccessIcon?: React.ReactNode;
75
- FailureIcon?: React.ReactNode;
76
- };
77
- type StepUIProps = {
78
- className?: string;
79
- itemClassName?: string;
80
- activatedItemClassName?: string;
81
- numberClassName?: string;
82
- activatedNumberClassName?: string;
83
- spinnerProps?: SpinnerProps;
84
- SuccessIcon?: React.ReactNode;
85
- FailureIcon?: React.ReactNode;
86
- };
87
69
 
88
70
  declare class PromiseStateGroup {
89
71
  group: PromiseState<any, any>[];
90
72
  groupOptions: GroupOptions;
91
- currentCallStepNo: number;
92
73
  constructor({ group, groupOptions }: {
93
74
  group: PromiseState<any, any>[];
94
75
  groupOptions: GroupOptions;
@@ -97,18 +78,11 @@ declare class PromiseStateGroup {
97
78
  result: any[];
98
79
  errMsg: string;
99
80
  }>;
100
- showDialog(dialogOptions?: Partial<DialogStore>, dialogContentOptions?: DialogContentUIProps): this;
101
- closeDialog(): void;
102
- stepCall(stepNo: number): Promise<{
103
- result: any;
81
+ ui(dialogOptions?: Partial<DialogStore>): Promise<{
82
+ result: any[];
104
83
  errMsg: string;
105
- } | {
106
- result: any;
107
- errMsg: any;
108
84
  }>;
109
- onNext(): void;
110
- onPrevious(): void;
111
- render(props?: StepUIProps): React.JSX.Element;
85
+ closeUI(): void;
112
86
  }
113
87
 
114
88
  export { ConfirmStore, DialogStore, PromiseStateGroup, ToastPlugin };
package/dist/plugins.mjs CHANGED
@@ -1,12 +1,11 @@
1
1
  export { ToastPlugin } from './chunk-4YCP5CJ4.mjs';
2
2
  import { getStyle } from './chunk-5SFAINN6.mjs';
3
- import { useStore, rootStore } from './chunk-DZMNL4BZ.mjs';
4
- import './chunk-HRWHDF2F.mjs';
3
+ import { useStore, rootStore } from './chunk-WS43BV7Y.mjs';
4
+ import './chunk-XJMRAPHI.mjs';
5
5
  import './chunk-MGU3KYGC.mjs';
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';
6
+ import { __spreadValues, __spreadProps } from './chunk-R4SQKVDQ.mjs';
7
+ import { makeAutoObservable } from 'mobx';
8
+ import React from 'react';
10
9
  import { observer } from 'mobx-react-lite';
11
10
  import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button, Spinner } from '@nextui-org/react';
12
11
  import { Check, X } from 'lucide-react';
@@ -15,7 +14,7 @@ var ConfirmModal = observer(() => {
15
14
  const rootStore2 = useStore();
16
15
  const confirmStore = rootStore2.get(ConfirmStore);
17
16
  const { isOpen, title, description, size, className, classNames, cancelText, okText } = confirmStore;
18
- return /* @__PURE__ */ React5.createElement(
17
+ return /* @__PURE__ */ React.createElement(
19
18
  Modal,
20
19
  {
21
20
  isOpen,
@@ -28,7 +27,7 @@ var ConfirmModal = observer(() => {
28
27
  }
29
28
  }
30
29
  },
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(
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(
32
31
  Button,
33
32
  {
34
33
  color: "primary",
@@ -39,7 +38,7 @@ var ConfirmModal = observer(() => {
39
38
  }
40
39
  },
41
40
  cancelText
42
- ), /* @__PURE__ */ React5.createElement(
41
+ ), /* @__PURE__ */ React.createElement(
43
42
  Button,
44
43
  {
45
44
  color: "primary",
@@ -56,7 +55,7 @@ var Provider_default = ConfirmModal;
56
55
  var ConfirmStore = class {
57
56
  constructor() {
58
57
  this.sid = "ConfirmStore";
59
- this.provider = () => /* @__PURE__ */ React5.createElement(Provider_default, null);
58
+ this.provider = () => /* @__PURE__ */ React.createElement(Provider_default, null);
60
59
  this.isOpen = false;
61
60
  this.title = "";
62
61
  this.description = "";
@@ -94,7 +93,7 @@ var Dialog = observer(() => {
94
93
  const modal = rootStore2.get(DialogStore);
95
94
  const { className, classNames, isOpen, placement, title, size, content, isDismissable } = modal;
96
95
  const Content = typeof content === "function" ? content : () => content;
97
- return /* @__PURE__ */ React5.createElement(
96
+ return /* @__PURE__ */ React.createElement(
98
97
  Modal,
99
98
  {
100
99
  isOpen,
@@ -109,7 +108,7 @@ var Dialog = observer(() => {
109
108
  classNames,
110
109
  isDismissable
111
110
  },
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))))
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))))
113
112
  );
114
113
  });
115
114
  var Provider_default2 = Dialog;
@@ -118,7 +117,7 @@ var Provider_default2 = Dialog;
118
117
  var DialogStore = class _DialogStore {
119
118
  constructor(args) {
120
119
  this.sid = "DialogStore";
121
- this.provider = () => /* @__PURE__ */ React5.createElement(Provider_default2, null);
120
+ this.provider = () => /* @__PURE__ */ React.createElement(Provider_default2, null);
122
121
  this.isOpen = false;
123
122
  this.title = "";
124
123
  this.size = "md";
@@ -153,97 +152,39 @@ var DialogStore = class _DialogStore {
153
152
  rootStore.get(_DialogStore).close();
154
153
  }
155
154
  };
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) => {
155
+ var DialogContent = observer(({ group, groupOptions }) => {
156
+ return /* @__PURE__ */ React.createElement("div", { className: "pb-4 space-y-4" }, group.map((promiseState, index) => {
169
157
  const uiOptions = groupOptions[index];
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
- );
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" }))));
215
159
  }));
216
160
  });
161
+
162
+ // module/PromiseStateGroup/index.tsx
217
163
  var PromiseStateGroup = class {
218
164
  constructor({ group, groupOptions = [] }) {
219
165
  this.group = [];
220
166
  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
- });
229
167
  Object.assign(this, {
230
168
  group,
231
169
  groupOptions
232
170
  });
233
- makeObservable(this, {
234
- currentCallStepNo: true
235
- });
236
171
  }
237
172
  async call() {
238
173
  let result = [];
239
174
  let errMsg = "";
175
+ this.group.forEach((p) => {
176
+ Object.assign(p, {
177
+ autoAlert: false,
178
+ value: p.defaultValue,
179
+ errMsg: ""
180
+ });
181
+ });
240
182
  for (let i = 0; i < this.group.length; i++) {
241
- this.currentCallStepNo = i + 1;
242
183
  const promiseState = this.group[i];
243
- if (promiseState) {
184
+ const options = this.groupOptions[i];
185
+ if (promiseState && options) {
244
186
  try {
245
- const options = this.groupOptions[i];
246
- const args = (options == null ? void 0 : options.args) || [];
187
+ const args = options.args || [];
247
188
  const data = await promiseState.call(...args);
248
189
  result.push(data);
249
190
  } catch (e) {
@@ -261,89 +202,19 @@ var PromiseStateGroup = class {
261
202
  errMsg
262
203
  };
263
204
  }
264
- showDialog(dialogOptions, dialogContentOptions) {
205
+ async ui(dialogOptions) {
265
206
  DialogStore.show(__spreadValues({
266
207
  title: "",
267
208
  size: "md",
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;
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;
278
214
  }
279
- closeDialog() {
215
+ closeUI() {
280
216
  DialogStore.close();
281
217
  }
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
- }
347
218
  };
348
219
 
349
220
  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;A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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"]}
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,QAAQ,OAAO,aAAa,MAAM,WAAW,YAAY,YAAY,OAAO,IAAI;AACxF,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc,CAAC,SAAkB;AAC/B,YAAI,CAAC,MAAM;AACT,uBAAa,MAAM;AAAA,QACrB;AAAA,MACF;AAAA;AAAA,IAEA,oCAAC,gBAAa,WAAU,gCACrB,MACC,0DACG,SAAS,oCAAC,eAAY,WAAU,yBAAuB,KAAM,GAC9D,oCAAC,iBACC,oCAAC,aAAK,WAAY,CACpB,GACA,oCAAC,mBACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAM;AAAA,QACN,SAAQ;AAAA,QACR,SAAS,MAAM;AACb,uBAAa,MAAM;AACnB,uBAAa,SAAS;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,CAAC;AACrB,QAAI,SAAiB;AACrB,SAAK,MAAM,QAAQ,CAAC,MAAM;AACxB,aAAO,OAAO,GAAG;AAAA,QACf,WAAW;AAAA,QACX,OAAO,EAAE;AAAA,QACT,QAAQ;AAAA,MACV,CAAC;AAAA,IACH,CAAC;AACD,aAAS,IAAI,GAAG,IAAI,KAAK,MAAM,QAAQ,KAAK;AAC1C,YAAM,eAAe,KAAK,MAAM,CAAC;AACjC,YAAM,UAAU,KAAK,aAAa,CAAC;AACnC,UAAI,gBAAgB,SAAS;AAC3B,YAAI;AACF,gBAAM,OAAO,QAAQ,QAAQ,CAAC;AAC9B,gBAAM,OAAO,MAAM,aAAa,KAAK,GAAG,IAAI;AAC5C,iBAAO,KAAK,IAAI;AAAA,QAClB,SAAS,GAAG;AACV,mBAAS,EAAE;AACX,eAAI,iCAAQ,SAAS,iCAAgC,OAAO,CAAC,EAAE,YAAY,EAAE,SAAS,eAAe,GAAG;AACtG,qBAAS;AAAA,UACX;AACA,uBAAa,SAAS;AACtB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,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"]}
@@ -106,4 +106,4 @@ declare class RootStore<T extends EventMap = any> {
106
106
  }, ann?: any): T;
107
107
  }
108
108
 
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 };
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 };
package/dist/ui.mjs CHANGED
@@ -1,6 +1,6 @@
1
- export { SkeletonBox } from './chunk-WT2ARRCR.mjs';
2
- import { cn } from './chunk-WYGQ3Y4R.mjs';
3
- import './chunk-6F7H4PAA.mjs';
1
+ export { SkeletonBox } from './chunk-HRYH37UI.mjs';
2
+ import { cn } from './chunk-AIZ7XDNV.mjs';
3
+ import './chunk-R4SQKVDQ.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,6 +1,5 @@
1
- import * as _dexie from 'dexie';
2
- import { Table } from 'dexie';
3
1
  import DataLoader from 'dataloader';
2
+ import { Table } from 'dexie';
4
3
  import BigNumber from 'bignumber.js';
5
4
 
6
5
  declare class DexieCache {
@@ -10,7 +9,13 @@ declare class DexieCache {
10
9
  value: any;
11
10
  expiration: number;
12
11
  };
13
- }, _dexie.IndexableType>;
12
+ }, any, {
13
+ key: string;
14
+ value: {
15
+ value: any;
16
+ expiration: number;
17
+ };
18
+ }>;
14
19
  kv_get: DataLoader<string, {
15
20
  value: any;
16
21
  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-6F7H4PAA.mjs';
4
+ import './chunk-R4SQKVDQ.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.141",
3
+ "version": "0.4.142",
4
4
  "description": "",
5
5
  "main": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.mts",