@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.
Files changed (95) hide show
  1. package/README.md +19 -14
  2. package/package.json +6 -4
  3. package/src/App/Command/DepsCommand.js +25 -0
  4. package/src/App/Core/CoreApp.js +18 -17
  5. package/src/App/Core/UI.js +12 -19
  6. package/src/App/Core/Widget.js +6 -10
  7. package/src/App/Core/index.js +3 -3
  8. package/src/App/Scenario.js +4 -4
  9. package/src/App/User/Command/Message.js +2 -29
  10. package/src/App/User/Command/index.js +3 -4
  11. package/src/App/User/UserApp.js +30 -23
  12. package/src/App/User/UserUI.js +2 -2
  13. package/src/App/User/index.js +2 -2
  14. package/src/App/index.js +5 -10
  15. package/src/Component/Process/Input.js +10 -17
  16. package/src/Component/Process/Process.js +3 -5
  17. package/src/Component/Process/index.js +2 -2
  18. package/src/Component/SortableList/SortableList.js +100 -0
  19. package/src/Component/SortableList/index.js +3 -0
  20. package/src/Component/Welcome/Input.js +2 -4
  21. package/src/Component/Welcome/Welcome.js +5 -9
  22. package/src/Component/Welcome/index.js +2 -2
  23. package/src/Component/index.js +5 -3
  24. package/src/Frame/Frame.js +163 -146
  25. package/src/Frame/Props.js +20 -20
  26. package/src/Locale.js +17 -18
  27. package/src/Model/User/User.js +3 -6
  28. package/src/Model/index.js +1 -1
  29. package/src/README.md.js +84 -94
  30. package/src/StdIn.js +8 -12
  31. package/src/StdOut.js +23 -27
  32. package/src/View/RenderOptions.js +1 -1
  33. package/src/View/View.js +42 -38
  34. package/src/core/Error/CancelError.js +2 -2
  35. package/src/core/Error/index.js +3 -5
  36. package/src/core/Flow.js +347 -0
  37. package/src/core/Form/Form.js +35 -33
  38. package/src/core/Form/Input.js +29 -14
  39. package/src/core/Form/Message.js +3 -6
  40. package/src/core/Form/index.js +4 -8
  41. package/src/core/InputAdapter.js +4 -6
  42. package/src/core/Message/Message.js +9 -12
  43. package/src/core/Message/OutputMessage.js +19 -17
  44. package/src/core/Message/index.js +2 -2
  45. package/src/core/OutputAdapter.js +12 -10
  46. package/src/core/Stream.js +4 -3
  47. package/src/core/StreamEntry.js +2 -2
  48. package/src/core/UiAdapter.js +57 -29
  49. package/src/core/index.js +38 -9
  50. package/src/functions.js +8 -15
  51. package/src/index.js +21 -32
  52. package/types/App/Command/DepsCommand.d.ts +16 -0
  53. package/types/App/Command/Options.d.ts +37 -40
  54. package/types/App/Command/index.d.ts +6 -6
  55. package/types/App/Core/CoreApp.d.ts +2 -2
  56. package/types/App/Core/UI.d.ts +6 -7
  57. package/types/App/Core/Widget.d.ts +4 -4
  58. package/types/App/Core/index.d.ts +3 -3
  59. package/types/App/Scenario.d.ts +1 -1
  60. package/types/App/User/Command/Message.d.ts +2 -16
  61. package/types/App/User/Command/Options.d.ts +29 -29
  62. package/types/App/User/Command/index.d.ts +2 -3
  63. package/types/App/User/UserApp.d.ts +5 -5
  64. package/types/App/User/index.d.ts +2 -2
  65. package/types/App/index.d.ts +4 -4
  66. package/types/Component/Process/Process.d.ts +2 -2
  67. package/types/Component/Process/index.d.ts +2 -2
  68. package/types/Component/SortableList/SortableList.d.ts +58 -0
  69. package/types/Component/SortableList/index.d.ts +2 -0
  70. package/types/Component/Welcome/Input.d.ts +1 -1
  71. package/types/Component/Welcome/Welcome.d.ts +1 -1
  72. package/types/Component/Welcome/index.d.ts +2 -2
  73. package/types/Component/index.d.ts +5 -3
  74. package/types/Frame/Frame.d.ts +1 -1
  75. package/types/Frame/Props.d.ts +1 -1
  76. package/types/Model/index.d.ts +1 -1
  77. package/types/StdIn.d.ts +2 -2
  78. package/types/StdOut.d.ts +1 -1
  79. package/types/View/View.d.ts +7 -7
  80. package/types/core/Error/index.d.ts +1 -1
  81. package/types/core/Flow.d.ts +320 -0
  82. package/types/core/Form/Form.d.ts +2 -2
  83. package/types/core/Form/Input.d.ts +15 -4
  84. package/types/core/Form/Message.d.ts +1 -1
  85. package/types/core/Form/index.d.ts +3 -3
  86. package/types/core/InputAdapter.d.ts +2 -2
  87. package/types/core/Intent.d.ts +65 -68
  88. package/types/core/Message/InputMessage.d.ts +65 -65
  89. package/types/core/Message/Message.d.ts +1 -1
  90. package/types/core/Message/OutputMessage.d.ts +1 -1
  91. package/types/core/Message/index.d.ts +2 -2
  92. package/types/core/Stream.d.ts +1 -2
  93. package/types/core/UiAdapter.d.ts +22 -4
  94. package/types/core/index.d.ts +5 -2
  95. 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
- 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;
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 "@nan0web/co";
70
+ export type InputMessageValue = Partial<Message> | null
71
+ import { Message } from '@nan0web/co'
@@ -90,4 +90,4 @@ export type MessageBodySchema = {
90
90
  defaultValue?: any;
91
91
  validate?: Function | undefined;
92
92
  };
93
- import { Message } from "@nan0web/co";
93
+ import { Message } from '@nan0web/co';
@@ -50,4 +50,4 @@ export default class OutputMessage extends UiMessage {
50
50
  */
51
51
  toJSON(): any;
52
52
  }
53
- import UiMessage from "./Message.js";
53
+ import UiMessage from './Message.js';
@@ -1,4 +1,4 @@
1
1
  export default UiMessage;
2
- import UiMessage from "./Message.js";
3
- import OutputMessage from "./OutputMessage.js";
2
+ import UiMessage from './Message.js';
3
+ import OutputMessage from './OutputMessage.js';
4
4
  export { UiMessage, OutputMessage };
@@ -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 "./StreamEntry.js";
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 "./Form/Form.js";
102
- import EventProcessor from "@nan0web/event/oop";
103
- import CancelError from "./Error/CancelError.js";
104
- import UIMessage from "./Message/Message.js";
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';
@@ -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 "./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";
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";