@dappworks/kit 0.4.139 → 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.
- package/dist/{PromiseState-yojg0WLR.d.ts → PromiseState-b0cc408e.d.ts} +3 -3
- package/dist/aiem.d.mts +1 -1
- package/dist/aiem.mjs +24 -5
- package/dist/aiem.mjs.map +1 -1
- package/dist/{chunk-R4SQKVDQ.mjs → chunk-6F7H4PAA.mjs} +1 -1
- package/dist/{chunk-SVPD6PC6.mjs → chunk-7FF4BCFW.mjs} +4 -4
- package/dist/{chunk-WS43BV7Y.mjs → chunk-DZMNL4BZ.mjs} +2 -2
- package/dist/{chunk-XJMRAPHI.mjs → chunk-HRWHDF2F.mjs} +7 -7
- package/dist/{chunk-XJMRAPHI.mjs.map → chunk-HRWHDF2F.mjs.map} +1 -1
- package/dist/{chunk-QWHU3HBK.mjs → chunk-PPYYRQDD.mjs} +2 -2
- package/dist/{chunk-HRYH37UI.mjs → chunk-WT2ARRCR.mjs} +2 -2
- package/dist/{chunk-AIZ7XDNV.mjs → chunk-WYGQ3Y4R.mjs} +14 -14
- package/dist/chunk-WYGQ3Y4R.mjs.map +1 -0
- package/dist/dev.d.mts +1 -1
- package/dist/dev.mjs +2 -2
- package/dist/experimental.d.mts +2 -2
- package/dist/experimental.mjs +3 -3
- package/dist/form.d.mts +5 -5
- package/dist/form.mjs +4 -4
- package/dist/{index-CUKoRIdy.d.ts → index-38be834f.d.ts} +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +5 -5
- package/dist/inspector.d.mts +1 -1
- package/dist/inspector.mjs +1 -1
- package/dist/jsontable.d.mts +2 -2
- package/dist/jsontable.mjs +4 -4
- package/dist/metrics.d.mts +1 -1
- package/dist/metrics.mjs +4 -4
- package/dist/plugins.d.mts +33 -7
- package/dist/plugins.mjs +163 -34
- package/dist/plugins.mjs.map +1 -1
- package/dist/{root-C3lZnoCI.d.ts → root-766ae985.d.ts} +1 -1
- package/dist/ui.mjs +3 -3
- package/dist/utils.d.mts +3 -8
- package/dist/utils.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-AIZ7XDNV.mjs.map +0 -1
- /package/dist/{PaginationState-Bmrrw0ky.d.ts → PaginationState-c19e621a.d.ts} +0 -0
- /package/dist/{chunk-R4SQKVDQ.mjs.map → chunk-6F7H4PAA.mjs.map} +0 -0
- /package/dist/{chunk-SVPD6PC6.mjs.map → chunk-7FF4BCFW.mjs.map} +0 -0
- /package/dist/{chunk-WS43BV7Y.mjs.map → chunk-DZMNL4BZ.mjs.map} +0 -0
- /package/dist/{chunk-QWHU3HBK.mjs.map → chunk-PPYYRQDD.mjs.map} +0 -0
- /package/dist/{chunk-HRYH37UI.mjs.map → chunk-WT2ARRCR.mjs.map} +0 -0
package/dist/form.d.mts
CHANGED
|
@@ -3,9 +3,9 @@ import { ButtonProps, TabsProps, CheckboxProps, SlotsToClasses, InputSlots, Inpu
|
|
|
3
3
|
import { UiSchema, RJSFSchema, WidgetProps, Widget } from '@rjsf/utils';
|
|
4
4
|
import * as _rjsf_validator_ajv8_lib_validator from '@rjsf/validator-ajv8/lib/validator';
|
|
5
5
|
import Form, { IChangeEvent } from '@rjsf/core';
|
|
6
|
-
import { T as ThemeType } from './index-
|
|
6
|
+
import { T as ThemeType } from './index-38be834f.js';
|
|
7
7
|
import { EditorProps } from '@monaco-editor/react';
|
|
8
|
-
import { S as Store, R as RootStore } from './root-
|
|
8
|
+
import { S as Store, R as RootStore } from './root-766ae985.js';
|
|
9
9
|
import EventEmitter from 'events';
|
|
10
10
|
import 'typed-emitter';
|
|
11
11
|
|
|
@@ -310,7 +310,7 @@ declare class ComplexFormModalStore<T extends FormDataType> implements Store {
|
|
|
310
310
|
modalSize: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full' | 'xs' | '3xl' | '4xl' | '5xl';
|
|
311
311
|
scrollBehavior?: 'normal' | 'inside' | 'outside';
|
|
312
312
|
isDismissable: boolean;
|
|
313
|
-
event: EventEmitter
|
|
313
|
+
event: EventEmitter;
|
|
314
314
|
onBatchSubmit?: (data: T, setLoading?: Dispatch<SetStateAction<boolean>>) => void;
|
|
315
315
|
onSet?: (v: FormDataOfKey<T>, form: JSONSchemaFormState<FormDataOfKey<T>, UiSchema>) => FormDataOfKey<T>;
|
|
316
316
|
onChange?: (data: Partial<T>) => void;
|
|
@@ -340,7 +340,7 @@ declare class FormModalStore<T = {
|
|
|
340
340
|
modalSize: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full' | 'xs' | '3xl' | '4xl' | '5xl';
|
|
341
341
|
scrollBehavior?: 'normal' | 'inside' | 'outside';
|
|
342
342
|
closeOnOverlayClick: boolean;
|
|
343
|
-
event: EventEmitter
|
|
343
|
+
event: EventEmitter;
|
|
344
344
|
onAfterSubmit?: (data: T) => void;
|
|
345
345
|
constructor(args?: Partial<FormModalStore>);
|
|
346
346
|
setData(v: Partial<FormModalStore>): void;
|
|
@@ -413,4 +413,4 @@ declare class JSONViewPlugin implements Store {
|
|
|
413
413
|
static JSONView: (props: JSONViewType) => React.JSX.Element;
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
-
export { CheckboxWidget,
|
|
416
|
+
export { CheckboxWidget, CheckboxWidgetProps, CheckboxWidgetUIOptions, ComplexFormModalStore, DatePickerWidget, DatePickerWidgetProps, DatePickerWidgetUIOptions, EditorWidget, EditorWidgetProps, EditorWidgetUIOptions, FieldLayoutType, FormConfigType, FormDataOfKey, FormDataType, FormKey, FormLayoutType, FormModalStore, InputWidget, InputWidgetProps, InputWidgetUIOptions, JSONDataType, JSONForm, JSONFormProps, JSONSchemaForm, JSONViewPlugin, JSONViewType, LayoutConfigType, LayoutType, MultipleSelectWidget, MultipleSelectWidgetProps, MultipleSelectWidgetUIOptions, SelectWidget, SelectWidgetProps, SelectWidgetUIOptions, TextareaWidget, TextareaWidgetProps, TextareaWidgetUIOptions, getComplexFormData, getFormData, getFormState, getSimpleFormData };
|
package/dist/form.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getStyle } from './chunk-5SFAINN6.mjs';
|
|
2
|
-
import { useStore } from './chunk-
|
|
3
|
-
import { RootStore } from './chunk-
|
|
2
|
+
import { useStore } from './chunk-DZMNL4BZ.mjs';
|
|
3
|
+
import { RootStore } from './chunk-HRWHDF2F.mjs';
|
|
4
4
|
import { helper } from './chunk-Q3AD5RHQ.mjs';
|
|
5
5
|
import { _ } from './chunk-MGU3KYGC.mjs';
|
|
6
|
-
import { cn } from './chunk-
|
|
7
|
-
import { __objRest, __spreadValues, __spreadProps } from './chunk-
|
|
6
|
+
import { cn } from './chunk-WYGQ3Y4R.mjs';
|
|
7
|
+
import { __objRest, __spreadValues, __spreadProps } from './chunk-6F7H4PAA.mjs';
|
|
8
8
|
import React7, { useEffect, useMemo, useState, useRef, useCallback, createRef } from 'react';
|
|
9
9
|
import { Modal, ModalContent, ModalHeader, ModalBody, Checkbox, Input, Select, SelectItem, Button, Textarea, DatePicker, Chip, Card, Tabs, Tab } from '@nextui-org/react';
|
|
10
10
|
import { Check, ChevronUp, ChevronDown } from 'lucide-react';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { R as RootStore, E as EventMap } from './root-
|
|
2
|
-
export { B as BaseState, c as BooleanState, N as NumberState, S as Store, a as StoreClass, b as StringState, V as ValueState } from './root-
|
|
3
|
-
export { P as PromiseState } from './PromiseState-
|
|
1
|
+
import { R as RootStore, E as EventMap } from './root-766ae985.js';
|
|
2
|
+
export { B as BaseState, c as BooleanState, N as NumberState, S as Store, a as StoreClass, b as StringState, V as ValueState } from './root-766ae985.js';
|
|
3
|
+
export { P as PromiseState } from './PromiseState-b0cc408e.js';
|
|
4
4
|
import * as mobx from 'mobx';
|
|
5
5
|
import BigNumber from 'bignumber.js';
|
|
6
|
-
export { P as PaginationState } from './PaginationState-
|
|
6
|
+
export { P as PaginationState } from './PaginationState-c19e621a.js';
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import 'typed-emitter';
|
|
9
9
|
import 'events';
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { BooleanState, NumberState, PromiseState, Store, StringState, ValueState } from './chunk-
|
|
1
|
+
export { BooleanState, NumberState, PromiseState, Store, StringState, ValueState } from './chunk-PPYYRQDD.mjs';
|
|
2
2
|
import './chunk-4YCP5CJ4.mjs';
|
|
3
|
-
export { rootStore, useStore } from './chunk-
|
|
4
|
-
import { RootStore } from './chunk-
|
|
5
|
-
export { RootStore } from './chunk-
|
|
3
|
+
export { rootStore, useStore } from './chunk-DZMNL4BZ.mjs';
|
|
4
|
+
import { RootStore } from './chunk-HRWHDF2F.mjs';
|
|
5
|
+
export { RootStore } from './chunk-HRWHDF2F.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-
|
|
9
|
+
import './chunk-6F7H4PAA.mjs';
|
|
10
10
|
import { observable, makeAutoObservable } from 'mobx';
|
|
11
11
|
import BigNumber2 from 'bignumber.js';
|
|
12
12
|
import React from 'react';
|
package/dist/inspector.d.mts
CHANGED
package/dist/inspector.mjs
CHANGED
package/dist/jsontable.d.mts
CHANGED
|
@@ -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-
|
|
3
|
+
import { P as PaginationState } from './PaginationState-c19e621a.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 {
|
|
100
|
+
export { CardOptions, Column, ColumnOptions, ExtendedTable, HeaderKeys, JSONTable };
|
package/dist/jsontable.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { JSONTable } from './chunk-
|
|
1
|
+
export { JSONTable } from './chunk-7FF4BCFW.mjs';
|
|
2
2
|
import './chunk-ONVPCAMQ.mjs';
|
|
3
|
-
import './chunk-
|
|
3
|
+
import './chunk-WT2ARRCR.mjs';
|
|
4
4
|
import './chunk-MGU3KYGC.mjs';
|
|
5
|
-
import './chunk-
|
|
6
|
-
import './chunk-
|
|
5
|
+
import './chunk-WYGQ3Y4R.mjs';
|
|
6
|
+
import './chunk-6F7H4PAA.mjs';
|
|
7
7
|
//# sourceMappingURL=out.js.map
|
|
8
8
|
//# sourceMappingURL=jsontable.mjs.map
|
package/dist/metrics.d.mts
CHANGED
package/dist/metrics.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { JSONTable } from './chunk-
|
|
1
|
+
import { JSONTable } from './chunk-7FF4BCFW.mjs';
|
|
2
2
|
import './chunk-ONVPCAMQ.mjs';
|
|
3
|
-
import { SkeletonBox } from './chunk-
|
|
3
|
+
import { SkeletonBox } from './chunk-WT2ARRCR.mjs';
|
|
4
4
|
import './chunk-MGU3KYGC.mjs';
|
|
5
|
-
import { cn } from './chunk-
|
|
6
|
-
import { __spreadValues } from './chunk-
|
|
5
|
+
import { cn } from './chunk-WYGQ3Y4R.mjs';
|
|
6
|
+
import { __spreadValues } from './chunk-6F7H4PAA.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';
|
package/dist/plugins.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { S as Store } from './root-
|
|
1
|
+
import { S as Store } from './root-766ae985.js';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { SlotsToClasses, ModalSlots } from '@nextui-org/react';
|
|
4
|
-
import { T as ThemeType } from './index-
|
|
3
|
+
import { SlotsToClasses, ModalSlots, SpinnerProps } from '@nextui-org/react';
|
|
4
|
+
import { T as ThemeType } from './index-38be834f.js';
|
|
5
5
|
import * as react_hot_toast from 'react-hot-toast';
|
|
6
|
-
import { P as PromiseState } from './PromiseState-
|
|
6
|
+
import { P as PromiseState } from './PromiseState-b0cc408e.js';
|
|
7
7
|
import 'typed-emitter';
|
|
8
8
|
import 'events';
|
|
9
9
|
|
|
@@ -66,10 +66,29 @@ 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
|
+
};
|
|
69
87
|
|
|
70
88
|
declare class PromiseStateGroup {
|
|
71
89
|
group: PromiseState<any, any>[];
|
|
72
90
|
groupOptions: GroupOptions;
|
|
91
|
+
currentCallStepNo: number;
|
|
73
92
|
constructor({ group, groupOptions }: {
|
|
74
93
|
group: PromiseState<any, any>[];
|
|
75
94
|
groupOptions: GroupOptions;
|
|
@@ -78,11 +97,18 @@ declare class PromiseStateGroup {
|
|
|
78
97
|
result: any[];
|
|
79
98
|
errMsg: string;
|
|
80
99
|
}>;
|
|
81
|
-
|
|
82
|
-
|
|
100
|
+
showDialog(dialogOptions?: Partial<DialogStore>, dialogContentOptions?: DialogContentUIProps): this;
|
|
101
|
+
closeDialog(): void;
|
|
102
|
+
stepCall(stepNo: number): Promise<{
|
|
103
|
+
result: any;
|
|
83
104
|
errMsg: string;
|
|
105
|
+
} | {
|
|
106
|
+
result: any;
|
|
107
|
+
errMsg: any;
|
|
84
108
|
}>;
|
|
85
|
-
|
|
109
|
+
onNext(): void;
|
|
110
|
+
onPrevious(): void;
|
|
111
|
+
render(props?: StepUIProps): React.JSX.Element;
|
|
86
112
|
}
|
|
87
113
|
|
|
88
114
|
export { ConfirmStore, DialogStore, PromiseStateGroup, ToastPlugin };
|
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-
|
|
4
|
-
import './chunk-
|
|
3
|
+
import { useStore, rootStore } from './chunk-DZMNL4BZ.mjs';
|
|
4
|
+
import './chunk-HRWHDF2F.mjs';
|
|
5
5
|
import './chunk-MGU3KYGC.mjs';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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
|
|
156
|
-
|
|
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
|
-
|
|
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
|
-
|
|
185
|
-
if (promiseState && options) {
|
|
243
|
+
if (promiseState) {
|
|
186
244
|
try {
|
|
187
|
-
const
|
|
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
|
-
|
|
264
|
+
showDialog(dialogOptions, dialogContentOptions) {
|
|
206
265
|
DialogStore.show(__spreadValues({
|
|
207
266
|
title: "",
|
|
208
267
|
size: "md",
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
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 };
|
package/dist/plugins.mjs.map
CHANGED
|
@@ -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,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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G5B,WAAO,OAAO,MAAM;AAAA,MAClB;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,OAAO;AACX,QAAI,SAAgB,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"]}
|
|
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;A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AAa,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 {
|
|
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-
|
|
2
|
-
import { cn } from './chunk-
|
|
3
|
-
import './chunk-
|
|
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';
|