@nan0web/ui 1.0.4 → 1.3.0
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/README.md +19 -14
- package/package.json +6 -4
- package/src/App/Command/DepsCommand.js +25 -0
- package/src/App/Core/CoreApp.js +18 -17
- package/src/App/Core/UI.js +12 -19
- package/src/App/Core/Widget.js +6 -10
- package/src/App/Core/index.js +3 -3
- package/src/App/Scenario.js +4 -4
- package/src/App/User/Command/Message.js +2 -29
- package/src/App/User/Command/index.js +3 -4
- package/src/App/User/UserApp.js +30 -23
- package/src/App/User/UserUI.js +2 -2
- package/src/App/User/index.js +2 -2
- package/src/App/index.js +5 -10
- package/src/Component/Process/Input.js +10 -17
- package/src/Component/Process/Process.js +3 -5
- package/src/Component/Process/index.js +2 -2
- package/src/Component/SortableList/SortableList.js +100 -0
- package/src/Component/SortableList/index.js +3 -0
- package/src/Component/Welcome/Input.js +2 -4
- package/src/Component/Welcome/Welcome.js +5 -9
- package/src/Component/Welcome/index.js +2 -2
- package/src/Component/index.js +5 -3
- package/src/Frame/Frame.js +163 -146
- package/src/Frame/Props.js +20 -20
- package/src/Locale.js +17 -18
- package/src/Model/User/User.js +3 -6
- package/src/Model/index.js +1 -1
- package/src/README.md.js +84 -94
- package/src/StdIn.js +8 -12
- package/src/StdOut.js +23 -27
- package/src/View/RenderOptions.js +1 -1
- package/src/View/View.js +42 -38
- package/src/core/Error/CancelError.js +2 -2
- package/src/core/Error/index.js +3 -5
- package/src/core/Flow.js +347 -0
- package/src/core/Form/Form.js +35 -33
- package/src/core/Form/Input.js +29 -14
- package/src/core/Form/Message.js +3 -6
- package/src/core/Form/index.js +4 -8
- package/src/core/InputAdapter.js +4 -6
- package/src/core/Message/Message.js +9 -12
- package/src/core/Message/OutputMessage.js +19 -17
- package/src/core/Message/index.js +2 -2
- package/src/core/OutputAdapter.js +12 -10
- package/src/core/Stream.js +4 -3
- package/src/core/StreamEntry.js +2 -2
- package/src/core/UiAdapter.js +57 -29
- package/src/core/index.js +38 -9
- package/src/functions.js +8 -15
- package/src/index.js +21 -32
- package/types/App/Command/DepsCommand.d.ts +16 -0
- package/types/App/Command/Options.d.ts +37 -40
- package/types/App/Command/index.d.ts +6 -6
- package/types/App/Core/CoreApp.d.ts +2 -2
- package/types/App/Core/UI.d.ts +6 -7
- package/types/App/Core/Widget.d.ts +4 -4
- package/types/App/Core/index.d.ts +3 -3
- package/types/App/Scenario.d.ts +1 -1
- package/types/App/User/Command/Message.d.ts +2 -16
- package/types/App/User/Command/Options.d.ts +29 -29
- package/types/App/User/Command/index.d.ts +2 -3
- package/types/App/User/UserApp.d.ts +5 -5
- package/types/App/User/index.d.ts +2 -2
- package/types/App/index.d.ts +4 -4
- package/types/Component/Process/Process.d.ts +2 -2
- package/types/Component/Process/index.d.ts +2 -2
- package/types/Component/SortableList/SortableList.d.ts +58 -0
- package/types/Component/SortableList/index.d.ts +2 -0
- package/types/Component/Welcome/Input.d.ts +1 -1
- package/types/Component/Welcome/Welcome.d.ts +1 -1
- package/types/Component/Welcome/index.d.ts +2 -2
- package/types/Component/index.d.ts +5 -3
- package/types/Frame/Frame.d.ts +1 -1
- package/types/Frame/Props.d.ts +1 -1
- package/types/Model/index.d.ts +1 -1
- package/types/StdIn.d.ts +2 -2
- package/types/StdOut.d.ts +1 -1
- package/types/View/View.d.ts +7 -7
- package/types/core/Error/index.d.ts +1 -1
- package/types/core/Flow.d.ts +320 -0
- package/types/core/Form/Form.d.ts +2 -2
- package/types/core/Form/Input.d.ts +15 -4
- package/types/core/Form/Message.d.ts +1 -1
- package/types/core/Form/index.d.ts +3 -3
- package/types/core/InputAdapter.d.ts +2 -2
- package/types/core/Intent.d.ts +65 -68
- package/types/core/Message/InputMessage.d.ts +65 -65
- package/types/core/Message/Message.d.ts +1 -1
- package/types/core/Message/OutputMessage.d.ts +1 -1
- package/types/core/Message/index.d.ts +2 -2
- package/types/core/Stream.d.ts +1 -2
- package/types/core/UiAdapter.d.ts +22 -4
- package/types/core/index.d.ts +5 -2
- package/types/index.d.ts +10 -10
|
@@ -3,69 +3,69 @@
|
|
|
3
3
|
* Represents a message input with value, options, and metadata.
|
|
4
4
|
*/
|
|
5
5
|
export default class InputMessage {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
6
|
+
static ESCAPE: string
|
|
7
|
+
/**
|
|
8
|
+
* Creates an InputMessage instance from the given value.
|
|
9
|
+
* @param {InputMessage|object|string} value - The value to create from
|
|
10
|
+
* @returns {InputMessage} An InputMessage instance
|
|
11
|
+
*/
|
|
12
|
+
static from(value: InputMessage | object | string): InputMessage
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new InputMessage instance.
|
|
15
|
+
* @param {object} props - Input message properties
|
|
16
|
+
* @param {InputMessageValue} [props.value=null] - Input value
|
|
17
|
+
* @param {string[]|string} [props.options=[]] - Available options
|
|
18
|
+
* @param {boolean} [props.waiting=false] - Waiting state flag
|
|
19
|
+
* @param {boolean} [props.escaped=false] - Sets value to escape when true
|
|
20
|
+
*/
|
|
21
|
+
constructor(props?: {
|
|
22
|
+
value?: InputMessageValue | undefined
|
|
23
|
+
options?: string | string[] | undefined
|
|
24
|
+
waiting?: boolean | undefined
|
|
25
|
+
escaped?: boolean | undefined
|
|
26
|
+
})
|
|
27
|
+
/** @type {Message} Input value */
|
|
28
|
+
value: Message
|
|
29
|
+
/** @type {string[]} Available options for this input */
|
|
30
|
+
options: string[]
|
|
31
|
+
/** @type {boolean} Whether this input is waiting for response */
|
|
32
|
+
waiting: boolean
|
|
33
|
+
/**
|
|
34
|
+
* Checks if the input value is empty.
|
|
35
|
+
* @returns {boolean} True if value is empty or null, false otherwise
|
|
36
|
+
*/
|
|
37
|
+
get empty(): boolean
|
|
38
|
+
/**
|
|
39
|
+
* Gets the timestamp when input was created.
|
|
40
|
+
* @returns {number} Creation timestamp
|
|
41
|
+
*/
|
|
42
|
+
get time(): number
|
|
43
|
+
/**
|
|
44
|
+
* Returns the escape value.
|
|
45
|
+
* @returns {string}
|
|
46
|
+
*/
|
|
47
|
+
get ESCAPE(): string
|
|
48
|
+
/**
|
|
49
|
+
* Checks if the input is an escape sequence.
|
|
50
|
+
* @returns {boolean} True if input value is escape sequence, false otherwise
|
|
51
|
+
*/
|
|
52
|
+
get escaped(): boolean
|
|
53
|
+
/**
|
|
54
|
+
* Validates if the input has a non-empty value.
|
|
55
|
+
* @returns {boolean} True if input is valid, false otherwise
|
|
56
|
+
*/
|
|
57
|
+
get isValid(): boolean
|
|
58
|
+
/**
|
|
59
|
+
* Converts the input to a plain object representation.
|
|
60
|
+
* @returns {object} Object with all properties including timestamp
|
|
61
|
+
*/
|
|
62
|
+
toObject(): object
|
|
63
|
+
/**
|
|
64
|
+
* Converts the input to a string representation including timestamp.
|
|
65
|
+
* @returns {string} String representation with timestamp and value
|
|
66
|
+
*/
|
|
67
|
+
toString(): string
|
|
68
|
+
#private
|
|
69
69
|
}
|
|
70
|
-
export type InputMessageValue = Partial<Message> | null
|
|
71
|
-
import { Message } from
|
|
70
|
+
export type InputMessageValue = Partial<Message> | null
|
|
71
|
+
import { Message } from '@nan0web/co'
|
package/types/core/Stream.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { StreamEntry };
|
|
2
1
|
/**
|
|
3
2
|
* Agnostic UI stream for processing progress using async generators.
|
|
4
3
|
*
|
|
@@ -25,4 +24,4 @@ export default class UIStream {
|
|
|
25
24
|
*/
|
|
26
25
|
static process(signal: AbortSignal, generatorFn: () => AsyncGenerator<StreamEntry>, onProgress?: Function, onError?: Function, onComplete?: Function): Promise<void>;
|
|
27
26
|
}
|
|
28
|
-
import StreamEntry from
|
|
27
|
+
import StreamEntry from './StreamEntry.js';
|
|
@@ -74,6 +74,23 @@ export default class UiAdapter extends EventProcessor {
|
|
|
74
74
|
index: number;
|
|
75
75
|
value: string | null;
|
|
76
76
|
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Process a UIForm and return its result.
|
|
79
|
+
*
|
|
80
|
+
* This default implementation follows an **agnostic UI** approach:
|
|
81
|
+
* it simply returns the form instance (with optional initial state merged)
|
|
82
|
+
* without UI interaction. Concrete adapters (CLI, Web, etc.) can override
|
|
83
|
+
* this method to render the form, collect user input and return a richer
|
|
84
|
+
* result object (`{ form, cancelled }`).
|
|
85
|
+
*
|
|
86
|
+
* @param {UIForm} form - The UIForm instance to process.
|
|
87
|
+
* @param {object} [initialState={}] - Pre‑filled values for the form.
|
|
88
|
+
* @returns {Promise<{ form: UIForm, cancelled?: boolean }>} Form processing result.
|
|
89
|
+
*/
|
|
90
|
+
processForm(form: UIForm, initialState?: object): Promise<{
|
|
91
|
+
form: UIForm;
|
|
92
|
+
cancelled?: boolean;
|
|
93
|
+
}>;
|
|
77
94
|
/**
|
|
78
95
|
* Ensures a message's body is fully and validly filled.
|
|
79
96
|
* Generates a form from the message's static Body schema,
|
|
@@ -98,7 +115,8 @@ export default class UiAdapter extends EventProcessor {
|
|
|
98
115
|
*/
|
|
99
116
|
render(message: UIMessage): void;
|
|
100
117
|
}
|
|
101
|
-
import UIForm from
|
|
102
|
-
import EventProcessor from
|
|
103
|
-
import CancelError from
|
|
104
|
-
import
|
|
118
|
+
import UIForm from './Form/Form.js';
|
|
119
|
+
import EventProcessor from '@nan0web/event/oop';
|
|
120
|
+
import CancelError from './Error/CancelError.js';
|
|
121
|
+
import OutputAdapter from './OutputAdapter.js';
|
|
122
|
+
import UIMessage from './Message/Message.js';
|
package/types/core/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export { default as InputAdapter } from "./InputAdapter.js";
|
|
2
2
|
export { default as OutputAdapter } from "./OutputAdapter.js";
|
|
3
|
-
export { default as UIStream } from "./Stream.js";
|
|
4
3
|
export { default as UiMessage } from "./Message/Message.js";
|
|
5
4
|
export { default as FormMessage } from "./Form/Message.js";
|
|
6
5
|
export { default as FormInput } from "./Form/Input.js";
|
|
7
|
-
export { default as UIForm } from "./Form/Form.js";
|
|
8
6
|
export { default as UiAdapter } from "./UiAdapter.js";
|
|
7
|
+
import UIStream from './Stream.js';
|
|
8
|
+
import StreamEntry from './StreamEntry.js';
|
|
9
|
+
import UIForm from './Form/Form.js';
|
|
10
|
+
export { UIStream, UIStream as UiStream, StreamEntry, StreamEntry as UiStreamEntry, UIForm, UIForm as UiForm };
|
|
9
11
|
export { default as Error, CancelError } from "./Error/index.js";
|
|
12
|
+
export { runFlow, flow, View, Prompt, Stream, Alert, Toast, Badge, Text, Table, Input, Select, Confirm, Multiselect, Mask, Password, Spinner, Progress, default as Flow } from "./Flow.js";
|
package/types/index.d.ts
CHANGED
|
@@ -7,15 +7,15 @@ export { default as UiForm } from "./core/Form/Form.js";
|
|
|
7
7
|
export { default as UiMessage } from "./core/Message/Message.js";
|
|
8
8
|
export { default as UiStream } from "./core/Stream.js";
|
|
9
9
|
export { default as UiAdapter } from "./core/UiAdapter.js";
|
|
10
|
-
import Frame from
|
|
11
|
-
import FrameProps from
|
|
12
|
-
import Locale from
|
|
13
|
-
import StdIn from
|
|
14
|
-
import StdOut from
|
|
15
|
-
import View from
|
|
16
|
-
import RenderOptions from
|
|
17
|
-
import Model from
|
|
18
|
-
import Component from
|
|
19
|
-
import App from
|
|
10
|
+
import Frame from './Frame/Frame.js';
|
|
11
|
+
import FrameProps from './Frame/Props.js';
|
|
12
|
+
import Locale from './Locale.js';
|
|
13
|
+
import StdIn from './StdIn.js';
|
|
14
|
+
import StdOut from './StdOut.js';
|
|
15
|
+
import View from './View/View.js';
|
|
16
|
+
import RenderOptions from './View/RenderOptions.js';
|
|
17
|
+
import Model from './Model/index.js';
|
|
18
|
+
import Component from './Component/index.js';
|
|
19
|
+
import App from './App/index.js';
|
|
20
20
|
export { Frame, FrameProps, Locale, StdIn, StdOut, View, RenderOptions, Model, Component, App };
|
|
21
21
|
export { default as Error, CancelError } from "./core/Error/index.js";
|